问题
When I read a color JPEG image:
jpgim = imread('path/to/image.jpg')
I get an MxNx3 array. However, with GIF files I also need to read the colormap:
[gifim, map] = imread('path/to/image2.gif')
Let's assume that I need only the first frame if the GIF image is animated: gifim = gifim(:,:,:,1)
Is there a way to get a standard MxNx3 image array using gifim
and map
as that is what later parts of my processing pipeline expect?
回答1:
Use ind2rgb:
im = ind2rgb(gifim, map);
来源:https://stackoverflow.com/questions/16775495/combining-gif-images-and-colormaps-to-3-d-image-arrays