Logical Operators

Boolean Alegebra
Logical operators are derived from the boolean algebra, which is the mathematical way of representing the concepts without much bothering about what the concepts generally means. For example, boolean algebra can represent the concept:
"The sky is high and blue."
in the following way: X and Y
here, X represents the concept that "the sky is high" and Y represents the concept that "the sky is blue" and the notation can be fully represented in the mathematical way by the notation ( X and Y ). Here, the notation is only true when both X and Y are true, else the notation is false. Now, to understand this take another example:
"Ali is playing cricket or studying at home."
it will take the following notation in the mathematical domain:
X xor Y
here X and Y represent "Ali is playing cricket" and "Ali is studying at home" respectively. And the notation X xor Y represents that "Ali is playing cricket or studying at home." Here X or Y can not represent the desired concept, because Ali can not be playing cricket and studying at home at the same time.
The truth value of a concept in Boolean value can have just one of two possible values: true or false. And the truth values of a combination of two concepts combined using a certain operator are shown by the help of the truth tables. For example, the truth table for "and" operator is as follows:
The left hand table shows each of the possible combinations of truth values of X and Y, and the the resulting truth value of X xor Y. The truth tables of the each operator can be seen in the respective articles.
Imeplementing Logical Operators on Binary Images
Binary Image represent the pixel data in the form of two intensity levels, that may be 0 and 1. But in the real case the binary image low intensity level is normally 0 and the high intensity level is 255. In this case, the 255 can be taken as logical 1 when applying the logical operators on the binary images. Using this convention we can carry out logical operations on images simply by applying the truth-table combination rules to the pixel values from a pair of input images (or a single input image in the case of NOT). Normally, corresponding pixels from each of two identically sized binary input images are compared to produce the output image, which is another binary image of the same size. As with other image arithmetic operations, it is also possible to logically combine a single input image with a constant logical value, in which case each pixel in the input image is compared to the same constant in order to produce the corresponding output pixel. See the individual logical operator descriptions for examples of these operations.
Implementing Logical Operators on Graylevel Images
Logical operations can also be carried out on images with integer pixel values. In this extension the logical operations are normally carried out in bitwise fashion on binary representations of those integers, comparing corresponding bits with corresponding bits to produce the output pixel value. For instance, suppose that we wish to ORing the integers 167 and 211 together using 8-bit integers. 167 is 10100111 in binary and 255 is 11010011. ORing these together in bitwise fashion, we have 11110111 in binary or 247 in decimal.
This is not the only implementation of the logical operators on the binary images, rather it can be applied simply by taking the 0 pixel value as the logical 0 and the non-zero pixel values as the logical 1 value.
Implementing Binary Logical Operators on a Single Image
The binary logical operators can be applied on the single image. It can be achieved by using the image as one input and the other input can be a structuring element in a single pass through the image. During the pass the operation between the image and the operator is applied on each pixel, by imposing the structuring the origin of the structuring element on that particular pixel.
Binary Operator List
AND & NAND
OR & NOR
Inversion
XOR & XNOR
The details can be found on the relative pages.
Combined Applications of the Binary Operators
Thresholding through ANDing
Thresholding is the operation, when applied to an image the image is transformed into a binary image. This operation can be performed using the AND operator on an image with the other input containing the threshold value for the thresholding operation. For example, you want to threshold the image at a value 128. So, first input to the AND operation is the image and the other input is the threshold value i.e 128 ( = 10000000 ). Then the ouput image only contains two values either 0 or 128 ( threshold value ). From there you can set any value for the binary intensity stages. For example, set the high intensity value to 255. For clarification take the following image:
After ANDing with 128, it yeilds:
If the threshold value contains more than one binary 1 in its binary equivalent, then in the output image contains 0 as the low binary intensity, but contains many high intensities which have to converted into the binary high intensity value. This can be achieved by setting all the non-zero intensities at 255, for example.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Basic Image Processing in Csharp

The C# provides a good support for processing on the image, and the purpose of this article...

Implementation Of Branch And Bound Algorithm

What is Branch and Bound Algorithm? These notes follow the discussion of branch and...

Implementation of Calculating the RTS Invariant Moments Of Area

Why Using Moments of Area? It is seen that the usage of moments of area highly...

Conversion of a Color Image to a Grayscale Image

What is a Color Image? It is possible to construct (almost) all visible colors by...

GrayLevel Image Contras Stretching in C#

Overview Contrast stretching (often called normalization) is a simple image...