フィルターのクリア

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

2 ビュー (過去 30 日間)
Wong Wei Weng
Wong Wei Weng 2018 年 10 月 9 日
コメント済み: Walter Roberson 2018 年 10 月 14 日
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 Center および File ExchangeAnimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by