-3

I have to convert 'Yale' dataset whose format is .pgm to .mat file, I searched about this issue but couldn't find anything.

I appreciate any help.

Amit Singh
  • 2,875
  • 14
  • 30
Samaneh Rezaei
  • 73
  • 2
  • 11

1 Answers1

1

Images can be saved in .mat format by using the save() function offered by MATLAB.

Let us suppose the name of your image is xyz.pgm that has to be saved as xyz.mat. Following steps should do so :

im = imread('xyz.pgm')
save('xyz.mat','im')

You can look into save() function to learn more about it.

Instead if you just want to convert it into other image formats, you should look up imwrite().

Amit Singh
  • 2,875
  • 14
  • 30
  • thank u, just one question: if I have 4 .pgm images and want to save them in a uniqe .mat file , in that occassion what should I do? for example, PIE.mat file consists of many images. I want to put all of 4 images in just one .mat file. – Samaneh Rezaei Nov 02 '17 at 17:39
  • 1
    You can use `('xyz.mat','im1','im2','im3','im4','im5')` where `im` represent ith image variable. – Amit Singh Nov 02 '17 at 17:52