MATLAB: How to assign values to each color in an image

color_to_valueImage Processing Toolbox

I have an image like the one from a heat detector camera (thermal vision). What I want to do is to assign values to the each of the colors of the image so I would end up with a matrix of values for heat instead of values for RGB colors so that I can use the exact values instead of comparing the colors to the color criterion every time.
The color criterion is basically jet and the corresponding heat values span from 0 to 266. I know that there are many documents regarding how to assign colors to different values but I couldn't find any that does the job the other way around. Please help 🙁

Best Answer

Take the image and use rgb2ind() passing in the "basically jet" color map as the map parameter. The result will be one index into the map for each position in the image. If you are fortunate, index into the map might happen to have some meaning that is useful for calculations.
Beware that like any other kind of image sensing technology, thermal sensors have a difficult time distinguishing between brightness and inherent energy. A sensor that is, for example, 50% efficient for 100 C, and 100% efficient for 120 C, will be unable to distinguish between a double-brightness 100 C sample or a regular-brightness 120 C sample.