LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 November 10 2010

mesa177
Member

License Plate Extraction, Processing, and Character Segmentation

As I've said here, I'm with developing a LebGeek special anti-speeding detector. As a first step, I'm going to post the algorithm which I adopted to perform license plate extraction, processing and character segmentation. Here, the original image can be captured as a grayscale image or as an RGB image and then converted to a grayscale image. However, all the processing must be performed on the grayscale form. The image is either a frontal view of the car with the license plate visible or a back view of the car with the license plate visible.

In order to understand the code, it is imperative to explain the main concepts behind the algorithm development. Further data can be extracted from the original IEEE transactions. The sources are:

Main Algorithm Source
Title
“A License Plate-Recognition Algorithm for Intelligent Transportation System Applications”
Authors
“Christos Nikolaos E. Anagnostopolous”
“Ioannis E. Anagnostopolous”
“Vassili Loumos”
“Eleftherious Kayafas”
Publication Source
IEEE Transactions on Intelligent Transportation Systems, Vol.7, № 3, September 2006
Digital Object Identifier
10.1109/TITS.2006.880641

Slant Correction Algorithm
Title
“Slant Correction of Vehicle License Plate Based on Feature Point and Principal Component Analysis”
Authors
“Wu Guo-ping”
“Cheng Shi”
“Ao Min-si”
“Lei Hui”
Publication Source
IEEE International Conference on Computer Science and Software Engineering of 2008
Digital Object Identifier
10.1109/CSSE.2008.1648

Explaining main algorithm:

The process as implied in the title involves three major partitions: license plate extraction, license plate processing, and character segmentation of license plate.

License Plate Extraction


2vj4u4g.png


As the above image indicates, there are 7 steps in the process of license plate recognition or LPR: sliding concentric window or SCW segmentation (to indicate region where the license plate or LP lies within), image masking (to isolate region of image where LP is located, but other regions can also be isolated falsely), Sauvola binarization or SB (to apply thresholding over isolated region such that the ambient or surrounding illumination source like the sun or flash of the camera is accounted for; precedes next step and is used to remove undesirable regions which have been falsely isolated), connected component analysis or CCA (to identify which of the isolated regions is actually the LP region), image inversion if required (sometimes the later steps yield no result even though there might in fact be LPs in the image captured, this is where the original grayscale image is inverted and the latter 4 steps are repeated => 85% of the time the LPs are detected correctly), object number tracking (in some images there might be multiple LPs so they are each tracked by an object number <= this step has no purpose in the anti-speeding detector in most cases), and finally storing the coordinates of the LP boundaries (to extract the LP from the original image; note that the isolated regions are in binary form; what we require is actually the grayscale form of the LP <= to be used in later section license plate processing).

Sliding Concentric Windows or SCW


17vgq1.png


SCW is an adaptive segmentation technique that identifies the LP region by means of statistical data. Review the above image for more info (please post questions if a certain point is not clear).

Image Masking and Sauvola Binarization or SB


2s9asmp.png


After performing the SCW segmentation, all the candidate regions (where LP lies within one of them) are extracted from original grayscale image by performing first an image masking (simply a logical ANDing of the candidate regions with the original image => the result is a grayscale image with the candidate regions in grayscale form and the remaining picture pitch black) then applying SB. The SB is a thresholding technique that depends on ambient lighting: since when LPs are subjected to extra light (ie flash of the camera), the reflective material within causes the LP to shine even if in broad daylight. This allows the elimination of all the falsely isolated regions where no LPs exist. The SB is also considered as an edge detection method. Edge detection is used to reduce an image into a group of contours for the objects lying within it.

Connected Component Analysis or CCA


ehixib.png


