How can I save images in a loop?

1 回表示 (過去 30 日間)
Aliyu Abdu
Aliyu Abdu 2012 年 4 月 20 日
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
  1 件のコメント
Aliyu Abdu
Aliyu Abdu 2012 年 4 月 20 日
That was quite helpful. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by