'fill' and 'image' incompatible

조회 수: 14 (최근 30일)
Nuno
Nuno 2011년 5월 4일
This demonstrates my previous question(<http://www.mathworks.com/matlabcentral/answers/6749-graphic-ghost)>, now with real code.
There is a wrong behaviour when I mix 'fill' and 'image' on the same plot.
This is demonstrated by the following code.
clc
close all
clear all
axis([-5 200 -5 200]);
axis square;
hold on
for pos=120:200
a=fill([10 10 0 0]+pos/2,[10 0 0 10]+pos/2,'r');
b=image([pos pos+40],[pos pos+40],rand(40)*100,'AlphaData',0.5*ones(40));
drawnow
if ishandle(b)
delete(a);
delete(b);
end
end
In Matlab r2010b the random color image will disapear as soon as it touch the axis(plot border). I can see only a thin line on the edge of the image. If you comment the 'a=fill...' and 'delete(a)' lines, it will work as expected. I tried to generate a animated gif with this, but it showed another bug, that I had complained previously. If you look at http://geodac.di.ubi.pt/nuno/bug1.gif you will see the 'fill' moving without the 'image'. When I add the image, at http://geodac.di.ubi.pt/nuno/bug2.gif, everything freezes on the first position. That means frame = getframe(1); only gets the first frame after the image was inserted, and the transparency seems to have been applied to the entire image.
This bug only appears when 'AlphaData' is used. Opaque images work fine!

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 5월 4일
The problem generating the movie is a known issue, documented here: http://www.mathworks.com/support/bugreports/384622. It mentions Windows Vista, but it also seems to occur on Windows 7.
The original issue of the image not showing up correctly could be a bug. I would recommend contacting support about it.
In just playing around with your example, it looks like perhaps swapping the order in which the image and the fill are created could be a workaround. Compare this ...
axis([-5 200 -5 200]);
axis square;
hold on
pos=160;
a=fill([10 10 0 0]+pos/2,[10 0 0 10]+pos/2,'r');
b=image([pos pos+40],[pos pos+40],rand(40)*100,'AlphaData',0.5*ones(40));
...and this...
axis([-5 200 -5 200]);
axis square;
hold on
pos=160;
b=image([pos pos+40],[pos pos+40],rand(40)*100,'AlphaData',0.5*ones(40));
a=fill([10 10 0 0]+pos/2,[10 0 0 10]+pos/2,'r');
  댓글 수: 1
Nuno
Nuno 2011년 5월 4일
Thanks for your answer.
Your workaround might work on this case but not in real life...That is because I don't delete the objects for performance reasons, so both 'image' and 'fill' objects are updated after they are created, so it's not possible to never change the 'image' after the 'fill' is created.

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

추가 답변 (1개)

Nuno
Nuno 2011년 5월 4일
This bug doesn't exist on the UNIX version. Probably only Win Vista and Win 7.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by