Bitwise Operations

Learn about bitwise operators and their applications.

Instead of just stacking images, we might also want to combine images. We’ll use bitwise operators to combine images in OpenCV. In this lesson, we’ll work with black in white images to better understand these operators.

What are bitwise operators?

There are four basic bitwise operatorsAND, OR, XOR, and NOT. These operators are frequently used to edit images, especially while working with masking images.

First, we’ll create a blank image.

To create a blank image, we use the np.zeros() function of the OpenCV library.

blank = np.zeros((600,600), dtype='uint8')

Note: We must import the NumPy library to use this function.

This function requires two parameters. The first parameter is the size of the blank image and the second parameter, ...