Top hat operation

A top hat operation is defined as the difference between the input image and the opening of the image. You can see the details of this operation in the following code:

top_hat = cv2.morphologyEx(image, cv2.MORPH_TOPHAT, kernel)