I recently started study opencv. I only have a bachelor's degree on engineering. I am having a hard time of understanding these 2 morphological transformation: Black Hat, Top Hat. the official documents is [here](https://docs.opencv.org/master/d9/d61/tutorial_py_morphological_ops.html) 

Can some one give some advice of what is the intuition of these operation and what is it for?
['https://Stackoverflow.com/questions/47278674', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6898439/']
Hopefully you understand *”morphological opening”*. If so, the (white) Top Hat tells you the pixels that would be removed by *”opening”*.

Likewise, the Black Hat tells you the pixels that would be added by *”morphological closing”*.
See the image for explanation. Simple algebra will help here.

> 
> Top hat
> 
> 
> 

top hat = image - opening = image - (image - false +ves) = false +ves

> 
> Black hat
> 
> 
> 

black hat = image - closing = image - (image - false -ves) = false -ves

[Explanation](https://i.stack.imgur.com/3Y15r.jpg)