필터 지우기
필터 지우기

How to open multiple images, processing each image, then saving it into a folder?

조회 수: 3 (최근 30일)
My code is as below,
file = dir('C:\Users\doey\Desktop\New folder');
file = file(~[file.isdir]); NF = length(file);
for k = 1 : NF
Img = imread(fullfile('C:\Users\doey\Desktop\New folder', file(k).name));
% Processing the image
% Obtain figure(k)
print(figure(k),'-dpng','C:\Users\doey\Desktop\New folder (2)')
close(gcf)
end
Can anyone answer these 2 questions:
1) The figures which I obtain are not saving in my directory (C:\Users\doey\Desktop\New folder) although I can show it during my processing.
2) I cannot load tiff images with this code. Why not???

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 27일
Let us know if you can't.
  댓글 수: 2
inter steller
inter steller 2015년 3월 28일
i can read the file now , but why i still can't save my figure? as the code above , after i done my image processing for multiple images, i were plotted something for every image, and i need to auto-save them into a folder.
Image Analyst
Image Analyst 2015년 3월 28일
Like the FAQ says, create your filename using sprintf() and fullfile(). Then you just call imwrite(yourImage, fullFileName) to write it out to a disk file in the folder. If you want to write the whole figure or axes, because you have put up some graphical overlay onto the image, then use export_fig() instead.
You're using print() instead, which might be okay, but you're just giving it a folder name and not a filename. Try constructing a filename:
fullFileName = fullfile('C:\Users\doey\Desktop\New folder', file(k).name)
[folder, fn, ext] = fileparts(fullFileName);
% Change extension to .png.
fn = sprintf('%s.png', fn);
% Prepend folder
fullFileName = fullfile(folder, fn);
% Save to disk.
print(figure(k), fullFileName);

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

카테고리

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