My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://ashokbasnet.com.np
and update your bookmarks.

Sunday, February 26, 2012

Number Plate Extraction using MATLAB

The number plate extraction in MATLAB can be accomplished using Image Proccessing Tools available in MATLAB. The functions provided by the Image Processing ToolBox makes it easy to process any images to extract the data from it.
The algorithm for extracting number plate can be summarized as:-
Input Image
  1. 1.Capture image from webcam.
  2. 2.Store the captured image into a image file for further processing.
Convert Image into Binary
    1.Identify the intensity of the image.
    If image intensity = high Reduce intensity Else if intensity = low Increase intensity Else No change.
    2.Convert image into grayscale.
    3.Calculate appropriate threshold value for the image.
    4.Convert the image into binary image using the calculated threshold.
Detecting Number plate area
    1.Fill small holes including numbers of Number plate so that number plate area will be large to isolate from figure. 2.Determine width and height of the image. 3.Scan each pixel of line counting number of white pixels in the following system,
    If number of ‘white’ pixels < x; pixels become ‘black’ Else; no change If number of ‘white’ pixels > y; pixels become ‘black’ Else; no change The value of x and y may be changed according the image intensity and plate area.
    4. Use the step no. 3 for both horizontal and vertical direction.
    5.Check number of possible areas.
    6. Logically AND with binary image obtained at “Convert image into binary algorithm.
    7.Crop the required area.
Segmentation
    1.Filter the noise level present in the image.
    2.Clip the plate area in such a way that only numbers of plate area extracted.
    3.Separate each character from the plate.
Number Identification
    1.Create the template file from the stored template images.
    2.Resize image obtained from segmentation to the size of template.
    3.Compare each character with the templates.
    4.Store the best matched character.
Save to file in given format
    1.Open a text file in write mode (append mode in case of the multiple records).
    2.Store the character obtained from the number identification process to text file in given format.
    3.Close the file
Some of the snapshots for the number plate extractions:-
BA48PA5445
Pic 1:- Number plate that is to be extracted.
Open the main.m file in MATLAB.
main program for number plate extration
Now run the main.m file in the MATLAB. It may prompt you to change the default directory. You can either change folder or Add to Path. Better change the directory.
prompt directory change
You will get a messagebox showing the extracted number plate. Message box like this:-
extracted number plate
The log file ( log.txt ) is maintained to keep track of the saved number plates ( which can be used in application level ). The log file content contains the number plate with the date saved.
log file content to store the number plates
In main.m there are certain lines which when commented can be used to see the step by step characters extraction.
uncommenting line to see the characters one bye one
Feel free to ask any queries if any problem occurred. I am using MATLAB 7.12.0 (R20011a) but it should work in all version.
Download the whole project here.
The project involving the number plate extraction :-  ANPR(Automatic Number Plate Recognition) Using ALR(Automatic Line Tracking Robot).  

28 comments :

  1. Great post on number plate extraction and OCR in MATLAB.

    ReplyDelete
  2. will it work for any no plate i am indian weather it will work for indian no plate

    ReplyDelete
  3. Replies
    1. Ya it works for the Number plate of any kind ( Number 0-9 and alphabets A-Z). You can make it work for any language you want but you should have the template file for them.

      Delete
  4. plz post codes for number plate extraction.
    Tnx in advance.

    ReplyDelete
    Replies
    1. I have given the link at the bottom of the post. Anyways you can download from the link below.
      http://dl.dropbox.com/u/24930699/Projects/My%20Projects/Others/Number%20Plate%20Extraction%20using%20MATLAB.zip

      Delete
  5. You have posted codes for character segmentation but not for plate extraction which uses smearing algorithm. So i request u to post codes for extracting license plate.(hsmearing and vsmearing functions). By the way thax for reply and hope u soon post codes for plate extraction.

    ReplyDelete
  6. Plz reply and post codes for run-length smearing algorithm.(hsmearing and vsmearing) as soon as possible.

    ReplyDelete
  7. I m final year student project similer to ur's. i need help for license plate recognition. so request you to post source codes for that.
    Thk U.

    ReplyDelete
  8. hi..will it works for black background with white characters?
    thnx..^^

    ReplyDelete
    Replies
    1. This algorithm works for the number plate with white background and black text. You need to invert the color of image captured to process.

      Delete
    2. is it because the template which is used in black and white background?
      what if the picture entered is the whole car, not just the plate
      thx

      Delete
  9. interesting blog. It would be great if you can provide more details about it. Thanks you

    Image Processing India

    ReplyDelete
  10. how to locate the number plate area and crope it from the whole vehicle photo....any idea...?

    ReplyDelete
  11. Hi. can you sharing with me the code from the beginning process till end.I need to learn this for my Final year project.
    my emel: sasuke.cold@yahoo.com

    ReplyDelete
  12. i am a student of mtech final year,i work on recognition of blurred license plates ,can u help me by providing the code for recognition of blurred license plates

    ReplyDelete
  13. This is useful blog, contains rich content about Create a Number Plate.All kinds of show plates and numberplates is excelled, we make sure the work according to your demand and choice and timely delivery is ensured.

    ReplyDelete
  14. i am getting some error can u send me proper code?

    ReplyDelete
  15. is this the whole code/ you have implemented all the steps which you mentioned above from input image to number identification?

    ReplyDelete
  16. hi.. i really lyk dis proj..
    but d problem is dat.. this proj. is not extracting particular no. plate from whole vehicle image ..(car image)
    here ,only number plate is needed..
    can u help to solve dis prob..???
    so , it also extracts from whole vehicle img..
    thanks..

    ReplyDelete
  17. can you write the codes for those please

    ReplyDelete
    Replies
    1. iwant the code please help me

      Delete
  18. what to do if after median filtering,some of the characters gets partitioned.it detects all this partition as seperate character.how to overcome this.please reply

    ReplyDelete
  19. helo...im doing project on anpr using ocr(optical character recognition)...i want code to extract the number plate without noise...pls favour me...

    ReplyDelete
  20. helo..im doing proj on automatic number plate recognition system using OCR algorithm...i want source code to extract the exact number plate region irrespective of its position..pls favour me..

    ReplyDelete
  21. Dude which algorithm did u use to segment the number plates and using which algorithm do u isolate the number plate from the image????

    ReplyDelete
  22. Hi there i cannot download your project could you please mail it to me on mvaishak.1291@gmail.com

    ReplyDelete
  23. Excellent work.I am trying to download your project but can't could you please mail it to me on robotics.rajkot@gmail.com

    ReplyDelete