How can I input an animated gif image into an axes?

2 次查看(过去 30 天)
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 个评论
Kevin Chng
Kevin Chng 2018-10-14
[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
Walter Roberson 2018-10-14
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by