One of the most practical application of image processing is license plate recognition. You may have seen those automated highway toll booths. When a car without a transponder passes through, these systems take a picture of the license plate. Using an image processing algorithm, the system gets the license plate of the car and sends a toll bill, all automatically. In this post, we will see a how these systems automatically “read” the license plate using image processing techniques.

Here is an example license plate.

Credit: commons.wikimedia.org

How can we read these characters? As humans, we automate most of our decisions but computers are “dumb”. So, we cannot skip any step when we want them to do a task. So, let’s list all the tasks we need to perform to read these letters:

  1. Get the image
  2. Find where the letters and numbers of the license plate are. These are the characters we want to read. In this example license plate, the computer needs to identify where these letters are, as shown in the following figure. We call this “region of interest” or ROI.
    • region of interest in the license plate
  3. In this ROI, find the first letter, which is “J” and extract that part of the image.
    • first letter of the license plate
  4. Identify the letter and record. Ignore the Texas map character.
  5. Get the next letter and identify.
  6. Repeat until all letters are identified.
  7. Report the result

Now, we have a plan and we can write MATLAB code to implement this algorithm. You can find the details of this algorithm in the following video.

The following is the LiveScript of the code describing the algorithm.

LicensePlateRecognitionFinal

And here is the App that I created to explore how varying certain parameters effect the performance of the algorithm. You can download the MATLAB code for the license plate recognition app here.

License Plate Recognition App
License Plate Picture: plateshack.com

Please let me know what you think? What other approaches could we have implemented? Is there a better approach? How would this algorithm fare if the plate had more colors? How can we modify the algorithm?

9 thoughts on “License Plate Recognition with MATLAB

  1. D says:

    This is fantastic! Thank you very much!

    1. Ethem says:

      Thank you! Please let me know if you have any questions or want to see other topics.

      1. Lahiru Fernando says:

        hi i checked this using matlab but only one the left side first character is being recognized. any idea why it happening? Dear sir please help me soft out this issue

        1. Ethem says:

          Did you try this with the app? Did you try changing the thresholds in the app and observe the effect? Can you provide some more detail?

          1. Ilham says:

            Hi Ethem, i got the same case as Lahiru Fernando.
            Only one character that can be detected is C.
            After I run the code, I found an error in the templates folder.
            No templates folder available.
            Can you help us?

          2. Ethem says:

            Hi Ilham,
            I looks like the release file did not have the required templates folder included. I updated it. The issues are also fixed in Release v1.1.
            Thank you for your interest and please let me know if you have any further questions.

  2. hassan says:

    Hi ,
    i have proplam when i need to slected photo
    the error is below :

    Error using fullfile (line 51)
    String input not supported.

    Error in LicensePlateRecognitionApp/startupFcn (line 190)
    templates = dir(fullfile(templateDir,”*.png”));

    Error in LicensePlateRecognitionApp (line 490)
    runStartupFcn(app, @startupFcn)

    1. Ethem says:

      What version of MATLAB do you have? It is possible that the version you have doe snot support string inputs for fullfile or dir functions.

      You can correct this problem by replacing “*.png”, which is a string, with ‘*.png’, which is a character array.

      1. hassan says:

        my matlap is 17

Leave a Reply

Your email address will not be published. Required fields are marked *