I have a set of images (> 500) and I want to convert them to .PGM
format.
Is there some way to do it from a .m
file?
Best regards!
UPDATE 06/09/2016
I found the following link, where IRFANVIEW commands to appear, but I have no experience running external commands from matlab. I used the following script:
dir_irfanview=('C:\Program Files (x86)\IrfanView\i_view32.exe');
cmd ='filelist=c:\v\list.txt /convert= c:\vc\*.pgm';
cmd2 = [cmd,dir_irfanview];
system(cmd2);
and I get the following error:
"filelist" is not recognized as an internal or external command, program or batch file.
Note that I used the "i_view32.exe filelist=c:\v\list.txt /convert= c:\vc*.pgm" command in DOS and no problems.
some guidance?
As Jørgen suggested, you can use system()
to call irfanview to convert.
Alternatively, you can use imread
and imwrite
in a loop to do the job in a more "matlab"-ish way
fls = dir('/path/to/images/*');
for ii=1:numel(fls)
if fls(ii).isdir
continue;
end
[pth fn ext] = fileparts(fls(ii).name);
img = imread(fullfile('/path/to/images',fls(ii).name));
imwrite(img, fullfile('/path/to/images',[fn, '.pgm']));
end