简体   繁体   English

如何在 Matlab 中将 .pgm 文件转换为 .mat 文件?

[英]How to convert .pgm file to .mat file in Matlab?

I have to convert 'Yale' dataset whose format is .pgm to .mat file, I searched about this issue but couldn't find anything.我必须将格式为.pgm “耶鲁”数据集转换为.mat文件,我搜索了这个问题但找不到任何东西。

I appreciate any help.我很感激任何帮助。

Images can be saved in .mat format by using the save() function offered by MATLAB.使用 MATLAB 提供的save()函数可以将图像保存为.mat格式。

Let us suppose the name of your image is xyz.pgm that has to be saved as xyz.mat .让我们假设您的图像名称是xyz.pgm ,必须保存为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.您可以查看save()函数以了解更多信息。

Instead if you just want to convert it into other image formats, you should look up imwrite() .相反,如果您只想将其转换为其他图像格式,则应查找imwrite()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM