Is it possible to create 24-bit gif in Matlab?

4 views (last 30 days)
I would like to create 24-bit animated gif from figure. Is it even possible in Matlab?
Below part of my code:
current_frame = getframe(fig3D);
[frame_indices, cmap] = rgb2ind(current_frame.cdata,256,'nodither');
movie_frames = repmat(frame_indices,[1 1 1 movFrames]);
for ii = 1:movFrames
[...]
ff = getframe(fig3D);
[movie_frames(:,:,1,ii),cmap] = rgb2ind(ff.cdata,cmap,'nodither');
end
imwrite(movie_frames,cmap,[movFilePath,'\',movFileName],'DelayTime',0,'LoopCount',inf);

Accepted Answer

Jan
Jan on 10 Nov 2015
24 bit GIFs are implemented as a multi-frame GIF without a time delay between the parts. For each frame of a picture a 8 bit color map can be created, if it is small enough. So the program must split the image into appropriate parts and save them as frames of an animated GIF and set the delay to zero. See https://en.wikipedia.org/wiki/GIF#True_color
Many browsers and e.g. Photoshop can read an display such 24-bit GIFs, but the definition is at least awkward. I do not know a method to create such GIFs in Matlab, and I would hesitate to create one, because PNGs are smarter.

More Answers (1)

Image Analyst
Image Analyst on 3 Nov 2015
  6 Comments
Image Analyst
Image Analyst on 10 Nov 2015
I didn't know either but after reading Guillaume's answer I thought I'd check PNG since it's pretty much become/becoming the new defacto standard, and sure enough, there's an animated PNG: https://en.wikipedia.org/wiki/APNG
The Animated Portable Network Graphics (APNG) file format is an extension to the Portable Network Graphics (PNG) specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs. It also retains backward compatibility with non-animated PNG files.
The first frame of an APNG file is stored as a normal PNG stream, so most standard PNG decoders are able to display the first frame of an APNG file. The frame speed data and extra animation frames are stored in extra chunks (as provided for by the original PNG specification).
APNG competes with Multiple-image Network Graphics (MNG), a comprehensive format for bitmapped animations created by the same team as PNG. APNG's advantage is the smaller library size and compatibility with older PNG implementations.
Michal Dudek
Michal Dudek on 10 Nov 2015
Yes, APNG would be the best choice, but as far as I know it is not implemented in Matlab.

Sign in to comment.

Categories

Find more on Animation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!