After SB edge detection, we label the objects within the image to identify how many objects (in this case the objects are the LPs) exist within the isolated region. But before the labeling, we perform connected component labeling where the pixels that lie within the neighborhood of a certain pixel are recognized as coming from the same object; this topic has been discussed already here. 8-connectivity is adopted for this application. Now after connecting the pixels of the same object together, we identify how many objects exist in the isolated region that match certain characteristics of an LP (here we assume that the LP studied is only Lebanese LP: this is our first limitation which needs solving; without this restriction, it is very complex to conduct the remaining steps and sections of the algorithm that even the authors have applied to their LP detection of Greek license plates). In each country, the LPs have specific parameters (constant height to width ratio within a marginal error), orientation (not of the LP itself but rather the alphanumeric characters and other objects like the Lebanese cedar tree are unique in their orientation with respect to the borders), and Euler's number (the number of alphanumeric characters that lie within the Lebanese LP are also unique compared to the rest of the countries). These conditions are used to identify the LP objects in the isolated and selected regions.

An example of how the original image is reduced to after applying the aforementioned steps is:

2gy5e2a.png


Image Inversion and Object Number Tracking


281opw.png


Sometimes the luminosity of the surrounding is not enough (e.g. in the dark) so the reflective material of the LP shines brightly which can lead to a false conclusion that the captured image does not have an LP object. This is where the grayscale inverted form of the image is treated as the original image instead, and all the 4 steps mentioned so far would be repeated on this inverted form. Other cases considered are license plates with dark background and white characters (like those of Qatar). This method is only effective 85% of the time <= our second limitation. As for object number tracking, it is just to recognize exactly how many LPs exist within an image (I don't think this step is required for an anti-speeding detector).

Storing LP Boundary Coordinates


fmp3t1.png


Finally, the coordinates of the desired LPs are stored for later analysis (sections 2 and 3).


An image of how the algorithm can be applied for the LP with dark background and white characters is shown below:


or6jd1.png


For those of you who prefer a flowchart than reading, here you go: flowchart of LPR stage:


15chlzl.png


License Plate Processing

This stage is proceeded by slant correction which for now will not be explained or implemented; I will do that later on but rest assure that it will be explained before posting the code and results of implementation on Lebanese LPs.


14xiclx.png


This section involves 8 steps: specifying sub-image (to process each LP alone), cropping sub-image (to resize extracted regions into a standard form before conducting further analysis), SCW segmentation (performed on alphanumeric characters), image inversion (for better CCA results), CCA (connected-component labeling of alphanumeric characters in the LP using the orientation and height standards), character enclosing (separating alphanumeric characters into regions of their own), character number tracking (number of enclosed boxes = number of alphanumeric characters per LP <= I think this is where we can actually modify the code to study all possible LPs that can be encountered: if no boxes are yielded, we can refer the image to another part where the algorithm is tailored to suit LPs from other countries, or if another number of boxes is yielded, then we refer the image to another part where the country LP with that number of LP characters is analyzed by its tailored code), and character resizing (resize the characters for next section of character recognition).

Specifying and Cropping Sub-images, SCW Segmentation, Image Inversion, and CCA


2qs17o1.png


Character Enclosing, Tracking and Resizing


149cvat.png


We mean by PNN: Probabilistic Neural Network, which is a neural network that uses Bayes detector and less training cycles than regular networks like back-propagation to make its decisions (more on NNs here). Although it requires cumbersome coding and it has a rather slow execution time, it is good for analyzing noisy, degraded LPs and continuously improves the learning curve for better character recognition. Its success rate is 95% to 98%.

An example of how the final LP appears is:

mtv3es.png


The flowchart for character segmentation or CS is:


2ii8llw.png


Optical Character Recognition or OCR


1zyik41.png


This section involves developing a PNN for character recognition. We discuss the topology and the learning mechanism of the PNN.

Topology


250nptg.png


An example of what the PNN topology looks like is:


2psj97p.png


The topology used for our Lebanese LPs however require less output nodes. The 108 input layer nodes correspond to number of pixels that compose a single LP alphanumeric character. The 180 middle layer nodes correspond to number of output nodes (36) times number of image patterns (i.e. possible view of character) stored for each of the output nodes (in this case 5). The 36 output layer nodes correspond to the 10 digits (0 to 9) plus 26 letters of the English alphabet (A to Z).

Competitive and Conscience Learning Mechanism


29pchtk.png


The learning mechanism enhances the chances of recognizing the character correctly; this is done as an update on how the character encountered might look like (ie characteristics) in the database of alphanumeric characters that is stored and used for the comparison (using cross-correlation) with the analyzed input characters. Note that not all the alphabet characters are used for Lebanese LPs: only the letters corresponding to the cities which issue the LPs are considered, such as B for Beirut, Z for Zahle, T for Tripoli, etc... But you also have to figure that the detected characters are not only for English alphanumeric characters but Arabic ones. On the other hand, it is possible to identify the LP correctly by simply analyzing the English section of the LP. When the analysis yields no result, the Arabic section would be analyzed. These restrictions allow not only reducing the number of output nodes on the PNN network, but also generating 2 PNN networks one for English section and one for Arabic section => less complexity and faster execution run-time. A similar restriction analysis can be conducted on LPs of each country. The mathematical formulas would be given later on.


To those who are interested in trying to write the code for the algorithm, I'll give you a week starting from now. Just implement the first 2 sections for now. The next post would explain the slant correction. Have fun!!

Last edited by mesa177 (November 11 2011)

Offline

#2 November 10 2010

rolf
Member

Re: License Plate Extraction, Processing, and Character Segmentation

We dont have to follow the exact methodology, I think we can modify it, according to the tools (libraries) we have and will be using. A lot of work can be spared by correctly designing the LP, but I guess that's a luxury we don't have here?
And another big, if not major problem you might encounter in creating such a device is the camera sensitivity. Take for example a night time situation, an average camera would probably have a hard time taking an acceptable picture of the LP of a stationary vehicle from some distance, due to the low light and high level of sensor noise... how about a speeding car (think of the low exposure and motion blur)... heh :-). One possible solution would be to illuminate the cars with invisible light (like infrared), but to which the camera sensor will be sensible. Most stock sensors are actually sensible to infrared light, but are fitted with an anti infrared filter, which, if removed, can turn the camera into a night vision device.

Offline

#3 November 10 2010

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

Okay rolf, what you are discussing lies within the category of image acquisition requirements. This will be discussed later on in the hardware section; for now, say that your images are acquired by a 5 mega-pixel camera on a N95 Nokia phone (which I used to capture my images for the study).

Focus on the processing part in this section.

PS: No, you don't need an external light source besides the flash of the camera since the reflective material which the LP is composed of would be more than enough to identify the LP correctly.

Last edited by mesa177 (November 10 2010)

Offline

#4 November 11 2010

saeidw
Member

Re: License Plate Extraction, Processing, and Character Segmentation

That's a very detailed explanation, thank you! So I suppose the first step would be to implement SCW segmentation?

I think I can manage that and the Image Masking in a week of awesome nonstop hacking. I don't think I have that luxury but I'll certainly try!

Offline

#5 November 11 2010

J4D
Member

Re: License Plate Extraction, Processing, and Character Segmentation

They already do this, we don't really need to reinvent the wheel :) lets think of something more useful.
The information you stated is great :)

Offline

#6 November 30 2010

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

If this topic has generated enough interest, please state so because I need to know if I should continue with the posts or close this topic.

Offline

#7 April 28 2011

Tarek
Banned

Re: License Plate Extraction, Processing, and Character Segmentation

<moderator edit: Off-topic. You are welcome to start a new topic about this />

Offline

#8 November 2 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

can you help me in that code it is for the first step  i just get white picture with few black points resulted image after sliding window , i dont know if this is the true way to do it , it is on matlap


clear
clc



image = rgb2gray(imread('65.jpg'));

%image = [1 2 3 4 5 6;7 8 9 10 11 12];
imageWidth  = size(image, 2)
imageHeight = size(image, 1)

windowWidth = 24;
windowHeight =8;

disp('Processing window1...'); 

for j = 1:imageHeight - windowHeight + 1
    for i = 1:imageWidth - windowWidth + 1

window1(j,i) = round((mean(mean(image(j:j + windowHeight - 1, i:i + windowWidth - 1, :)))));
        % do stuff with subimage
    end
end

imageWidth1  = size(window1, 2)
imageHeight1 = size(window1, 1)





windowWidth1 = 12;
windowHeight1 =4;

disp('Processing window2..'); 

for j = 1:imageHeight - windowHeight1 + 1
    for i = 1:imageWidth - windowWidth1 + 1

window2(j,i) =round( mean(mean(image(j:j + windowHeight1 - 1, i:i + windowWidth1 - 1, :))));
        % do stuff with subimage
    end
end


imageWidth2 = size(window2, 2)
imageHeight2 = size(window2, 1)

newwindow2 = window2(1:imageHeight1,1:imageWidth1);


for j = 1 :imageHeight1   
   for i = 1 :imageWidth1
      
       if((window1(j,i)/newwindow2(j,i))>.5)
           newimage(j,i)=1;
       else
           newimage(j,i)=0;
       end
       
   end
    
end
imshow(newimage);

Offline

#9 November 2 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

Ok, first of all, I need to see your original image. If it's not a picture of a car with a license plate, then you can't know what to expect as an end result. Furthermore, how did you decide on the size of your windows A and B? If you did the calculation then fine, if not, then you have to (note: read the original paper from which the algorithm is derived; PM me your email if you can't download it).

PS: The code I wrote is also Matlab, so you've just made my work easier ;)

For example, if the original image is the following:

24yxsox.jpg

Then the height/width ratio is 1/3. So selecting X1 to be 6 and X2 to be 12, Y1 becomes 2 and Y2 becomes 4 (X1 is window A's width and Y1 is window A's height, X2 and Y2 are the same for window B). The threshold TS is set to 0.8 by trial and error (no other way). For the first step of SCW (i.e. SCW segmentation), these are the only parameters needed. However, in later stages (CCA), the license plates or LPs to be detected must have a limitation on the aspect ratio, orientation angle and Euler’s number.

The Matlab code for conducting the SCW segmentation on the above image is as such:

% 1 - Sliding Concentric Windows (SCW) Segmentation:
%
% This program applies the SCW segmentation to the studied car image 
% containing a license plate. The sizes of the applied windows A and 
% B are 12 x 4 and 24 x 8 respectively. After appending the grayscale image
% by appropriate number of rows and columns, the statistical data (mean and
% standard deviation) of each window is found. Thresholding with the
% segmentation rule is then performed with a threshold value of 0.8. 
%--------------------------------------------------------------------------

% Initialization Stage:

clear all
clc

TS = 0.8;                     % Threshold for segmentation rule

%--------------------------------------------------------------------------

figure(1)
I1 = imread('image 1.jpg');  % Importing picture of license plate 1
I1 = rgb2gray(I1);
imshow(I1,[]);               % Show grayscale picture
[M1,N1] = size(I1);

figure(2)
I1_ext = horzcat(I1(:,1:12),I1,I1(:,N1-10:N1)); % Appending rows and columns to obtain extended boarders
                                                                     % for processing purposes
I1_ext = vertcat(I1_ext(1:4,:),I1_ext,I1_ext(M1-2:M1,:));
[M1_ext,N1_ext] = size(I1_ext);
for i = 5:M1_ext-3 % Scanning the image according to its original size (i.e. where the data lies) 
    for j = 13:N1_ext-11
        A_SCW = I1_ext(i-2:i+1,j-6:j+5);
        B_SCW = I1_ext(i-4:i+3,j-12:j+11);
        mA = mean(mean(A_SCW));
        mB = mean(mean(B_SCW));
        if (mA/mB < TS)
            I1_SCW_ext(i,j) = 1;
        else
            I1_SCW_ext(i,j) = 0;
        end
        clear A_SCW B_SCW mA mB
    end
end
I1_SCW = I1_SCW_ext(5:M1_ext-3,13:N1_ext-11); %Regaining original size of image
imshow(I1_SCW,[]);           % Show SCW segmentation
clear I1_ext I1_SCW_ext M1_ext N1_ext

The resulting SCW segmented image is:

11sp74z.jpg

When I ran your code to the same image, it took too much processing time because you were scanning the image three times while all you needed to do was scan once and do the calculations during that single scan. The mean values don't have to be stored, they're just being used for calculation purposes. Second, the limits of the scan range (that is the values of i and j), are incorrect. You don't shrink your original picture, because data can lie within the removed boarders. Instead, extend the boarders of your picture.

Although the later two parts have an impact on your results, they are not the reason behind the faulty result that you're getting. This is: the selected threshold value is not 0.5 but 2 (0.5 is for ratio of height over width, but you are considering the ratio of width over height => 1/0.5 = 2). However, the threshold is too high, so I selected a threshold of 1.25 (i.e. 1/0.8 = 1.25; for your image '65.jpg', try a threshold of 1/0.6 and decrease it until you get a satisfactory result and then fixate it).

After modifying your code:

clear
clc



image = rgb2gray(imread('image 1.jpg'));

%image = [1 2 3 4 5 6;7 8 9 10 11 12];
imageWidth  = size(image, 2)
imageHeight = size(image, 1)

windowWidth = 24;
windowHeight =8;

disp('Processing window1...'); 

for j = 1:imageHeight - windowHeight + 1
    for i = 1:imageWidth - windowWidth + 1

window1(j,i) = round((mean(mean(image(j:j + windowHeight - 1, i:i + windowWidth - 1, :)))));
        % do stuff with subimage
    end
end

imageWidth1  = size(window1, 2)
imageHeight1 = size(window1, 1)

windowWidth1 = 12;
windowHeight1 =4;

disp('Processing window2..'); 

for j = 1:imageHeight - windowHeight1 + 1
    for i = 1:imageWidth - windowWidth1 + 1

window2(j,i) =round( mean(mean(image(j:j + windowHeight1 - 1, i:i + windowWidth1 - 1, :))));
        % do stuff with subimage
    end
end


imageWidth2 = size(window2, 2)
imageHeight2 = size(window2, 1)

newwindow2 = window2(1:imageHeight1,1:imageWidth1);


for j = 1 :imageHeight1   
   for i = 1 :imageWidth1
      
       if((window1(j,i)/newwindow2(j,i))>1.43)%1.25)
           newimage(j,i)=1;
       else
           newimage(j,i)=0;
       end
       
   end
    
end
imshow(newimage);

This is the resulting image:

15xk6jb.jpg

If you extend the image boarders like I did, you would obtain an identical SCW segmented image as generated by my code.

Offline

#10 November 3 2011

jsaade
Member

Re: License Plate Extraction, Processing, and Character Segmentation

I advise anyone interested in Image processing field to read "Feature Extraction and Image Processing - M. Nixon, A. Aguado (2002)" this was my image processing class textbook and (although 2002) it is very informative.

Offline

#11 November 3 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

ZeRaW wrote:

I advise anyone interested in Image processing field to read "Feature Extraction and Image Processing - M. Nixon, A. Aguado (2002)" this was my image processing class textbook and (although 2002) it is very informative.

Thanks for sharing ZeRaW!! I also recommend "Digital Image Processing - Gonzalez & Woods - 3rd ed".

Offline

#12 November 4 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

thansk alot  Mr mesa177
i'm going to read code now
and if i face any problems , i will post it and wish you keep help me

Last edited by elqnas15 (November 4 2011)

Offline

#13 November 4 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

elqnas15 wrote:

thansk alot  Mr mesa177

:\ I'm a girl, so that's Mrs mesa177

looking forward to reading more on your progress :)

Offline

#14 November 4 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

oh iam srry i didnot notice that

Offline

#15 November 4 2011

Georges
Member

Re: License Plate Extraction, Processing, and Character Segmentation

mesa177 wrote:
elqnas15 wrote:

thansk alot  Mr mesa177

:\ I'm a girl, so that's Mrs mesa177

He'll get used to it eventually.

Offline

#16 November 4 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

that was my code for mask

for i = 1 :M1
   for j = 1 : N1
      
       if(I1_SCW(i,j)==0)
       I1(i,j)=0;
       end
   end
end

figure;

imshow(I1);

and i made code for sauvola but i dont know if it is true or not ,i didnot extends borders also because i cant do it , wish you modify my sauvola code to add extended borders (i think my code for sauvola is wrong)

windowWidth = 10;
windowHeight = 10;

[imageHeight,imageWidth] = size(I1);
for j = 1:imageHeight - windowHeight + 1
    for i = 1:imageWidth - windowWidth + 1

 window = double(I1(j:j + windowHeight - 1, i:i + windowWidth - 1, :));

        std2 = std(std(window));
        mA = mean(mean(window));
        K = .5;
        R=128;
        T = mA+(1+K*((std2/R)-1));
        
        if (I1(j,i)>=T)
            NEW(j,i) = 1;
        else
            NEW(j,i) = 0;
        end
        
    end
end
imshow(NEW);

Offline

#17 November 4 2011

MrClass
Member

Re: License Plate Extraction, Processing, and Character Segmentation

Georges wrote:
mesa177 wrote:
elqnas15 wrote:

thansk alot  Mr mesa177

:\ I'm a girl, so that's Mrs mesa177

He'll get used to it eventually.

Uhh? You mean you're a Ms not a Mrs, right sis?

Offline

#18 November 5 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

MrClass wrote:
Georges wrote:
mesa177 wrote:

:\ I'm a girl, so that's Mrs mesa177

He'll get used to it eventually.

Uhh? You mean you're a Ms not a Mrs, right sis?

:\ Must be all the hitching attempts of the nurses at the hospital, but yes I meant Ms.

@elqnas15:

First of all, the AND image from the image masking should be a separate image from the original (a rule of thumb, in image processing you never overwrite the original image). Also, you continued coding with the parameter names that I used: why? Stick with the code that you wrote and I modified, it's good. Yes, it yielded a bit of a different image, but it would be interesting to see if you get a better result than mine.

Some Matlab coding tips:

1) When coding with Matlab, especially something related to image processing, it is better to save the result in a text file so that next time you continue coding you don't have to go through the code from the start (seeing that the processing time is too long). So let's save the result of the SCW segmentation as such:

save newimage.txt -ascii -tabs newimage

In the directory where your m-file is, you should see a text file named "newimage". This file contains the values of the matrix newimage (the data in the matrix is saved as ascii values for later processing purposes; another rule of thumb: always save the values in you matrix as ascii so that you can open them and read their content).

2) When you want to show your image in a figure, write:

imshow(newimage,[])

The brackets [] scales your image for proper viewing.

So a bit of modification on your original code:

load newimage.txt newimage

[M1,N1] = size(image);
[M1_new,N1_new] = size(newimage);
% Extending matrix newimage by missing boarders; the entry values of the 
% added boarders are null
diff = size(image) - size(newimage);
newimage = horzcat(zeros(M1_new,(diff(2)-1)/2+1),newimage,zeros(M1_new,(diff(2)-1)/2));
[M1_new,N1_new] = size(newimage);
newimage = vertcat(zeros((diff(1)-1)/2+1,N1_new),newimage,zeros((diff(1)-1)/2,N1_new));

imageAND = zeros(M1,N1); % Initializing matrix
for i = 1 :M1
   for j = 1 : N1
      
       if(newimage(i,j))
       imageAND(i,j)= image(i,j);
       end
   end
end

figure;
imshow(imageAND,[]);

save imageAND.txt -ascii -tabs imageAND

would result in the following image:

1zyuas5.jpg

I'll read the Sauvola code later on.

Offline

#19 November 5 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

ok thx waiting your comment on sauvola method , also wish you support your code

Offline

#20 November 5 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

Please read the comments within the lines of code to know what went wrong with your written code for Sauvola binarization:

load imageAND.txt imageAND

windowWidth = 10;
windowHeight = 10;
[M1,N1] = size(imageAND);
% Extending the boarders occur evenly along the sides: 5 columns to the
% left and 5 to the right, 5 rows up and 5 down: the image is always
% centralized
imageAND_ext = horzcat(imageAND(:,1:windowWidth/2),imageAND,imageAND(:,N1-(windowWidth/2-1):N1));
imageAND_ext = vertcat(imageAND_ext(1:windowHeight/2,:),imageAND_ext,imageAND_ext(M1-(windowHeight/2-1):M1,:));
[M1_ext,N1_ext] = size(imageAND_ext);
imageAND_ext_t = imageAND_ext';

% The code is processed over the original size of the image =>
% i and j are limited within that range
for j = windowHeight/2+1:N1_ext-windowHeight/2+1
    for i = windowWidth/2+1:M1_ext-windowWidth/2+1
        % The name of the window is b for Sauvola binarization
        % The window is extracted from the image result of the masking, not
        % the original one; also, the scanning window is centralized so 
        % that it covers all the image 
        b = imageAND_ext_t(j-windowHeight/2:j + windowHeight/2 - 1,i-windowWidth/2:i + windowWidth/2 - 1);
        std2 = std(std(b));
        mA = mean(mean(b));
        K = .5;
        R = 128;
        T = mA+(1+K*((std2/R)-1));
        % The thresholding is done for image result of the masking not the
        % original one
        if (imageAND_ext_t(j,i) >= T)
            NEW_ext(j,i) = 1;
        else
            NEW_ext(j,i) = 0;
        end
    end
end

% Remove extended boarders and rotate image for correct viewing
NEW_ext2 = NEW_ext';
NEW = NEW_ext2(windowWidth/2+1:M1_ext-windowWidth/2+1,windowHeight/2+1:N1_ext-windowHeight/2+1);
figure;
imshow(NEW,[]);

The resulting image is:

30c2c2g.jpg

Offline

#21 November 7 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

thank you very much , i have read it , and notice errors in my code

now i test the code on an image


and that was the result of running code on the orginal image

02de3066ba.jpg


now i read about connected component analysis

but i realy can't implement it or do binary measurement

so i wish you provide your code for cca ,and binary measurement

then i will start to study ocr

Last edited by elqnas15 (November 7 2011)

Offline

#22 November 7 2011

mesa177
Member

Re: License Plate Extraction, Processing, and Character Segmentation

elqnas15 wrote:

now i read about connected component analysis

but i realy can't implement it or do binary measurement

so i wish you provide your code for cca ,and binary measurement

then i will start to study ocr

this is not how it works, I post my code only when I see your code. I'm not here to do your work for you.

remember that the CCA cannot be implemented without calculating the parameters aspect ratio, orientation angle, and Euler's number. So start with writing the code to calculate these parameters, post it, and then I'll see if it needs any modification. Then we'll move to the CCA.

Offline

#23 November 8 2011

elqnas15
Member

Re: License Plate Extraction, Processing, and Character Segmentation

OK thx , i will try to do it

does the next step will be Morphological operations to make holes in the square of the license plate ?

or how can i do  binary measurements

Last edited by elqnas15 (November 8 2011)

Offline

#24 May 10 2012

solo220
Member

Re: License Plate Extraction, Processing, and Character Segmentation

I think you should try "OPENCV" it is faster and simpler.
Or you could use some colored light projector  with a filtered lens camera , the LP plate will reflect the light, i tried it and the plates are the brightest in the picture.

Last edited by solo220 (May 10 2012)

Offline

#25 June 13 2012

Beast_C
Member

Re: License Plate Extraction, Processing, and Character Segmentation

Hello everyone!
Mesa177 Thank you alot for this amazing post...i was wondering if i may contact you regarding this project I have started working on it lately.

Offline

Board footer