save images in a new folder
古いコメントを表示
Hi,
I am using the below subroutine inside for loop to save images during every itertaion. Here, I would like to save the images in new folder. Please help me with this...
if (f>=1) && (f<=9)
saveas(gcf, sprintf('S0000%d', f), 'bmp')
elseif (f>=10) && (f<=99)
saveas(gcf, sprintf('S000%d', f), 'bmp');
elseif (f>=100) && (f<=999)
saveas(gcf, sprintf('S00%d', f), 'bmp');
else
saveas(gcf, sprintf('S0%d', f), 'bmp');
end
6 件のコメント
Turbulence Analysis
2020 年 9 月 26 日
Mario Malic
2020 年 9 月 26 日
Missing on
saveas(gcf, fullFileName)
Turbulence Analysis
2020 年 9 月 26 日
Mario Malic
2020 年 9 月 26 日
prefix = '\\new\\';
thisBaseFileName = sprintf('%sS%4.5d.png',prefix, f);
Image Analyst
2020 年 9 月 26 日
Have two folders:
inputFolder = 'D:\CH\';
outputFolder = 'D:\CH\new\';
if ~isfolder(outputFolder)
mkdir(outputFolder);
end
Then in the loop
fname = fullfile(inputFolder, fname); % Create full input filename.
thisBaseFileName = sprintf('S%4.5d.png', f); % Base output file name.
fullFileName = fullfile(outputFolder, thisBaseFileName); % Create full output filename in different folder.
Not sure why you removed the folder from my call to fullfile() in my answer. You should not have done that. fullfile() needs both a folder and a base file name.
Turbulence Analysis
2020 年 9 月 27 日
採用された回答
その他の回答 (1 件)
Mario Malic
2020 年 9 月 26 日
saveas(gcf, sprintf('/folder/S0000%d.bmp', f))
2 件のコメント
Turbulence Analysis
2020 年 9 月 26 日
Mario Malic
2020 年 9 月 26 日
No, /folder/ is, but use Image Analyst's solution, it's much better than what you have.
カテゴリ
ヘルプ センター および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!