# Matlab code for car number extraction

Status
Not open for further replies.

#### ahmed jasim

##### Newbie level 5
hello every one

please im student master computer science in university Malaya

my topic about (car number plate extraction ) using matlab

this title my topic
An Efficient Approach for Number Plate Extraction
from Vehicles Image under Image Processing

Last edited by a moderator:

#### sreevenkjan

##### Full Member level 5
Are u really serious??. You created an account to write an post and get a code??!! Google the code, there are plenty of them.

ahmed jasim

### ahmed jasim

Points: 2

#### ahmed jasim

##### Newbie level 5
Are u really serious??. You created an account to write an post and get a code??!! Google the code, there are plenty of them.

thank you bro

if can gate any code please send me

ahmed jasim

### ahmed jasim

Points: 2

#### ahmed jasim

##### Newbie level 5
thank you so much

i will understand this code .

#### ahmed jasim

##### Newbie level 5
hello bro
i try to solve the apper car number plate but i have picture cannot apper the number please can help me to solve
i send now code and picture
Code:
f=imread('pic5.jpg');
f=imresize(f,[400 NaN]); % Resizing the image keeping aspect ratio same.
g=rgb2gray(f); % Converting the RGB (color) image to gray (intensity).
g=medfilt2(g,[3 3]); % Median filtering to remove noise.
se=strel('disk',1); % Structural element (disk of radius 1) for morphological processing.
gi=imdilate(g,se); % Dilating the gray image with the structural element.
ge=imerode(g,se); % Eroding the gray image with structural element.
gdiff=imsubtract(gi,ge); % Morphological Gradient for edges enhancement.
gdiff=mat2gray(gdiff); % Converting the class to double.
gdiff=conv2(gdiff,[1 1;1 1]); % Convolution of the double image for brightening the edges.
gdiff=imadjust(gdiff,[0.5 0.7],[0 1],0.1); % Intensity scaling between the range 0 to 1.
B=logical(gdiff); % Conversion of the class from double to binary.
% Eliminating the possible horizontal lines from the output image of regiongrow
% that could be edges of license plate.
er=imerode(B,strel('line',50,0));
out1=imsubtract(B,er);
% Filling all the regions of the image.
F=imfill(out1,'holes');
% Thinning the image to ensure character isolation.
H=bwmorph(F,'thin',1);
H=imerode(H,strel('line',3,90));
% Selecting all the regions that are of pixel area more than 100.
final=bwareaopen(H,100);
% final=bwlabel(final); % Uncomment to make compitable with the previous versions of MATLAB®
% Two properties 'BoundingBox' and binary 'Image' corresponding to these
% Bounding boxes are acquired.
Iprops=regionprops(final,'BoundingBox','Image');
% Selecting all the bounding boxes in matrix of order numberofboxesX4;
NR=cat(1,Iprops.BoundingBox);
% Calling of controlling function.
r=controlling(NR); % Function 'controlling' outputs the array of indices of boxes required for extraction of characters.
if ~isempty(r) % If succesfully indices of desired boxes are achieved.
I={Iprops.Image}; % Cell array of 'Image' (one of the properties of regionprops)
noPlate=[]; % Initializing the variable of number plate string.
for v=1:length(r)
N=I{1,r(v)}; % Extracting the binary image corresponding to the indices in 'r'.
while letter=='O' || letter=='0' % Since it wouldn't be easy to distinguish
if v<=3                      % between '0' and 'O' during the extraction of character
letter='O';              % in binary image. Using the characteristic of plates in Karachi
else                         % that starting three characters are alphabets, this code will
letter='0';              % easily decide whether it is '0' or 'O'. The condition for 'if'
end                          % just need to be changed if the code is to be implemented with some other
break;                       % cities plates. The condition should be changed accordingly.
end
noPlate=[noPlate letter]; % Appending every subsequent character in noPlate variable.
end
fid = fopen('noPlate.txt', 'wt'); % This portion of code writes the number plate
fprintf(fid,'%s\n',noPlate);      % to the text file, if executed a notepad file with the
fclose(fid);                      % name noPlate.txt will be open with the number plate written.
winopen('noPlate.txt')

%     Uncomment the portion of code below if Database is  to be organized. Since my
%     project requires database so I have written this code. DB is the .mat
%     file containing the array of structure of all entries of database.
%     for x=1:length(DB)
%         recordplate=getfield(DB,{1,x},'PlateNumber');
%         if strcmp(noPlate,recordplate)
%             disp(DB(x));
%             disp('*-*-*-*-*-*-*');
%         end
%     end

else % If fail to extract the indexes in 'r' this line of error will be displayed.
fprintf('Unable to extract the characters from the number plate.\n');
fprintf('The characters on the number plate might not be clear or touching with each other or boundries.\n');
end
end

this picture

Last edited by a moderator:

#### sreevenkjan

##### Full Member level 5
Does the input image have the nameplate always with yellow background??

#### ahmed jasim

##### Newbie level 5
no i have different pic but i try this pic cannot running

if you help me any pic with noise can using to remove noise and running

thnx for help me

#### andre_luis

##### Super Moderator
Staff member
You are using a plate that has a very poor quality on its painting, and should not be used at the initial tests. Did you got successful using another picture ?

Another point: Are you sure that the code above is able to perform detection on different scales and angles from the original pattern for what it was proposed ?

#### ahmed jasim

##### Newbie level 5
this my problem because i don't have any code to check
but i check 4 pic running is good but another pic running appear last number is different
i search any code cannot find . if you find code can send please

i so much thank for help me

#### andre_luis

##### Super Moderator
Staff member
Programming for image processing is strongly dependent of the application.
There is not a standard code that you can download and expect it works fine for your pictures.

The code don´t work and you don´t know why. I suggest you debug the code above, firstly plotting each intermediate picture generated by each function using original image in order to understand what are the pattern required for each phase. After that, you will be able to adjust parameters accordingly.

#### sreevenkjan

##### Full Member level 5
You have just copied and pasted the code without the changing it!!. your not even telling what error your getting after simulating the code. You are not expecting us to write you a code, aren't you??

#### andre_luis

##### Super Moderator
Staff member
The code posted above is part of the project below, which embeed few images for which worked perfectly in the tests I made, but as expected, the implementation of any recognition algorithm provides a degree of recognition and non-recognition. Patterns must to have a minimum level of intelligibility:

https://www.mathworks.com/matlabcen...mber_Plate_Extraction/numberPlateExtraction.m

I think we can assume that the OP's original problem is solved.

#### ahmed jasim

##### Newbie level 5
thank for reply i got this same code i already working same code and picture but no running

#### andre_luis

##### Super Moderator
Staff member
The fact of the code is recognizing other plates and doing not for the ( degraded ) plate above don´t means that the code is not working, but is running perfectly as expected. As can be seen in the author's comments, it is required for the recognition that the characters meet a minimum distance between each one and the bounds, which does not occur with this specific plate.

#### sreevenkjan

##### Full Member level 5
The code posted does not have the database for classification algorithm. I had provided the link to the OP and he has just copied and pasted it expecting us to do his work.
He needs to understand, use a different number plate or change the parameters in the code which suites the number plate image. I am sorry but I gave him a link and he has just copied and pasted it saying he has a problem!!..All the best for his project.

#### ahmed jasim

##### Newbie level 5
need database car plate number in malaysia

hello every one

please can you help me i want database car plate recognition numbers of Malaysia
i search database don't find
thank you so much to help me

regards

Status
Not open for further replies.