How can I save images in a loop?

1 vue (au cours des 30 derniers jours)
Aliyu Abdu
Aliyu Abdu le 20 Avr 2012
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

Réponse acceptée

Walter Roberson
Walter Roberson le 20 Avr 2012
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
  1 commentaire
Aliyu Abdu
Aliyu Abdu le 20 Avr 2012
That was quite helpful. Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by