3

我正在对图像文件集进行一些批处理,这要求文件应在文件名末尾使用附加的“_corrected”字符串保存,例如“IMG_001.tif”应在处理后保存为“IMG_001_corrected”。 .jpg'。

这是我的代码:

FileList = dir('srgb8bit/*.tif');
N = size(FileList,1);

for k = 1:N

   % get the file name:
   filename = FileList(k).name;
   I = imread(filename);
   Icorr = CorrectedRetinexFM(I,8);
   ** Here should go the save command**

最好能够选择不同的目录来保存它们。这怎么可能?

非常感谢你的帮助!

4

1 回答 1

4

Use fileparts to split the file name and its extension:

[pathstr, name, ext] = fileparts(FileList(k).name);

Note that pathstr is "" since you already stripped that.

And then imwrite like this

imwrite(Icorr, [name '_corrected.jpg']);
于 2012-10-22T17:53:35.223 回答