【问题标题】:Can I run irfanview in MATLAB and batch/convert images?我可以在 MATLAB 中运行 irfanview 并批量/转换图像吗?
【发布时间】:2017-01-09 01:06:47
【问题描述】:

我有一组图像 (> 500),我想将它们转换为 .PGM 格式。
有没有办法从.m 文件中做到这一点?

最好的问候!

2016 年 6 月 9 日更新

我找到了以下link,其中出现了 IRFANVIEW 命令,但我没有从 matlab 运行外部命令的经验。我使用了以下脚本:

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);

我收到以下错误:

"filelist" 未被识别为内部或外部命令, 程序或批处理文件。

请注意,我在 DOS 中使用了“i_view32.exe filelist=c:\v\list.txt /convert= c:\vc*.pgm”命令,没有问题。

一些指导?

【问题讨论】:

  • IrfanView自带的批量转换选项有什么问题?
  • 是的,使用system 在matlab 之外运行程序。
  • 我使用的人脸识别方法(C/C++ 中的 .bat)在 matlab 中创建的图像(图像头)有问题,所以要使用我需要将 .pgm 转换为 . pgm

标签: matlab irfanview


【解决方案1】:

按照Jørgen的建议,您可以使用system()调用irfanview进行转换。

或者,您可以在循环中使用 imreadimwrite 以更“matlab”式的方式完成这项工作

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

【讨论】:

  • 非常感谢,已经阅读了有关命令 system() 的信息,我需要信息来访问一些特定的选项程序(例如:在 Irfanview 中按“B”导致转换选项)。问候!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 2015-06-13
  • 1970-01-01
相关资源
最近更新 更多