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.
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.
2. Apply the and function.
Combining Two Binary Images
1. Construct the following binary image.
2. Use the WRITEBMP function to write the binary image to a file.
(binary_image.bmp)
3. Construct a second image to combine with the first.
4. Use the binarize function to binarize the image, and use the WRITEBMP function to write the new image to a file.
(binary_image2.bmp)
5. Combine the two binary images using and.
(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.
2. Apply the or function to the image matrices defined above, and use the WRITEBMP function to write the new image to a file.