Erosion / Dilation erroneous output for empty structuring element?

asked 2015-03-10 00:15:30 -0600

updated 2015-03-11 00:15:50 -0600

If one erodes an image by zeros(3,3) structuring element, it should be all 1s, but in case of OpenCV, it returns the image. Similarly, dilation of image by zeros(3,3) structuring element return image itself instead of all 0s.

edit retag flag offensive close merge delete

Comments

Can you post the theory of your approach?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-10 03:05:36 -0600 )edit
4

No, it seems that a morphological operator using an empty structuring element shouldn't change the image. The theory says (e.g. dilatation): "If at least one pixel in the structuring element coincides with a foreground pixel in the image underneath, then the input pixel is set to the foreground value. If all the corresponding pixels in the image are background, however, the input pixel is left at the background value." In the case of an empty structuring element, you don't change anything because you don't have any pixels to compare with.

kbarni gravatar imagekbarni ( 2015-03-10 03:45:55 -0600 )edit
2

This is the most weird statement ever, why the hell would you do a morphological operation without a structuring element, that is just weird :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-10 05:29:53 -0600 )edit

My bad, I just edited the question. I meant zeros(3,3) instead of empty kernel.

I am implementing hit miss transform using erode function, it uses a kernel of 0's if the structuring element for hit miss is all 1's

Aadil Jaleel Choudhry gravatar imageAadil Jaleel Choudhry ( 2015-03-11 00:19:31 -0600 )edit
1

Keep in mind that erosion and dilation work inversely in OpenCV to what wikipedia tells you. Look at this bug report explaining the problem. Could this be the reason why it doesn't work for you?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-11 02:53:18 -0600 )edit
1

Steven, no this isn't the problem.

Aadil Jaleel Choudhry gravatar imageAadil Jaleel Choudhry ( 2015-03-11 03:36:54 -0600 )edit