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.
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:
Generated on January 29, 2020, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com