The Logical Operations category contains logical operations between two images or between an image and a constant as union, intersection, complementary. More...
Classes | |
class | SoBitShiftProcessing |
SoBitShiftProcessing engine More... | |
class | SoInvertImageProcessing |
SoInvertImageProcessing engine calculates the reverse of an image. More... | |
class | SoLogicalImageProcessing |
SoLogicalImageProcessing engine performs logical operations between two image. More... | |
class | SoLogicalNotProcessing |
SoLogicalNotProcessing engine More... | |
class | SoLogicalValueProcessing |
SoLogicalValueProcessing engine More... |
The Logical Operations category contains logical operations between two images or between an image and a constant as union, intersection, complementary.
Logical operations are usually performed on binary images, but may also be applied to grayscale images. In a binary image, a pixel/voxel with value 1 has the value true and a pixel/voxel with value 0 a value false. Each logical operation is linked to a boolean operation. In a binary image I, all pixels/voxels with value 1 belong to the set A, and all 0-value pixels to the complement set of A or the background.
When a logical operation is applied to a grayscale image, the logical operations for binary images are applied to each bit plane. Let us consider the two images and , and perform a logical AND operation.
Suppose that for pixel (n,m), intensities and are respectively equal to and . What will be the value of the result ? If we consider the binary coding of the two numbers and apply the operator to each of the eight bits as shown on the Figure 1.
Figure 1
The result of this logical AND may appear rather strange and for this reason logical operations applied to grayscale images have to be handled with care.
The two main applications of logical operations on grayscale images are for masking and for combining bit planes.
To mask an image, a logical AND is performed between images I and M where every pixel with value 1 is coded with 1 (short value) and every pixel with value 0 is coded with 0 (short value). In masking a grayscale image I with a binary image M:
To combine bit planes, if two images and have grayscale values in the range 0 to 15 (4-bit images), one has to shift the image by 4 bits on the left. A logical OR between image and image shifted by 4 bits ( ) gives an 8-bit image made of the two images.
Let us consider the two color images and . Suppose we want to perform where is a boolean operator.
When a logical operation is applied to color image, it operates on each color channel. A color image pixel/voxel is a quadruplet of values coded on one unsigned byte each:
then we will have the following relations:
For example, let us suppose that (opaque magenta) and (opaque light blue) performing an AND operation, then we should get :
When performing a logical operation between an image and a fixed value: , the following formulas apply:
For example, let us suppose that (opaque magenta) and performing a XOR operation then we should get: