Issue with colormap when displaying an image extract from an animated gif file

4 ビュー (過去 30 日間)
I extract an image from an animated gif file with the following code :
GIF_file = dir([PathName, '*velocity*.gif']);
[im, map] = imread([GIF_file.folder, '\', GIF_file.name], 'frames', num);
Then i want to display it :
figure;
imshow(im)
colormap(map)
All is good when "num" (i.e. the frame number in the gif file) is set to 1 :
1.png
Now, when "num" is set to a number > 1, here is the result (num = 7) :
1.png
I don't understand what happens...
Please, is anybody is able to help me to have same color when num > 1 than when num = 1 ?
Thanks

採用された回答

Mikaël LE GRAND
Mikaël LE GRAND 2019 年 10 月 15 日
Ok, iget it myself :
It seems that when we do (num <> 1)
GIF_file = dir([PathName, '*velocity*.gif']);
[im, map] = imread([GIF_file.folder, '\', GIF_file.name], 'frames', num);
'map' is always the colormap of the first image of the animated GIF. So, it's better to do :
infos = imfinfo([GIF_file.folder, '\', GIF_file.name], 'gif');
[im, map] = imread([GIF_file.folder, '\', GIF_file.name], 'frames', num);
imshow(im)
colormap(infos(num).ColorTable)
In this way, i get the good result for each frame of the animated GIF.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by