Functions > Image Processing > Combinations of Images > Example: Boolean Operations
  
Example: Boolean Operations
Use the and and or functions to combine two binary (pixel intensities of 0 and 255 only) images according to the Boolean AND and OR rules. The and and or functions can be used, for example, to find features in color images, by thresholding the three colors (RGB) separately, and ANDing or ORing the three binary images.
For information on using this example, refer to About Image Processing Examples.
Finding the Minimum of Nonbinary Image Matrices
The and function performs a Boolean AND on two matrices of the same size. If corresponding pixels are both zero, the function returns zero; otherwise it returns the minimum of the two corresponding pixels.
1. Define two matrices.
Click to copy this expression
Click to copy this expression
2. Apply the and function.
Click to copy this expression
Combining Two Binary Images
1. Construct the following binary image.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
(binary_image.bmp)
2. Construct a second image to combine with the first.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
(binary_image2.bmp)
3. Combine the two binary images using and.
Click to copy this expression
Click to copy this expression
(binary_image3.bmp)
Finding the Maximum of Nonbinary Image Matrices
The or function performs a Boolean OR on two matrices of the same size. If corresponding pixels are both zero, the function returns zero; otherwise it returns the maximum of the two corresponding pixels.
1. Apply the or function to the previously defined matrices.
Click to copy this expression
Click to copy this expression
2. Apply the or function to the image matrices defined above.
Click to copy this expression
(binary_image4.bmp)