'fill' and 'image' incompatible
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponse acceptée
Patrick Kalita
le 4 Mai 2011
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');
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!