My blog has moved!

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

## 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:-

Pic 1:- Number plate that is to be extracted.
Open the main.m file in MATLAB.

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.

You will get a messagebox showing the extracted number plate. Message box like this:-

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.

In main.m there are certain lines which when commented can be used to see the step by step characters extraction.

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.
The project involving the number plate extraction :-  ANPR(Automatic Number Plate Recognition) Using ALR(Automatic Line Tracking Robot).

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

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

3. will it work for indian number plate

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.

4. plz post codes for number plate extraction.

http://dl.dropbox.com/u/24930699/Projects/My%20Projects/Others/Number%20Plate%20Extraction%20using%20MATLAB.zip

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.

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

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.

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

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.

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

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

Image Processing India

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

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

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

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.

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

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

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..

17. can you write the codes for those please