I. Introduction to license plate recognition
License plate recognition technology originated in the early 1980s, image pattern recognition and computer vision play a vital role in it. With the rapid popularization and progress of computer technology, in the late 1980s, the license plate recognition system was gradually put into the market and used, but the recognition accuracy and speed are not ideal. At present, plate recognition systems in developed countries have been widely used in the market, among which Israel and Singapore companies are relatively leading the plate recognition system. There is no universal license plate detection technology due to different license plate designs. Because Chinese license plates include Chinese characters, foreign license plate recognition systems cannot be directly used for domestic license plate recognition, which requires China’s own research and development. China’s research on license plate recognition technology started slightly later than that of western countries. At present, the Chinese Academy of Sciences’ hanwang Eye and Hong Kong vision Technology companies are the leading technologies in China. However, the use of these license plate recognition systems in the market has certain limitations, in the poor quality of license plate image, license plate tilt, lighting conditions are not ideal, the recognition rate will be greatly reduced. In order to overcome the above problems, the license plate images obtained under different lighting conditions are recognized and analyzed. Because license plates involve confidential information, there is no publicly available large-scale data set for experimental comparison. In this paper, the license plate data collection, unified processing 320×240 resolution of the picture, the establishment of a test database. The database is divided into two categories: test library 1 for good lighting conditions, no shadow license plate; Test library 2 for poor lighting conditions, there are shadow plates. The traditional template matching algorithm was used to establish the license plate recognition system, and the median filtering algorithm was used to average the template images, and a uniform recognition template library with a resolution of 20×40 was established. For the convenience of users, the graphical user interface (GUI) is established by using Matlab. Through the test of Kuqa plate, it can be seen that the image quality of license plate has a great influence on the recognition rate. Therefore, in the establishment of license plate recognition system, the appropriate Angle of filling light can effectively improve the recognition accuracy.1 image preprocessingBecause license plates are mostly obtained through traffic monitoring and other conditions, due to the surrounding traffic environment, shooting Angle, lighting and real-time requirements and other reasons, it is difficult to ensure the recognition accuracy of the obtained photos directly used for license plates. Therefore, pre-processing images can improve the accuracy of recognition.1.1 Image grayingIn order to improve the speed of the license plate recognition system and save memory, the RGB image is first converted into grayscale image. The three basic colors of red, blue and green can be composed of any color in different proportions, so each color of the license plate photo can be composed of different proportions of red, blue and green. Gray image can be represented by array I, and the data types of array and I generally have integer and double precision. Usually 0 is black and 255 is white. A conversion method suitable for the human visual system is adopted, as shown in Formula (1).Among them, the coefficients A, B and c should be greater than 0, and a+ B +c=1, Y represents the gray value, R, G and b represent red, green and blue respectively, a=0.299, b=0.584 and c=0.117. Figure 1 shows the original license plate image with the license plate photo, and Figure 2 shows the gray image of the license plate image after the gray processing of formula (1).Figure 1 Original license plateFIG. 2 Gray scale of license plate1.2 Image binarizationImage binarization can not only greatly reduce the amount of data, but also highlight the target contour of the image, which is beneficial to the subsequent image positioning and segmentation processing. In the binarization processing of license plate image, the pixel determined as the target region has a gray value greater than or equal to the threshold value, which is calculated as shown in Formula (2). After testing, when the threshold th=0.76, the effect is good, as shown in Figure 3.Figure 3. Binarization of license plate1.3 Image edge detectionIn this paper, The Roberts operator is used for edge detection. This operator has a small amount of calculation, is fast and convenient for subsequent real-time processing. Its template is shown in Table 1. If the gradient amplitude G(x, y) is greater than the set threshold, it is judged as an edge. G(x, y) is calculated as shown in Formula (3), where the threshold value is 0.15. Table 1 Roberts operator templatesWhere, f(x, y) is the gray value in the image space (x, y), and G(x, y) is the gradient amplitude of F (x, y). Figure 4 shows the result after edge detection.Figure 4. Edge detection of license plate
Design of license plate recognition system 2.1 License plate positioningLicense plate location using color feature extraction, the general license plate area has very obvious characteristics, Chinese license plate with blue background white characters in the majority. According to the color characteristics of the license plate, the traditional method generally divides the reasonable license plate area by the color pixel statistics method. Suppose that the RGB image containing the license plate is collected by the camera, and the horizontal direction is recorded as Y, and the vertical direction is recorded as X. First, the corresponding color range of each component of the license plate is determined. Secondly, the corresponding number of pixels in the horizontal direction and the reasonable area of the license plate are calculated. Then, the number of pixels of white in the color range in the vertical direction of the segmtioned horizontal region is calculated and a reasonable threshold is set for positioning. Finally, the license plate area is determined according to the range of corresponding directions. However, the accuracy of this method is low. This paper adopts the color feature extraction and binarization classification method proposed in literature [6] to improve the algorithm. The calculation method is shown in Formula (4). Figure 5 shows the license plate after positioning. Where, the blue feature can be expressed by formula (4) :FIG. 5 License Plate Location FIG. 2.2 License plate Character Recognition Before character recognition, the license plate characters are divided. Character segmentation adopts threshold segmentation, which mainly includes two steps [7]. (1) Determine the threshold required for segmentation. (2) Compare the threshold value with the gray value of each point to achieve the purpose of segmentation. After the segmentation of the image is normalized, the size of the character image can be effectively scaled to get the same size character image, which is convenient for the subsequent character recognition. Template matching is one of the most commonly used recognition methods in digital image processing. Firstly, a template library is established, and then the characters are input into the template to find the best matching template characters. The size of the template image is 20×40, and the template library consists of three parts: Chinese characters for short and capital English letters (O is generally not used as the license plate letter) of 32 provinces. A partial image of the template is shown in Figure 6.Figure 6. Part of the template library
Part of the source code
function varargout = gui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_OpeningFcn, ...
'gui_OutputFcn', @gui_OutputFcn, ...
'gui_LayoutFcn', [],...'gui_Callback'[]);if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:}); End % End initializationfunction gui_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = gui_OutputFcn(~, ~, handles)
varargout{1} = handles.output; % = = = = = = = = = = = = = = = = = = = = = = input image = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function pushbutton1_Callback (hObject, ~. handles) [filename, pathname]=uigetfile({'*.jpg';'*.bmp'}, 'File Selector');
I=imread([pathname '\' filename]); handles.I=I; guidata(hObject, handles); axes(handles.axes1); imshow(I); title('The original image'); % = = = = = = = = = = = = = = = = = = = = = = image processing = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function pushbutton2_Callback (~, ~, handles) I = handles. I; I1=rgb2gray(I); I2=edge(I1,'roberts'.0.18.'both'); axes(handles.axes2); imshow(I1); title('Grayscale'); axes(handles.axes3); imshow(I2); title('Edge detection');
se=[1;1;1]; I3=imerode(I2,se); % corrosion operation se=strel('rectangle'[25.25]); I4=imclose(I3,se); % image clustering, fill image I5=bwareaopen(I4,2000); % The gray value of cluster removal is less than2000Part of the [] y, x, z = size (I5); % return15The dimensions of each dimension, stored in x,y,z myI=double(I5); Blue_y= Zeros (y,1); % produces a y star1The zero needlefor i=1:y
for j=1:x
if(myI(i,j,1) = =1If myI image coordinate is (I, j) point value is1That is, the background color is blue, blue plus Blue_y(I,1)=Blue_y(i,1) +1; End end end [temp MaxY]= Max (Blue_y); In the %Y direction license plate area, %temp is determined to be the maximum value of the elements in the vector yellow_y, and MaxY is the value of the index PY1=MaxY;while((Blue_y(PY1,1) > =5)&&(PY1>1))
PY1=PY1- 1;
end
PY2=MaxY;
while((Blue_y(PY2,1) > =5)&&(PY2<y))
PY2=PY2+1; end IY=I(PY1:PY2,:,:); %X direction license plate area determine Blue_x=zeros(1,x); % further confirm the license plate area in the x directionfor j=1:x
for i=PY1:PY2
if(myI(i,j,1) = =1)
Blue_x(1,j)=Blue_x(1,j)+1;
end
end
end
PX1=1;
while((Blue_x(1,PX1)<3)&&(PX1<x))
PX1=PX1+1;
end
PX2=x;
while((Blue_x(1,PX2)<3)&&(PX2>PX1))
PX2=PX2- 1;
end
PX1=PX1- 1; % correction of the license plate area1;
dw=I(PY1:PY2- 8 -,PX1:PX2,:); t=toc; axes(handles.axes4); imshow(dw),title('Locate license plate');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
imwrite(dw,'dw.jpg'); % write color license plate to dW file a=imread('dw.jpg'); % read license plate b= rGB2gray (a); % Convert license plate image to grayscale imwrite(b,'Greyscale license plate.jpg'); % write grayscale image to file g_max=double(max(max(b)));
g_min=double(min(min(b)));
T=round(g_max-(g_max-g_min)/3); %T = binarization threshold [m,n]=size(b); d=(double(b)>=T); %d: binary image imwrite(d,'Binary.jpg'); % filter before % filter h=fspecial('average'.3); % to establish the pre-defined filtering operator, average is the mean filtering, template size is3*3d=im2bw(round(filter2(h,d))); % imwrite(d, imwrite(d, imwrite(d,'Mean filter.jpg'); % Some images are manipulated % swell or corrode se=eye(2); % identity matrix [m,n]=size(d); % Returns the information matrixif bwarea(d)/m/n>=0.365% Calculates whether the total area of an object in a binary image is greater than the total area0.365d=imerode(d,se); % if greater than0.365Corrosion is carried outelseif bwarea(d)/m/n<=0.235% Calculates whether the ratio of the total area of an object in a binary image to the total area is less than or equal to0.235d=imdilate(d,se); %% If less than the implementation of the expansion operationend
imwrite(d,'inflation. JPG'); % Searches for a block with continuous characters. If the length is greater than a certain threshold, the block is considered to be composed of two characters and needs to be divided d=qiege(d); [~,n]=size(d); k1=1;
k2=1;
s=sum(d);
j=1;
while j~=n
while s(j)==0
j=j+1;
end
k1=j;
while s(j)~=0 && j<=n- 1
j=j+1;
end
k2=j- 1;
if k2-k1>=round(n/6.5)
[val,num]=min(sum(d(:,[k1+5:k2- 5))); d(:,k1+num+5) =0; D =qiege(d); % cut out7Characters y1 =10;
y2=0.25;
flag=0;
word1=[];
while flag==0
[m,n]=size(d);
left=1;
wide=0;
while sum(d(:,wide+1))~=0
wide=wide+1;
end
ifWide <y1 % d(:,[1:wide])=0;
d=qiege(d);
else
temp=qiege(imcrop(d,[1 1 wide m]));
[m,n]=size(temp);
all=sum(sum(temp));
two_thirds=sum(sum(temp([round(m/3) :2*round(m/3)], :)));if two_thirds/all>y2
flag=1; word1=temp; %word1
end
d(:,1:wide])=0; d=qiege(d); end endCopy the code
Third, the operation result
Iv. Matlab version and references
1 Matlab version 2014A
2 References [1] CAI Limei. MATLAB Image Processing — Theory, Algorithm and Case Analysis [M]. Tsinghua University Press, 2020. [2] Yang Dan, ZHAO Haibin, LONG Zhe. Detailed Analysis of MATLAB Image Processing Examples [M]. Tsinghua University Press, 2013. [3] Zhou Pin. MATLAB Image Processing and Graphic User Interface Design [M]. Tsinghua University Press, 2013. [4] LIU Chenglong. [5] GUO Runhua, SU Tingting, MA Xiaowei. Study on MATLAB Image Processing [M]. Tsinghua University Press, 2015. Journal of tsinghua university (science and technology), 2013,53 (9) : 1221-1226. (in Chinese with English abstract) Research on license plate recognition algorithm based on BP neural network [D]. Daqing: Northeast Petroleum University, 2018. [7] An improved method for defacing license plate recognition based on template matching [J]. Intelligent computer and applications. 2019,9(03). [8] liang kai. Design and Implementation of Vehicle License plate Recognition System based on MATLAB [D]. Harbin: Heilongjiang University, 2018. [9] Computer simulation, 2014,31 (10) : 161-164,290. (in Chinese with English abstract) License plate Recognition system based on SVM and BP Neural Network. Electronic Science and Technology, 2016, 29(1) : 98-101.