Saved figure different than actual figure size (?)

Hi, I'm trying to save a figure as a .tif, however, the output .tif file is different than the specified figure size. Here is an example:
im=imread('rice.png');
fig=figure;
set(gcf,'Position',[30 30 512 256]);
hL=axes('Position',[0 0 .5 1],'Visible','off');
hR=axes('Position',[.5 0 .5 1],'Visible','off');
set(gcf,'CurrentAxes',hL);
imshow(im,[]);
set(gcf,'CurrentAxes',hR);
imshow(im,[]);
print(gcf,'-dtiff','temp');
The output image is 1200 x 900 pixels, not the 512 x 256 I specified in the program. What am I missing during the export to get the output to be 512 x 256?
Thanks, Matt K.

 채택된 답변

Matt
Matt 2011년 2월 28일

0 개 추천

I think that the answer came down to a combo of the suggested answers. After I show the figure, I edited the code to be:
set(gcf,'PaperUnits','inches');
set(gcf,'PaperPosition',[1 1 5.12 2.56]);
set(gcf,'PaperPositionMode','manual');
print(gcf,'-dtiff','-r100','temp');
See more info about this from a MATLAB blog here, and some other info available here.
Thanks for your help.

추가 답변 (3개)

Walter Roberson
Walter Roberson 2011년 2월 25일

1 개 추천

See the figure PaperPosition and PaperPositionMode properties.
the cyclist
the cyclist 2011년 2월 25일

0 개 추천

Can you use the -r option? E.g.
>> print(gcf,'-dtiff','-r300','temp')
Oliver Woodford
Oliver Woodford 2011년 2월 27일

0 개 추천

To get the output you expect (i.e. a fair representation of the figure on the screen) without having to set lots of options, use export_fig.
In this case try:
export_fig temp.tif -nocrop

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

질문:

2011년 2월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by