How can I save images in a loop?

1 visualización (últimos 30 días)
Aliyu Abdu
Aliyu Abdu el 20 de Abr. de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Abr. de 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 comentario
Aliyu Abdu
Aliyu Abdu el 20 de Abr. de 2012
That was quite helpful. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by