|Two 2D Views showing the same dataset, but Gray Scale on the left and Pseudo Color on the right (with ETrF color ramp)|
I was once asked the following by a customer:
"Color coding images is a pain. It would be great if we could make a legend and then apply it to the image, instead of having to select and code groups of colors for each image individually, just because the range of values are slightly different. For example, I have a model that outputs an ETrF float image that needs to be color coded as follows:
But the actual range of image values is slightly different for each ETrF image, so I have to open raster attributes, select values, and input the colors, for each image individually."
Which is entirely true. But with the release of ERDAS IMAGINE 2016 there was a solution to this in the form of the Create Color Ramp operator.
But first, let's look at the ways of defining display colors for pixel DN values. For a Thematic (e.g. Landcover Classification) this is straightforward. When the image in opened into the 2D View it will (generally) default to Pseudo Color display mode. In this mode the Raster Attribute Editor panel can be brought up and colors set for each DN value / Class. This process can even be automated using the Spatial Modeler through approaches similar to this Spatial Recipe.
But if the image is a continuous, Athematic image, such as an NDVI, or an ETrF, or even a DEM, the approach is a little more complicated. When such an image is displayed in a 2D View it will default to Grey Scale mode (similar to the display shown in the left-hand 2D View of the screenshot above). In this mode the Raster Attribute Editor cannot be used to affect the "color" of the display, since this display mode is intended for grey scale display, controlled by a Lookup Table (LUT), instead. However, an Athematic image can still be displayed in Pseudo Color mode. When using the FIle Chooser to select the input file a second tab will be available called Raster Options. On this tab the Display mode can be changed from the default Grey Scale to Pseudo Color. Click OK and the data will be displayed. Now the Raster Attribute Editor panel can be displayed and colors can be assigned to DN values.
|Raster Options tab of the File Chooser|
Color ramps can also be quickly assigned in this mode. The Colors button on the Table tab brings up a dialog from which various color ramps can be applied to the selected range of data.
However this is where we encounter the problem mentioned by the customer above. Applying a color ramp (e.g. Violet through Red) to the full range of DNs values is straightforward. But if you have to manually select a range (e.g. -0.25 to 0), apply a ramp (e.g. Red to Beige), select another range (e.g .0 to 0.25), apply a different ramp (e.g. Beige to Tan), etc., it becomes tedious (especially if you have to do it on more than one image).
There's also the problem of the start and end data range of the image being analysed, even if applying a single ramp across the full range. You might want a Violet to Red ramp on your data products and that can be easily applied using a Spatial Model. But it's generally applied across the full range. So if one dataset starts at 40, the color ramp would start with Violet for DN 40 and go up from there. But another dataset might start at DN 80, meaning that Violet would be assigned to DN 80. The problem this causes is lack of consistency and interpretability - you can't look at two color-coded images and know that the color Violet represents a value of 40 in both images.
Which is exactly what's needed for the ETrF problem presented. The color Turquoise has to represent an ETrF value of 0.5.
Which bring us to our new Spatial Model using the Create Color Ramp operator introduced with ERDAS IMAGINE 2016.
The Create Color Ramp operator provides a means to set a direct relationship between a DN range and a color range. So we can, for example, define that a DN range of -0.25 to 0 should be portrayed as a color ramp between Red and Beige. It also enables several such discrete ranges to be cascaded together to define the various color transitions to apply over a much broader range of DN values, such as those defined in the ETrF example above.
The result of the chain of Create Color Ramp operators is a Color Table which can be attached to a raster dataset so that when it is displayed using the Pseudo Color display mode it is colored in the desired manner.
Creating a Spatial Model of this nature thereby enables a standardised "DN to Colors" ramping to be created, which can be applied consistently to multiple datasets quickly and easily.
Input Image: Input image filename to assign a color ramp to.
Apply to Input Image?: If set to Yes / True / 1, the color ramp will be attached to the Input Image (and no output file will be created. Otherwise (No / False / 0) a new Output Image, with the color ramp associated to it, will be created.
Output Image: Name of the new, output image file to create if "Apply to Input Image?" is set to False.