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. |
The algorithm is based on detection of small black local structures (characters):
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. |
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. |
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. |
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. |
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. |
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. |