4

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

user1105630
  • 65
  • 1
  • 1
  • 5

2 Answers2

6

To visualize the image in matlab,

imshow(imread('im.pgm'))

To convert the image from pgm to jpeg:

imwrite(imread('im.pgm'),'im.jpg')
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
Oli
  • 15,935
  • 7
  • 50
  • 66
1

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.

jpjacobs
  • 9,359
  • 36
  • 45