Erosion / Dilation erroneous output for empty structuring element?
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.
Can you post the theory of your approach?
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.
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
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
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?
Steven, no this isn't the problem.