View .pgm images in Matlab

I have been given a dataset consisting of .pgm images that will be used for some encoding in Matlab. I'm just wondering if it is possible to view the same image as .jpeg / .png in Matlab?

thank

+5
source share
2 answers

To render an image in Matlab,

imshow(imread('im.pgm'))

To convert an image from pgmto jpeg:

imwrite(imread('im.pgm'),'im.jpg')
+5
source

The MathWorks imread docs seem to suggest that Matlab can read in the pgm file.

The display should consist of use imshowin the resulting array returned imread.

+2
source

All Articles