top of page

ERAN ASA

Electronics Engineer   

ANPR - License Plate Recognition

Implementation of license plate recognition for Israeli vehicle (Yellow plate - European standard)

 

Algorithm

There are several main steps to perform:

 

  • Plate Localization

  • LP Binarization - Character segmentation

  • OCR 

 

Plate Localization

There are several ways to locate the LP, in our case we search for yellow plate so all we have to do is a yellow filter.

In the RGB space the 'pure' yellow color is [255 255 0], but in realty there is noise and we get hues of yellow, therefore we have to define a yellow region.

A basic yellow region is something like:

R = 130-255    G = 80-255    B = 0-85

 

In this implementation I used the YCbCr color space , and the Cb channel – the chrominance blue.

It can be said that the Cb channel represents how much the hue of the color is blue or yellow, therefore by thresholding we can get the yellow region in the image (the smallest values represent the yellow).

Original image

Cb Channel

To get better result for localization we increase the contrast of the Cb such that the 'yellow' will be locate around the zero value of the Cb.

and than do thresholding to get binary image with 1 where the LP locate.

Adjust contrast - Cb channel

The Cb after thresholding 

Beside the 'Yellow' filter , a vertical edge detection(sobel method) has been applied on the image and with some morphological operations such as dilation and remove unwanted objects, we get vertical edge connected areas which we expect that the LP region is marked , can see in figures.

Now we do AND between the output of the Yellow filter and the edge connected image (this is good for getting yellow only in the places that has edges), and more morphological operations. see in figure.

For now we got the putative location of the LP, now we need to examine each connected component in the binary image for getting the LP itself (in order to facilitate , we can define ROI in the middle of the image and eliminate all components in the border).

 

The LP region is characterized by a row of transitions from dark to light and vice versa - the Signature of the LP.

but first we rotate the region such that the numbers will align horizontally ant than check the 'signature'. ( in Matlab it easily can be done by using the regionprops function and the 'Orientation' property and do rotation with the negative orientation. 

another useful property is the 'Eccentricity' - Scalar that specifies the eccentricity of the ellipse that has the same second-moments as the region. an ellipse whose eccentricity is 1 is a line segment.(The value is between 0 and 1) (Matlab Help - regionprops) , the LP is close to be a line , in the measurements I got that the eccentricity of the LP is something like 0.94-0.98 , and therefore I reject all region that has eccentricity smallest than 0.9 ).

 

in the figures we see the LP - graylevel , and the intensity of a row of the LP :

LP - graylevel

Row intensity of the LP

After we got the LP - and confirm that its the LP by its 'signature' , we finished by that the first step and can go to the next step - Binarization.

 

Binarization

Global threshold

There is main method for global threshold - Otsu's method , (in Matlab - graythresh() ) but in many cases this will not work,

for example in case there is shadow on the LP , in the global threshold the LP will truncate along the shadow and we cant get the digits separate nicely.

 

Two methods to overcome this problem :

1. Local thresold 

simply divide the image to parts and than apply the Otsu's method on each part and join them back.

 

2. Moving average

convolve average mask with the LP and than return '1' everywhere the LP is smaller than the averaged LP.

 

those 2 methods is very useful and in this implement I used them both.

 

In the figure we can see the LP after the Binarization step.

almost finished....

 

 

OCR

The final step:

After we got a Binary image of the LP,

we label each digit and correlate them with a data-base of templates (of numbers) that I prepared before,

and the template with the high score will selected to be the recognized number.

 

 

RESULT :  5570665    :)

 

 

 

 

Examples :

8696664

Successful

5355651

Successful

5570665

Successful

Please reload

 

 

 

 

 

 

 

 

 

bottom of page