The algorithm for extracting number plate can be summarized as:-
- Capture image from webcam.
- Store the captured image into an image file for further processing.
Convert Image into Binary
- Identify the intensity of the image.
If image intensity = high Reduce intensity Else if intensity = low Increase intensity Else No change.
- Convert image into grayscale.
- Calculate the appropriate threshold value for the image.
- Convert the image into a binary image using the calculated threshold.
Detecting Number plate area
- Fill small holes including numbers of Number plate so that number plate area will be large to isolate from the figure.
- Determine the width and height of the image.
- 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.
- Use the step no. 3 for both horizontal and vertical direction.
- Check number of possible areas.
- Logically AND with binary image obtained at “Convert image into a binary algorithm.
- Crop the required area.
- Filter the noise level present in the image.
- Clip the plate area in such a way that only numbers of plate area extracted.
- Separate each character from the plate.
- Create the template file from the stored template images.
- Resize image obtained from segmentation to the size of the template.
- Compare each character with the templates.
- Store the best-matched character.
Save to file in the given format
- Open a text file in write mode (append mode in case of the multiple records).
- Store the character obtained from the number identification process to text file in given format.
- 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.
Download the whole project here.
The project involving the number plate extraction:- ANPR(Automatic Number Plate Recognition) Using ALR(Automatic Line Tracking Robot).