Viewing .pgm images in Matlab

user1105630 picture user1105630 · Mar 22, 2012 · Viewed 12.8k times · Source

I have been provided with a dataset consisting of .pgm images to be used for some coding in Matlab. I was just wondering if it is possible to view the same image as a .jpeg/.png in Matlab itself?

Thanks

Answer

Oli picture Oli · Mar 22, 2012

To visualize the image in matlab,

imshow(imread('im.pgm'))

To convert the image from pgm to jpeg:

imwrite(imread('im.pgm'),'im.jpg')