'fill' and 'image' incompatible
Show older comments
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!
Accepted Answer
More Answers (1)
Nuno
on 4 May 2011
0 votes
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!