meta data for this page
ImageMath
ImageMath combines two images mathematically: an “input” image and an “op” (operation) image. In this example, the links show that the image on the left of ImageMath is the input image and the image on top is the op image. The operation is div, so the output is the input image divided by the op image.
Operations
| Operation | Output at each pixel |
|---|---|
| add, sub, mul, div | input + op, input − op, input × op, input ÷ op |
| max, min | the larger or the smaller of the two values |
| mod | (input − op) ÷ (input + op), a modulation between −1 and 1 |
| atan2 | the arctangent of the ratio of the two images. It enhances low-contrast information, increasing the contrast of dim values and suppressing that of bright values |
Other arguments
- scale_factor: two numbers that multiply the input and op images before the operation. For example, a scale factor of
0.5 0.5with add averages the two images. - values: if only one image is connected, the operation uses these constant values as the second image, one per band. A single value is used for every band. The defaults are 0.0 for add, sub and max, and 1.0 for the others.
- enhance: works with mod. It takes a factor (greater than 1.0) and an offset (between −1.0 and 1.0), and the output becomes arctan(factor × (mod − offset)). This raises the contrast of modulation values near the offset.
Multiband images
The two images must be the same size. The operation is applied to each band separately. If both images have more than one band, they must have the same number of bands. If one image has a single band, it is applied to each band of the other. The output is floating point.