user1105630
user1105630

Reputation: 65

Viewing .pgm images in Matlab

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

Upvotes: 4

Views: 14334

Answers (2)

Oli
Oli

Reputation: 16035

To visualize the image in matlab,

imshow(imread('im.pgm'))

To convert the image from pgm to jpeg:

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

Upvotes: 6

jpjacobs
jpjacobs

Reputation: 9549

The MathWorks docs on imread seem to suggest Matlab can read in a pgm file.

Showing it should be a matter of using imshow on the resulting array returned by imread.

Upvotes: 1

Related Questions