The different results of functions getframe and imread

1 次查看(过去 30 天)
Hi everybody
I have simple function:
=================================================
function getframe_inmread
for i = 1:200
for j = 1:300
latmap(i,j) = 10 + (j - 1) * 0.1;
lonmap(i,j) = 10 + (i - 1) * 0.1;
end;
end
A(1:200, 1:300) = 1;
A(50:100, 100:200) = 2;
f1 = figure;
axesm gortho
surfm(latmap,lonmap,A);
% ------------ version 1 - getframe
pos = get(gcf,'Position');
Bgf = getframe(gcf);
sgf = size(Bgf.cdata)
% ------------ version 2 - imread
fl_pic = 'tmp_frim';
% print('-f1', '-dpng',fl_pic);
print('-f1', '-dbmp',fl_pic);
close(f1);
% af = imread([fl_pic '.png']);
af = imread([fl_pic '.bmp']);
saf = size(af)
================================================
Obtain arrays (colors) of different dimension.
>>sgf =
420 560 3
>>saf =
901 1201 3
I need to getframe gave the same array as imread, because upon application of map I should take the second map of imread.
Any help on the topic would be greatly appreciated.
Thanks
  1 个评论
Jan
Jan 2011-12-2
Please apply a proper code formatting as explained in the "Markup help" link. And please be so kind and explain, why the formatting of the code is so hard for beginners.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2011-12-2
The function getframe creates an exact pixel copy of the contents of the window. In opposite to this print performs some rescaling, e.g. if you export the figure contents with a different resolution. But even for -r0, the original screen resolution, the output is not exact. E.g. UICONTROLs are rendered differently and embedded as raster images.
In consequence IMREAD(PRINT) and GETFRAME will not produce the 100% equal results.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by