figure(1);

imshow(img);

hold on;

h = line([xa' ; xb'], [ya' ; yb']) ;

set(h,'linewidth', 2, 'color', 'b') ;



saveas(gcf,'img_line.jpg');


참고

http://kr.mathworks.com/help/matlab/ref/savefig.html


저장 이미지 해상도를 조절하고 싶을 경우

print 함수 사용

http://kr.mathworks.com/help/matlab/ref/print.html?searchHighlight=print


* 저장된 이미지에서 white margin 을 없애고 싶은 경우

http://tipstrickshowtos.blogspot.kr/2010/08/how-to-get-rid-of-white-margin-in.html


saveThightFigure 함수 사용

사용법 saveTightFigure(h,'output.pdf');

(matching_distrat_ransac_zacurr.m 파일 참고)

코드

-----------------------------------------------------------------------------------------------

function saveTightFigure(h,outfilename)

% SAVETIGHTFIGURE(H,OUTFILENAME) Saves figure H in file OUTFILENAME without

%   the white space around it. 

%

% by ``a grad student"

% http://tipstrickshowtos.blogspot.com/2010/08/how-to-get-rid-of-white-margin-in.html


% get the current axes

ax = get(h, 'CurrentAxes');


% make it tight

ti = get(ax,'TightInset');

set(ax,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);


% adjust the papersize

set(ax,'units','centimeters');

pos = get(ax,'Position');

ti = get(ax,'TightInset');

set(h, 'PaperUnits','centimeters');

set(h, 'PaperSize', [pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);

set(h, 'PaperPositionMode', 'manual');

set(h, 'PaperPosition',[0 0  pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);


% save it

saveas(h,outfilename);

-----------------------------------------------------------------------------------------------


* 그외 figure 관계 없이 이미지를 저장할 때

imwrite 함수

ex) imwrite(img_crop,crop_img_name,'Quality',100);

http://kr.mathworks.com/help/images/writing-image-data-to-a-file.html

http://kr.mathworks.com/help/matlab/ref/imwrite.html


http://tthinking.tistory.com/29


Posted by 우주여행가
,