save sequence of images in a folder using matlab
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
annmaria
am 10 Jul. 2015
Kommentiert: Image Analyst
am 10 Jul. 2015
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
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 10 Jul. 2015
Change the filename then:
baseFileName = sprintf('H:\\mainproject\\codes\\images\\Letter%d.png');
fullFileName = fullfile(pwd, baseFileName); % Prepend folder
imwrite(img_r, fullFileName);
1 Kommentar
Image Analyst
am 10 Jul. 2015
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!