How can I save images in a loop?

1 次查看(过去 30 天)
Hi.. I'm working on a project that can crop individual lines from a document image. So far, I have achieved the cropping but I can't write a code that can save the cropped and remaining lines' images in every loop. Can anyone help? Below is the code I'm using:
function [fl re]=lines(im_texto)
% Divide text in lines
% im_texto->input image; fl->first line; re->remain line
im_texto=clip(im_texto);
num_filas=size(im_texto,1);
for s=1:num_filas
if sum(im_texto(s,:))==0
nm=im_texto(1:s-1, :); % First line matrix
rm=im_texto(s:end, :);% Remain line matrix
fl = clip(nm);
re=clip(rm);
%*-*-*Uncomment lines below to see the result*-*-*-*-
% subplot(2,1,1);imshow(fl);
% subplot(2,1,2);imshow(re);
break
else
fl=im_texto;%Only one line.
re=[ ];
end
end
function img_out=clip(img_in)
[f c]=find(img_in);
img_out=img_in(min(f):max(f),min(c):max(c));%Crops image

采纳的回答

Walter Roberson
Walter Roberson 2012-4-20
print() or saveas() or use the File Exchange contribution export_fig .
For information about how to change the file name each iteration see http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

更多回答(0 个)

类别

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