Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a colormap from JPEG file in MATLAB?

I have a jpg image file of the surface of Neptune. My intention is to build a texture mapping (see Matlab help about this topic). I have used the command imread with the file but jpg files have not a colormap (in general, the command imread produces an MxNx3 matrix and a colormap is a Mx3 matrix). I would like to know how I could do it.

Like an image is more valuable than 1000 words (sometimes), my purpose is doing something like that example but for Neptune.

like image 904
julianfperez Avatar asked Jan 18 '23 10:01

julianfperez


1 Answers

The MxNx3 array is a RGB array, i.e. at position (x,y), the third dimension corresponds to a triplet of red, green, and blue values.

To change from an RGB image to a indexed image with a colormap, you use the function RGB2IND

[indexedImage,colorMap] = rgb2ind(rgbImage, nColors); %# set nColors to e.g. 128 
like image 157
Jonas Avatar answered Jan 29 '23 21:01

Jonas