필터 지우기
필터 지우기

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 CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by