学习需要,要将PPM格式的图片转换为bmp格式,试了两种方法:
1.使用Photoshop 2019逐张转换,另存为你需要的格式。
2.使用代码进行转换,这里我使用matlab工具进行转换
参考博客
%--------------------------2019-10-18----------------------%
% 在当前工作环境下,本示例程序将 E:\10.15 综述总结\行人数据集\MIT行人数据集\pedestrians128x64\\s1 目录下
%所有的.ppm 图片转换为 .bmp 图片
function[ ] = ppm2bmp( )
%读取指定目录下面所有的 ppm 格式图片
ppms = dir('E:\10.15 综述总结\行人数据集\MIT行人数据集\pedestrians128x64\*.ppm');
num_ppms = length( ppms );
for i = 1 : num_ppms
ppm_file = fullfile( 'E:\10.15 综述总结\行人数据集\MIT行人数据集\pedestrians128x64\' , ppms(i).name );
ppm = imread(ppm_file);
% 第一步,解析文件名 ppm_file,ppm_file包括路径+文件名+后缀,
% 如 bmp_file = '.\ORL人脸数据库\s1\1.bmp'
% path = '.\ORL人脸数据库\s1' name = '1' ext = '.bmp'
[ path , name , ext ] = fileparts( ppm_file ) ;
% 第二步,生成新的文件名
filename = strcat( name , '.bmp' );
% 第三步,生成文件全称
bmp_file = fullfile( 'E:\10.17\BMP\' , filename ) ;
% 第四步,将 bmp 以 bmp_file 作为文件名,保存为 bmp 格式。
imwrite( ppm , bmp_file , 'bmp' );
end
end
天知道我为啥要花一天时间用第一种方法…