Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Wong Wei Weng
Wong Wei Weng el 9 de Oct. de 2018
Comentada: Walter Roberson el 14 de Oct. de 2018
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 comentarios
Kevin Chng
Kevin Chng el 14 de Oct. de 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
Walter Roberson el 14 de Oct. de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by