Search code examples
c#image-processingaforgemathematical-morphology

Image gets shifted down when an opening operation is made on the Image


I am doing an Automatic Number Plate recognition application. What I am doing is locating rectangular objects on a given vehicle image in order to extract the number plate location. I am doing an opening operation on the image and the image seems to get shifted down. So when I locate the number plate on the original image I could locate only half of the number plate because the final image shifts down due to morphological processing.

Also I noticed that this happens when I use a structuring element of size 4x13

Let me attach the image here. You would see the difference at the top of the image and the image has shifted down a bit. Does anyone know a work around for this issue? I am really stuck with this thing

enter image description here


Solution

  • You are not stuck with this problem, you just need to implement these morphological operations correctly or use some correct implementation. Compare your results to what I obtain, using the same structuring element, without any kind of effort (i.e., I simply apply an opening and a closing, nothing else, respectively):

    enter image description here   enter image description here

    You get severe artifacts, which shouldn't appear when the duality of erosion and dilation are correctly taken into account.