IMAGE Team - The Pantheon project

Tutorial: Automatic License Plate Detection

Identification

Resources

I. Objective

The goal is to localize license plates in images of car rears captured with mobile phone camera. The detected areas are located in bounding boxes ready to be used by an OCR system to decipher the number.

The optimization criterion is to maximize the detection. Therefore there is no accurate elimination of false detection. Results can be refined afterwards using knowledge on the application such as license plate height versus width ratio or the position to discard spurious candidate regions.

The input image.The result image.

II. Method

The algorithm is based on detection of small black local structures (characters):

  1. Localize the local black structures with Black Top Hat. This requires one parameter: the thickness of a character.
  2. Select the most contrasted structures using entropy binarization.
  3. Form the candidate plates from the selected structures using horizontal closing. This requires one parameter: the maximum distance between two characters.
  4. Remove false alarms with respect to plate features. This requires at least three parameters: the minimum width, the minimum and the maximum height of license plates.

II.1 Localization of the Local Black Structures

The localization is based on a black Top-Hat with a square structuring element parametrized by the half-thickness of a character (here 3 pixels). This operation acts by suppression of the small black structures by morphological closing, then difference with the input image to keep only the small structures.

pany2pan input.png input.pan
prgb2gray 50 50 0 input.pan tmp1.pan
pdilatation 1 3 tmp1.pan tmp2.pan
perosionreconstruction 8 tmp2.pan tmp1.pan tmp3.pan
pdif tmp3.pan tmp1.pan tmp4.pan
tmp2.pan: After dilatation with half-size 3.
tmp3.pan: After erosion with half-size 3.
tmp4.pan: After difference.

II.2 Selection of the Most Contrasted Structures

The detection of potential regions begins by a binarization to keep only local structures highly contrasted (the clearest). The binarization uses the entropy thresholding which is well adapted for small structures detection.

pentropybinarization tmp4.pan tmp5.pan
tmp5.pan: After binarization.

II.3 Formation of the Candidate Plates

A horizontal closing is used to merge together close binary regions into one unique region. The closing operation needs the maximum horizontal half-distance value between two characters (here 10 pixels).

plineardilatation 0 0 10 tmp5.pan tmp6.pan
plinearerosion 0 0 10 tmp6.pan tmp7.pan
tmp7.pan: After horizontal closing.

II.4 Removal of False Alarms

The removal of the spurious regions is based on the region size: the minimum half-width (here 20 pixels), the minimum half-height (7 pixels), the maximum half-width (20 pixels) of license plates.

plinearerosion 90 0 20 tmp7.pan tmp8.pan
plineardilatation 90 0 20 tmp8.pan tmp9.pan
pdif tmp9.pan tmp7.pan tmp10.pan
plinearerosion 90 0 5 tmp10.pan tmp21.pan
plinearerosion 0 0 20 tmp21.pan tmp12.pan
pgeodesicdilatation 0 1 -1 tmp12.pan tmp10.pan tmp13.pan
tmp13.pan: After elimination of spurious regions.

II.5 Localization in Bounding Boxes

The bounding box locates the plate since a plate is a horizontal rectangular area.

plabeling 8 tmp13.pan tmp14.pan
pboundingbox tmp14.pan tmp15.pan
tmp15.pan: Localization of the plate in a bounding box.

II.6 Superimposition of the Plate Boundary to the Original Image

This operation is just added for the sake of visualization.

pboundary 8 tmp15.pan tmp16.pan
psuperimposition 1 input.pan tmp16.pan output.pan
ppan2png output.pan output.png
output.pan: The result image.

III. The Complete Pandore Script


The Pantheon project
Image Team GREYC Laboratory
UMR CNRS 6072 - ENSICAEN - University of Caen, France
This page was last modified on 27 September 2018