DescriptionThe RasterExpressionEvaluator is a transformer that evaluates expressions on each cell in a raster, such as algebraic operations or conditional statements.
Simple Calculation Examples
Inverting ColorsThis example demonstrates how to invert images with the following band interpretation list and expression:
The images show Heritage Mountain Elementary School and the surrounding area in Google Earth
Brightness CorrectionIf an image is too dark, we can boost brightness with the following simple expression:
Port Moody, Greater Vancouver
Note that this method should be used cautiously - if there are bright areas in the image, they will reach or exceed the maximum value (255 in my example), which will make them purely white (255, 255, 255 in case of RGB24), and the information in those areas will be lost.
If one of the colors on an image seems to dominate over the others, we can change only one band (or apply different coefficients to different bands):
Color to Grayscale Conversion
Most internet sources suggest the following formula for color to grayscale conversion (and many sources also mention that depending on the image it may vary):
0.2989*A + 0.5870*A + 0.1140*A
The workspace also makes an image based on calculating average values,
0.3333*A + 0.3333*A + 0.3333*A
but the first formula gives better contrast.
Conversion between all kinds of units is a very natural operation for RasterExpressionEvaluator. In this example we take a numeric raster representing a DEM in meters and convert the units into feet (band interpretation is INT32):
If we inspect results in Visualizer, we will see the results of the conversion: