How can I input an animated gif image into an axes?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
When i apply the code implay(file), it straightly comes out with a player, the problem i met is i would like to put it in axes, how should I solve that? I have attached .m file, .gif image and .fig file
2 Kommentare
Kevin Chng
am 14 Okt. 2018
[gifImage cmap] = imread('1232.gif', 'Frames', 'all');
len=length(gifImage(1,1,1,:));
for i=1:1:len
image(app.UIAxes,gifImage(:,:,:,i));
pause(0.1);
end
Refer to my code above, i have tried it out, but it is something wrong that they change the background to yellow. Once i have time, i will try back here to see it.
Walter Roberson
am 14 Okt. 2018
info = imfinfo('parsley_classify.gif');
info(1).TransparentColor
ans =
217
info(1).ColorType
ans =
'indexed'
So Kevin Chng's suggestion would have to be modified to something like
filename = 'parsley_classify.gif';
info = imfinfo(filename);
transparent_color = info(1).TransparentColor;
delays = [info.DelayTime] / 100; %varies for each frame!
[gifImage cmap] = imread('parsley_classify.gif', 'Frames', 'all');
alphas = double(gifImage ~= transparent_color);
len = size(gifImage, 4);
for frame = 1 : len
image(gifImage(:,:,:,frame));
colormap(cmap);
pause(delays(frame));
end
Note: MATLAB does not support automatic playing of GIF animations in traditional axes (I do not know about apps). However, it does support autoplay of GIF in Live Script; https://www.mathworks.com/matlabcentral/answers/422870-can-i-insert-an-animated-gif-into-a-live-script
Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!