O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Black Hat transform

This transform extract finer details from the image as well. This is the difference between the morphological closing of an image and the image itself. This gives us the objects in the image that are smaller than the structuring element and darker than its surroundings:

Let's look at the function to perform a Black Hat transform:

Mat performBlackHat(Mat inputImage, int morphologyElement, int morphologySize){    Mat outputImage;    int morphologyType;    if(morphologyElement == 0)        morphologyType = MORPH_RECT;    else if(morphologyElement == 1)        morphologyType = MORPH_CROSS;    else if(morphologyElement == 2) morphologyType = MORPH_ELLIPSE; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required