Arithmetic and Logic
Reasons you may use arithmetic and logic are:
- to emphasize differences between images by subtracting the pixels (a conformity check).
- to compensate for non-uniform lighting by dividing the target image by the image of the background alone.
- to remove unwanted areas of an image by preparing an appropriate mask, and clearing all the pixels that belong to the mask by using logical combinations of pixels.
- to create a combined image by combining the pixels of two source images to generate a resulting image.
Arithmetic operations are handled by the Oper function, EArithmeticLogicOperation enum lists all supported operators.
These operations can be applied to images and constants, they have one or two source arguments (image or integer constants) and one destination argument. If the source operands are a color and a gray-level image, each color component combines with the gray-level component to give a color image. Histogram equalization can improve your results.
|
General |
Copy |
Invert |
Shift |
Logical |
Overlay |
Set |
---|---|---|---|---|---|---|---|
Const BW8 -> Image BW8 |
|
x |
|
|
|
|
|
Const C24 -> Image C24 |
|
x |
|
|
|
|
|
Image BW8 -> Image BW8 |
|
x |
x |
|
|
|
|
Image BW8 -> Image C24 |
|
x |
x |
|
|
x |
|
Image C24 -> Image C24 |
|
x |
x |
|
|
|
|
Const BW8, Image BW8 -> Image BW8 |
x |
|
|
|
|
|
|
Image BW8, Const BW8 -> Image BW8 |
x |
|
|
x |
|
|
x |
Image BW8, Image BW8 -> Image BW8 |
x |
|
|
|
x |
|
x |
Image BW8, Image BW8 -> Image C24 |
x |
|
|
|
|
x |
|
Const C24, Image C24 -> Image C24 |
x |
|
|
|
|
|
|
Image C24, Const C24 -> Image C24 |
x |
|
|
x |
|
|
|
Image C24, Image C24 -> Image C24 |
x |
|
|
|
x |
|
|
Image C24, Image BW8 -> Image C24 |
x |
|
|
|
x |
x |
|
Image BW8, Image C24 -> Image C24 |
x |
|
|
|
x |
|
x |
Note: For logical operators, a pixel with value 0 is assumed FALSE, otherwise TRUE. The result of a logical operation is 0 when FALSE and 255 otherwise.
The classification of operations in the above table are:
- Compare (abs. value of the difference)
- Saturated sum
- Saturated difference
- Saturated product
- Saturated quotient
- Modulo
- Overflow-free sum
- Overflow-free difference
- Overflow-free product
- Overflow-free quotient
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Minimum
- Maximum
- Equal
- Not equal
- Greater or equal
- Lesser or equal
- Greater
- Lesser
- Sheer Copy
- Invert (negative)
- Left Shift
- Right Shift
- Logical AND
- Logical OR
- Logical XOR
- Add an overlay
Operators Copy if mask = 0 and Copy if mask <> 0 are very handy to perform masking: the first image argument serves as a mask that allows or disallows changing the pixel values in the destination image.
- Copy if mask = 0
- Copy if mask <> 0