Displaying GIF Image Matlab

370 views (last 30 days)
Rooy
Rooy on 21 Apr 2012
Edited: DGM on 4 May 2022
I tried using this code
[X,map] = imread('electricity.gif');
imshow(X,map)
I also tried looking at online help but it does not solve my problem.
Thank you
  6 Comments
Image Analyst
Image Analyst on 6 Feb 2021
@Maram Abd, scroll down to see the "Answers". These are just "Comments" up here which are typically used to ask the poster to clarify the question and/or attach missing data or code. Steve's Image Processing Blog in the blog section here has also discussed GIF images

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 21 Apr 2012
This will play a GIF but not with the colormap or in some axes control that you specify the handle of - it brings up the movie player:
fullFileName = 'C:\Users\Zach\Pictures\GIFs\AnimatedGifs\electricity.gif';
[gifImage cmap] = imread(fullFileName, 'Frames', 'all');
size(gifImage)
implay(gifImage);
  4 Comments
Walter Roberson
Walter Roberson on 23 Apr 2019
colormaps read in from GIF represent colors in the range 0 to 1, rather than integers 0 to 255.

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 21 Apr 2012
Edited: Walter Roberson on 6 Feb 2017
GIF Player from File Exchange
  3 Comments
DGM
DGM on 4 May 2022
Edited: DGM on 4 May 2022
FWIW, that error was an error internal to readgif(), which is used internally by imread(). At least as of R2019b, current_frame should be an indexed image during this test (if I recall correctly), and transparent_color should then be a scalar as defined in the file/frame header.
I don't exactly know why readgif() breaks in this one case that nobody needs solved anymore. The file isn't the most common sort of arrangement. There may be GIF functionality imread() doesn't support, and some things it really just can't support in an ideal way due to the conventions for image handling in MATLAB. So don't be surprised if readgif() breaks or returns garbage.
For what it's worth, the file can be re-saved using 'donotspecify' disposal instead of 'leaveinplace', and it reads fine and looks the same.

Sign in to comment.


Rooy
Rooy on 21 Apr 2012
Well it looks like I will just get windows to open the file from Matlab. Thank you very much for all the help.
  2 Comments
Rooy
Rooy on 21 Apr 2012
I will use winopen and then the file would get opened using windows default program.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!