필터 지우기
필터 지우기

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 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