Vous êtes sur la page 1sur 10




Automatic Number Plate Extraction Through Edge Detection & Morphology

Group Members:
y y y y

Waleed Pervaiz 6237 Rashid Amir 6252 Fahad Adeel 01078

Syed Abid 01091

Submitted To:
Dr. Javed Ahmed

In an intelligent transport system number plate recognition plays an important role and for that number plate region extraction is the key step to final recognition of the number plate recognition. In our project we have tried to extract the ROI (Region Of Interest) i.e. number plate through detection of vertical edges in an image of a car rear of front and then through morphological operations which helped us getting closer to the exact region of the plate and the through masking we perform the final extraction. We have conducted experiments through our algorithm on about 30 images and have achieved 80% accuracy in detection. The test images varied in lightning conditions, angles and distance and resolutions. Our algorithm is strict to Punjab number plates so far but we are working on making a general algorithm for all the number plates in Pakistan.

Edge Detection
The edge detection is the first step to our algorithm it will help us get rid of the undesired detail of the image. There are Kirsch, Prewitt and Sobel operators for edge detection. Through experimentation we have selected Sobel Operater for our purpose because it has the maximum response to edges. We will be only applying the vertical sobel operator to further erase the detail of horizontal edges in the image because we the values on the number plate will have the maximum vertical edges so it is effective to deal with vertical edges then the horizontal edges in the image. -1 -2 -1 0 0 0 1 2 1

Sobel Vertical Mask

Mathematical morphology is widely is being widely used in image processing an analysis it is built on the basis of set theory. It uses SE (Structuring Element) for measuring the morphology of the image. SE can be of different geometric shapes but we are using LINE SE which is best for our project. Size of the Line is achieved through experimentation and we have used some specific perimeters to apply over image for Punjab number plates character spacing. It uses two processes: y y EROSION - Erosion is used to get rid of irrelevant information in a binary image. DILATION - Dilation is used to fill up the gaps or holes in the image.



There are another two operation which use erosion and dilation these are : OPENING Eroding the image with SE and then Dilating it with same SE to get rid of white holes on dark object or can remove small dark objects on dark background CLOSING Dilating the image with SE and then Eroding it with same SE to get rid of the black holes on white object


We use the closing function over the vertical edge detected image to achieve closing of the gaps in the whole image and when it is finished we can see the number plate characters are all joined and starting to take shape as a box. We further do the closing operation to get rid of and small white patches. After this we are left with a grey scale image including gray and black and white boxes now we need the only pure white box which is our number plate so we convert the image to black and white while applying the threshold of only whitening the region where pixel intensity is 225 to 255 and blackening the region other than that. This gives us a white box in the place of number plate this is our MASK. To further enhance the achieved MASK we dilate the image vertically and horizontally to get a mask which is almost exactly the height and width of our number plate.

After the processes of closing and opening we receive and image which includes ROI. Now we will simply apply the mask to our original image to get the number plate only.

Original Image

Extracted Number Plate After Masking

Flow Chart
Input Image (640X480 resolution)

Convert to Gray Scale

Apply vertical Sobel filter for vertical Edge Detection

Closing Vertically and Horizontally

Opening Vertically and Horizontally

Convert to B/W Image

Dilate Vertically & Horizontally Mask with gray scale image

Number Plate Extracted


Original Image

Opening Horizontal & Vertical

Gray Scale and Blurred Image

B/W Image and Dilated V/H

Edge Detected Image Extracted Number Plate After Masking

Closing Horizontal & Vertical

Through experimentation we have achieved our goal with some very respectable results and created an algorithm for timely recognition of Punjab number plates. We have also come across some parameters which can be controlled to achieve 100% accuracy in ANPR extraction. We can use this algorithm in Toll Plaza, Parking lot ticketing, motorway over speed car recognition, Red signal crossing.

Future work
We are working on creating an algorithm which can be used to detect number plate worldwide, which will allow us to extract number plates for further processing before we get to recognize the number plate.


clc clear all close all

%im_g %im_p %im_f % f % i

= = = = =

Gray Scale image padded image filtered image filter Size of Padding needed

im = imread('lahore.jpg'); imshow(im); title('Orignal Image'); im_g=rgb2gray(im); [m,n]=size(im_g); figure(2); imshow(im_g); x=3; i = ceil(x/2); %for middle intensity of matrix v=x*x;

%% Filter Sobel and Averaging f = 1/v.*ones(x,x); f1= [ -1 -2 -1 0 0 0 1; 2; 1];

%% Zero Padding and Filtering [im_zp1] = zpad(im_g,x,i); figure(3); imshow(im_zp1); [im_f] = filtering(im_zp1,m,n,x,f); figure(4); imshow(im_f); [im_f1] = filtering(im_zp1,m,n,x,f1); figure(5); imshow(im_f1); %Averaging Filtering

%Sobel Filtering

%% Closing Horizontal se=strel('line',20,0); I = imdilate(im_f1,se); se2=strel('line',20,0); I = imerode(I,se2); figure(6);imshow(I); %% Closing Vertical se=strel('line',10,90); I = imdilate(I,se); se2=strel('line',10,90); I = imerode(I,se2); figure(7);imshow(I);

%% Opening Horizontal se2=strel('line',20,0); I = imerode(I,se2); se=strel('line',20,0); I = imdilate(I,se); figure(8);imshow(I); %% Opening Vertical se2=strel('line',10,90); I = imerode(I,se2); se=strel('line',10,90); I = imdilate(I,se); figure(9);imshow(I); %% Black/White for r= 1:m for c = 1:n if (I(r,c) >= 250) I(r,c) = 255; else I(r,c) = 0; end end end figure(10);imshow(I);title('B/W MASK');

%% Acquiring Number plate se=strel('line',15,0); I = imdilate(I,se); figure(11);imshow(I);title('Vertical Dilation of MASK'); se=strel('line',10,90); I = imdilate(I,se); figure(12);imshow(I);title('Horizontal Dilation of MASK'); %% Mask Multiplication I = im2bw(I); im_g = im_g .* uint8(I); figure(13);imshow(im_g);title('EXTRACTED NUMBER PLATE');

FILTER FUNCTION function [im_f] = filtering(im_z,m,n,x,f) sop = 0 ; im_f = zeros(m,n,'uint8'); for r= 1:m for c = 1:n im_e =im_z(r:r+(x-1) , c:c+(x-1)); p = double(im_e) .* f; sop = sum (sum(p)); %assigning value to image matrix on current coordinate im_f(r,c) = sop; end end


function [im_p] = [m,n]=size(im_g);


im_p =zeros(m+(x-1),n+(x-1),'uint8'); im_p(i:m+(i-1),i:n+(i-1)) = im_p(i:m+(i-1),i:n+(i-1)) + im_g;