First of all, my apologies if this is a duplicate question, I did my best at trying to find a previous possible answers.
I’m trying to find a more efficient way to reclass and colorize a single channel grayscale image into several classes (three or more) delimited by preestablished pixel value ranges.
In this particular case, my interest is to dynamically partition a thermal image into three regions considering a specific range of minimum and maximum temperatures, the regions being; (1) areas with temperatures colder than the stablished minimum colored in blue, (2) areas corresponding to the temperature range of interest in black, and (3) areas hotter than the stablished maximum colorized in red.
For the moment I have this working code:
Manipulate[
Show[ColorReplace[
ColorReplace[Binarize[ThermalImage, {ImageMin, RangeMin}], Black],
White -> Blue],
ColorReplace[
ColorReplace[Binarize[ThermalImage, {RangeMin, RangeMax}], Black],
White -> Black],
ColorReplace[
ColorReplace[Binarize[ThermalImage, {RangeMax, ImageMax}], Black],
White -> Red]], {{RangeMin, range1, "Range minimum"}, ImageMin,
ImageMax, 0.1}, {{RangeMax, range2, "Range maximum"}, ImageMin,
ImageMax, 0.1}]
A sample of the output of this code:
I’m almost certain there is a more efficient way to obtain the same results with fewer lines of code.
Also, I’m looking for a method that could be easily adapted to reclassify at n number of bins (not only three).
Thank you so much for your assistance.