save images in a new folder

조회 수: 1 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2020년 9월 26일
댓글: Turbulence Analysis 2020년 9월 27일
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
Image Analyst
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
Turbulence Analysis 2020년 9월 27일
Thanks it worked perfectly..
Furthermore, regarding my previous query on "having two colorbars in the contours for the images read in .im7 format". I have sent the .im7 files and loadvec function as per your request. Is .im7 readable now ???

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2020년 9월 26일
Do it this way:
folder = pwd % Wherever you want...
for k = 1 : 1234
thisBaseFileName = sprintf('S%4.4d.png', k);
fullFileName = fullfile(thisBaseFileName);
fprintf('Saving %s\n', fullFileName);
% saveas() of exportgraphics()
end

추가 답변 (1개)

Mario Malic
Mario Malic 2020년 9월 26일
saveas(gcf, sprintf('/folder/S0000%d.bmp', f))
  댓글 수: 2
Turbulence Analysis
Turbulence Analysis 2020년 9월 26일
Is 'f' here represents the folder destination ??
Mario Malic
Mario Malic 2020년 9월 26일
No, /folder/ is, but use Image Analyst's solution, it's much better than what you have.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by