Does morphological dilatation with a 3x3 structuring element equal to one with a 6x6 structuring element?

My question is simple. It may be too easy. But in the process of working on one of my projects, I used the following lines to expand the binary image.

cv::dilate(c_Proj, c_Proj, Mat(), Point(), 2);

Which basically expands the binary image with a 3x3 rectangular structural element. From the last argument, you can see that I am doing 2 iterations of these operations, which is equivalent to:

cv::dilate(c_Proj, c_Proj, Mat(), Point(), 1);
cv::dilate(c_Proj, c_Proj, Mat(), Point(), 1);

My question is: Instead of doing two iterations, if I only do one iteration using a 6x6 structuring element, is this equivalent to the code above in terms of accuracy and performance? Is it faster when the image is repeated only once?

+5
source share
2 answers

Dilation with the same core can be expressed by two convolution operations:

("YourImage" convolve "DilationKernel") convolve "DilationKernel" 

Due to convolution properties, this operation is equivalent to:

"YourImage" convolve ( "DilationKernel" convolve "DilationKernel")

Convolving a 3x3 kernel with itself will result in a 5x5 matrix, so your 6x6 guess is wrong.

In terms of performance, there is so much to consider. In my previous internship, our goal was to use the smallest kernel possible due to the loss of performance of large kernels. The rule of thumb is small cores that act faster on the image, because you can store and retrieve them using CPU registers without gaining access to L1 or L2 caches. Also, if your kernel fits in registers, you can easily use SSE instructions.

- , . , .

+6

, , 6x6 . Wikipedia, . , 3x3, , 6x6, 3x3 6x6.

0

All Articles