Topography calibrated from color scale

Newbie question, so I apologize in advance if this is already well known. I have a topographic surface as an RGB image in which elevation has been defined by a “rainbow” color scale that I wish to convert to XYZ values. The method in ImageJ is obvious enough when the color image converts using a standard method to a grayscale with linear monotonic increase with elevation. In my current case, however, the color scale defining topography changes from dark red to lighter yellow to darker green to lighter blue to dark blue, which makes the standard grayscale image rather unusable. In photoshop I have masked the different colors and changed each color to a specified greyscale range before recombining the layers (and I am sure this would be easy to do in ImageJ also), but, my question, is there a way to automate this for a general case with ImageJ? That is, to use (calibrate) the color scale bar to define a grayscale image without first hand editing the color ranges.

Still do not know the answer, but Color Inspector 3D did provide me with some insights into my question. I now see there are really three problems: 1) filtering the noise, 2) deciding cutoff criteria between reference to the RGB layers, and 3) defining new grayscale values defined by distance around RGB space. Am I making this more complicated than it needs to be? Are there already methods available to do this?

It appears that the “rainbow” lookup table in your original image looks pretty linear in it’s hue channel. Thus you can simply recover a linear grayscale image reflecting elevation by converting your image to HSB and extracting the hue channel.

run(“HSB Stack”);
run(“Duplicate…”, “title=elevation”);


Thanks Jerome! I spent my afternoon reading about segmentation in general (I have a lot to learn!). Yours is a nice example of looking for obvious separating factors first before thinking about something more complicated. What you show is all that I need for the question at hand. cheers!