Numberplate extraction from vehicle image

3.5k views Asked by At

I am developing an anpr application and I have managed to locate the number plate area from the vehicle image. Following is the numberplate image i h ave extracted

when i feed this image to tesseract OCR engine it seems to detect a character "L" before "C" so im thinking of taking out the remaining black pixels around the number plate area. is there a particular approach that i can take to sort this out? I am using aforge.net library in this case

Cheers

1

There are 1 answers

11
Anders Gustafsson On BEST ANSWER

One approach for semi-automatically removing the black pixel areas around the number plate could be to apply the PointedColorFloodFill filter four times, placing the flood fill starting points in the four corners of your image.

Here is some example code where I have applied the filter on a copy of the number plate image from your question above (cropped to remove the white border):

var filter = new PointedColorFloodFill();
filter.FillColor = Color.White;
filter.Tolerance = Color.FromArgb(60, 60, 60);

filter.StartingPoint = new IntPoint(0, 0);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(image.Size.Width - 1, 0);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(image.Size.Width - 1, image.Size.Height - 1);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(0, image.Size.Height - 1);
filter.ApplyInPlace(image);

which provides the following image after completed filtering from all four corners:

Flood-filled number plate

You may want to experiment with a more grayish fill color and different tolerance, but this example could at least provide a reasonable starting point.

UPDATE I stumbled across the BradleyLocalThresholding filter which could give you an even better starting point for your OCR recognition. This filter can only be applied to 8bpp images, which you would be able to solve for example by first applying the Grayscale filter on your original image. If you add the following four lines before the PointedColorFloodFill code:

var grayFilter = new Grayscale(0.3, 0.3, 0.3);
var image = grayFilter.Apply(originalImage);

var bradleyfilter = new BradleyLocalThresholding();
bradleyfilter.ApplyInPlace(image);

and reduce the PointedColorFloodFill tolerance to e.g. 10 for each RGB component:

filter.Tolerance = Color.FromArgb(10, 10, 10);

the fully filtered number plate will now look like this:

enter image description here