Why does turning the visibility of a figure to "off" slow things down?

조회 수: 15 (최근 30일)
Michael Mancinelli
Michael Mancinelli 2015년 11월 19일
댓글: Mike Garrity 2015년 11월 23일
I have an application where turning the visibility of the figure off actually quadruples the run time of my program. I do a lot of axis and lighting manipulations between grabbing the screen.
Here is brief example that leads to a roughly 10% increase in time:
%%->> Visible ON<<-
tic
h = figure('Visible', 'On');
surf(peaks);
light;
axis([10 40 10 40 -5 5]);
h.Color = 'r';
view(45,45);
data = getframe();
toc
%%->>Visible OFF<<-
tic
h = figure('Visible', 'Off');
surf(peaks);
light;
axis([10 40 10 40 -5 5]);
h.Color = 'r';
view(45,45);
data = getframe();
toc
Basically, I would love an explanation as to why MATLAB acts any differently when the figure is not displayed!

답변 (1개)

Mike Garrity
Mike Garrity 2015년 11월 19일
They actually don't do the same thing at all.
In the Visible='on' case, the pixels are already sitting in the framebuffer on the graphics card. The getframe function just fetches them.
In the Visible='off' case, there is no framebuffer and the graphics haven't already been drawn. So the getframe command basically starts a print job. Printing is nearly as tightly optimized as on screen rendering because it supports lots of additional features that you're not using here. For one thing, it needs to allocate a number of resources which are basically free when you're drawing into the framebuffer.
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 11월 19일
Mike, is that "is nearly" or "is not nearly" ? The "is nearly" would imply that the timing should be very close, which the rest of your discussion seems to argue otherwise.
Mike Garrity
Mike Garrity 2015년 11월 23일
Yes, it looks like I lost track of a negation there. Sorry about that.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by