It is often useful to perform arithmetic operations on images. These operations apply the specified operator on individual pixel values in a source image or on pixels at corresponding locations in two source images. These operations, whose results do not depend on neighboring values, are known as point-to-point operations.
Besides arithmetic operations, the MIL Image Processing module includes several other point to point operations: logical, comparative, shifting, trigonometric, or absolute value operations.
You can apply most of the above point-to-point operations, using MimArith():
You can add, subtract, multiply, divide, AND, NAND, OR, XOR, NOR, or XNOR two images or an image and a constant.
You can negate, take the absolute value, NOT, or simply copy the image into the result buffer.
You can perform the trigonometric atan2(x, y) function using the first image for the X-coordinates and the second image for the Y-coordinates.
You can copy a constant to the entire result buffer.
For example, for a surveillance application, it is more efficient to extract the constant background from the grabbed image and display only changes in the image. The following example shows how this can be done.
MimArith(GrabImage, BackgroundImage, MilImage, M_SUB_ABS);
You can perform complex operations (such as scaling and logarithms) on an image buffer, using MimLutMap(). This function performs the operation simply by mapping the source image buffer through a specified lookup table (LUT) and storing results in the specified destination image buffer.
You allocate a LUT buffer, using MbufAlloc1d(), specifying the buffer attribute as M_LUT. You can assign mapping values to it by copying data from a Host generated buffer (for example, an array) into it, using MbufPut1d(). You can also generate data directly into a LUT buffer according to a specified function, using MgenLutFunction(). If you simply want to invert the image or set the image to a constant, you can alternatively use MgenLutRamp().