필터 지우기
필터 지우기

save sequence of images in a folder using matlab

조회 수: 3 (최근 30일)
annmaria
annmaria 2015년 7월 10일
댓글: Image Analyst 2015년 7월 10일
I want to save images into a folder. I tried a code given below
[Ilabel num] = bwlabel(If);
disp(num);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Ibox = reshape(Ibox,[4 83]);
figure,imshow(Ibox);
for n=1:num
[r,c] = find(Ilabel==n);
% Extract letter
n1=Iout(min(r):max(r),min(c):max(c));
% Resize letter (same size of template)
img_r=imresize(n1,[42 24]);
%figure,imshow(n1);
%Uncomment line below to see letters one by one
%imshow(img_r);pause(0.5)
imwrite(img_r,['H:\\mainproject\\codes\\images\\test0.jpg' ]);
end
But only the last letter is saved in the folder. I dont know where it made mistakes.I tried a lot but i didn't get it.please help me and thanks in advance

채택된 답변

Image Analyst
Image Analyst 2015년 7월 10일
Change the filename then:
baseFileName = sprintf('H:\\mainproject\\codes\\images\\Letter%d.png');
fullFileName = fullfile(pwd, baseFileName); % Prepend folder
imwrite(img_r, fullFileName);
  댓글 수: 1
Image Analyst
Image Analyst 2015년 7월 10일
By the way, you can just use the bounding box, which you already got, rather than recomputing it with find(), min(), and max(). That's just a waste of time.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by