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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With