# Number Plate Extraction using MATLAB

The number plate extraction in MATLAB can be accomplished using Image Processing 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:-

Contents

## Input Image

1. Capture image from webcam.
2. Store the captured image into an 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 the appropriate threshold value for the image.
4. Convert the image into a 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 the figure.
2. Determine the 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 to 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 a 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 the template.
3. Compare each character with the templates.
4. Store the best-matched character.

## Save to file in the 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).

SHARE Number Plate Extraction using MATLAB

### 57 Responses

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

• 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. Anonymous says:

plz post codes for number plate extraction.

5. Anonymous says:

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. Anonymous says:

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

7. Anonymous says:

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. Anonymous says:

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

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

• Anonymous says:

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. kanmani says:

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

Image Processing India

10. ankur says:

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

11. Anonymous says:

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: [email protected]

12. sukhman says:

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. sesilia says:

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. Pooja Shah says:

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

15. Anonymous says:

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

16. Esha says:

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. Anonymous says:

can you write the codes for those please

18. Anonymous says:

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

19. keerthi says:

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

20. keerthi says:

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

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

24. Belarmino N M Simao says:

Hi dear,

I’m new on Mathlab developer and i wonder to be a good MathLab programmer.

I’ve developed an OCR project on C# language and using a DTKANPR Libs.
I capture de image and store on SQL Server database, but my project has missing most the time on taking the plate.

Can you help me, how to integrate MathLab on C#, i mean manager all MathLab function on C#, and here um your code, there a line an instaance of img with “image.jpg”.

How can i take the image from camera “real time” and passing it to MathLab?

PS: I am sorry about my english

Best wishes

25. ali says:

AOA

How to load multi images stored in a folder

26. riff says:

please mail it to me [email protected]

27. jayanth says:

I am getting error like
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file
identifier.

Error in main (line 55)
fprintf(fid,’Number Plate:-%s\nDate:-%s\n’,’word’,’date’);%Write
‘word’ in text file (upper)
in lines 55 56 in main.
Can u help me out in this?

28. Ganesh says:

Getting error in simulation
Can you please post working code?

29. Lindiwe Hlophe says:

Hey…tanx for sharing. I am an undergraute at the University of Swaziland..I am doing a similar project for my final year…i have implemented license plate extraction and segmentation. I am stuck in recognition…if I can have a look at ur code it would help but I am not able to download the code. Please email it here: [email protected].

30. Amruth reddy says:

Sir,
could you please send all the zip fles,templates and the complete matlab code

31. Amruth reddy says:

Sir,
could you please send all the zip fles,templates and the complete matlab code to my email

Email: [email protected]

32. Verlie Elson says:

Valuable ideas ! I loved the facts , Does anyone know if I would be able to grab a sample CG 20 37 example to use ?

33. Sunil gupta says:

Dear ashokji. Please post extraction code and details for no plate extraction system and help many students to understand MATLAB fully . It will be a great help to our kids..,.Sunil Gupta Indian Railways

34. Con says:

Hello. I tried to use your code on a 7 digit plate and it keeps giving me as a result a wrong number plate ,sometimes completely different than the real one. What kind of changes should I make in order to produce the right result?

35. Ohnmar says:

Well done!
Could you please mail it to me?

36. Nabil Javeed says:

I request you to mail the matlab code of this project to [email protected]

37. pavan s says:

38. gargi says:

hello plz send me all things in mail.i need this .
email -id [email protected]

39. Inzamam says:

Hi. can you sharing with me the code at [email protected]

40. aarthi says:

Sir,
could you please send all the zip fles,templates and the complete matlab code to my email
Email: [email protected]

41. R.Rbls says:

hello do you mind sharing the code, in desperate need of some help. Thank you

[email protected]

42. R.Rbls says:

can you please email me the code for license plate detection, in desperate need of some help,
thank you

[email protected]

43. Manul Gupta says: