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.
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, ...