Other morphological operators
Here are some other morphological operators that are interesting. Let's first take a look at the output image. We can take a look at the code at the end of this section.
Morphological opening
This is an operation that opens a shape. This operator is frequently used for noise removal in an image. We can achieve morphological opening by applying erosion followed by dilation to an image. The morphological opening process basically removes small objects from the foreground in the image by placing them in the background:
Here is the function to the perform morphological opening:
Mat performOpening(Mat inputImage, int morphologyElement, int morphologySize) { Mat outputImage, tempImage; int morphologyType; if(morphologyElement == 0) morphologyType = MORPH_RECT; else if(morphologyElement == 1) morphologyType = MORPH_CROSS; else if(morphologyElement == 2) morphologyType = MORPH_ELLIPSE; // Create the structuring...