Logic

The resulting value for each pixel is a logical operation between the input value of the source 1 and the source 2, except the Not operation that requires only one source image.

The truth-table below describes the logical operations only for binary images. Logical operations can also be carried out on images with pixel values between 0 and 255 (grayscale and color images). In this extension, the logical operations are carried out on binary representations of these values. For instance, suppose we wish to "And" the values 83 and 71 together. 83 is 1010011 in binary, and 71 is 1000111. After the logical And operation, we obtain 1000011 in binary or 67 in decimal.

Rules for determining the type of the resulting image when the two source images have different types (see Image Types):

Note: A binary image can be used as a mask when a logical And is performed between a binary and a color or grayscale image.

Or

Logical Or truth-table:

src1 src2 Result
0 0 0
0 1 1
1 0 1
1 1 1

 

And

Logical And truth-table:

src1 src2 Result
1 1 1
1 0 0
0 1 0
0 0 0

 

Not (Invert)

The logical Not or the invert is an operator which takes the source 1 image as input and produces its photographic negative.

Logical Not truth-table (only for binary images):

src1 Result
1 0
0 1

For all image types, the resulting value for each pixel is the input value subtracted from 255. R(i,j) = 255 - SRC1(i,j)

 

Xor

Logical Xor truth-table:

src1 src2 Result
0 0 0
0 1 1
1 0 1
1 1 0

 

 

See also:

Image Factory