First, license plate recognition introduction

License plate recognition technology originated in the early 1980s, image pattern recognition and computer vision play an important role in it. With the rapid popularization and progress of computer technology, in the mid and late 1980s, license plate recognition system was gradually put into the market and used, but the recognition accuracy and speed are not ideal. Currently, license plate recognition systems in developed countries have been widely used in the market, among which companies in Israel and Singapore are leading the way. Because of the different design of license plate, there is no universal license plate detection technology. Because Chinese license plate includes Chinese characters, foreign license plate recognition system cannot be directly used for domestic license plate recognition, which needs to be independently developed by China. The research of license plate recognition technology in China started slightly later than that in western countries. The current domestic technology leaders are The Chinese Academy of Sciences’ Hanwang Eye and Hong Kong’s Vision Technology company. However, these license plate recognition systems put into the market have certain limitations, in the case of poor license plate image quality, license plate tilt, lighting conditions are not ideal, the recognition rate will be greatly reduced. In order to overcome the above problems, license plate images obtained under different lighting conditions are recognized and analyzed in this paper. Because license plates involve confidential information, there are no publicly available large-scale data sets for use and experimental comparison. In this paper, license plate data were collected, images of 320×240 resolution were processed uniformly, and test database was established. The database is divided into two types: test library 1 is good lighting conditions, no shadow license plate; Test library 2 has poor lighting conditions and shadow license plates. The traditional template matching algorithm was used to build the license plate recognition system, and the median filtering algorithm was used to average the template images, and a recognition template library with a resolution of 20×40 was established. For the convenience of users, a graphical user interaction interface (GUI) is established by Matlab. Through the test kuqa plate experiment, 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 light supplement can effectively improve the accuracy of recognition.1. Image preprocessingBecause the license plate is 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 accuracy of the photos directly used for license plate recognition. Therefore, preprocessing images can improve the accuracy of recognition.1.1 Image grayscaleThe license plate shot by the camera is usually a color image, that is, RGB image in order to improve the speed of the license plate recognition system, save memory, RGB image is converted to gray map. The three basic colors of red, blue and green can be composed of any color according to 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 type of array I generally has two types: integer and double precision. Usually 0 represents black and 255 represents white. The conversion method suitable for the human visual system is adopted, as shown in Formula (1).Where, the coefficients a, b and C are greater than 0, and a+ B + C =1, Y represents 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 license plate photo, and Figure 2 shows the gray image of license plate image after gray processing of Formula (1).Figure 1 Original license plateFigure 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 location and segmentation. In the binarization processing of license plate image, the pixel identified as the target area has a gray value greater than or equal to the threshold value, which is calculated as shown in Formula (2). After the test, when the threshold th=0.76, the effect is better, as shown in Figure 3.Figure 3. Binarization of license plate1.3 Image edge detectionRoberts operator is used for edge detection in this paper. This operator has a small amount of computation, fast speed and is 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. The calculation formula of G(x, y) is shown in Formula (3), where the threshold is 0.15. Table 1 Roberts operator templateWhere, f(x, y) is the gray value at the image space (x, y), and G(x, y) is the gradient amplitude of F (x, y). Figure 4 is the result of edge detection.Figure 4 Edge detection of license plate

Design of license plate recognition system 2.1 License plate locationLicense plate location adopts color feature extraction, general license plate area has obvious characteristics, Chinese license plate with blue background white characters in the majority. Traditional methods are generally based on the color characteristics of license plates and the method of color pixel point statistics to segment a reasonable license plate area. It is assumed that RGB images containing license plates are collected by the camera, and the horizontal direction is denoted as Y, and the vertical direction as X. First, determine the color range corresponding to each component of the license plate. Secondly, the number of horizontal pixels and the reasonable area of the license plate are calculated. Then, the number of white pixels in the vertical direction of the color range in the segmented horizontal direction region is calculated, and a reasonable threshold is set for localization. Finally, according to the corresponding direction of the range to determine the license plate area. 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, and the calculation method is shown in Formula (4). Figure 5 shows the license plate after positioning. The blue feature can be expressed by formula (4) :Figure 5 License plate location Figure 2.2 License plate character recognition Before character recognition, license plate character segmentation. Character segmentation adopts threshold segmentation, which mainly consists of two steps [7]. (1) Determine the threshold for segmentation. (2) Compare the threshold value with the gray value of each point to achieve the purpose of segmentation. By normalizing the segmented image, the size of the character image can be effectively scaled to get the character image of the same size, 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 characters are input into the template to find the best matching template character. The size of the template image is 20×40, and the template library is composed of three parts: the numbers 0-9, the abbreviation Chinese characters of 32 provinces and the uppercase English letters (O is generally not used as the license plate letter). A partial image of the template is shown in Figure 6.Figure 6. Partial image of template library

Two, some source code

%% clear; close all; clc; Read image [filename filepath] = uigetFile ('.jpg'.'Enter an image to identify');
file = strcat(filepath, filename);
img = imread(file);
figure;
imshow(img);
title('License plate image'); Img1 = rGB2gray (img); % RGB image to gray image figure; subplot(1.2.1);
imshow(img1);
title('Grayscale image');
subplot(1.2.2);
imhist(img1);
title('Gray histogram after gray processing'); Img4 = edge(img1,'roberts'.0.15.'both');
figure('name'.'Edge detection');
imshow(img4);
title(Roberts operator edge detection); %% image corrosion se=[1;1;1];
img5 = imerode(img4, se);
figure('name'.'Image corrosion');
imshow(img5);
title('Corroded image'); %% smooth image, image swell se = strel('rectangle'[30.30]);
img6 = imclose(img5, se);
figure('name'.'Smoothing');
imshow(img6);
title('Smooth image contour'); %% removes all less than2200pixel8Img7 = bwareaopen(img6,2200);
figure('name'.'Remove small Objects');
imshow(img7);
title('Remove small object from image'); [y, x, z] = size(img7); img8 =double(img7); Blue_Y = zeros(Y,1);
for i = 1:y
    for j = 1:x
        if(img8(i, j) == 1% t (I, I, I)1) = blue_Y(i, 1) + 1; End end % find the minimum value of Y coordinate img_Y1 =1;
while (blue_Y(img_Y1) < 5) && (img_Y1 < y)
    img_Y1 = img_Y1 + 1; Img_Y2 = Y; end % find the maximum value of Y coordinates img_Y2 = Y;while (blue_Y(img_Y2) < 5) && (img_Y2 > img_Y1)
    img_Y2 = img_Y2 - 1; End % x blue_X = zeros(1, x);
for j = 1:x
    for i = 1:y
        if(img8(i, j) == 1) % Determine license plate location area blue_X(1, j) = blue_X(1, j) + 1; End end end % find the minimum value img_X1 =1;
while (blue_X(1, img_X1) < 5) && (img_X1 < x)
    img_X1 = img_X1 + 1; End % find the minimum value img_X2 = x;while (blue_X(1, img_X2) < 5) && (img_X2 > img_X1)
    img_X2 = img_X2 - 1; Img9 = img(img_Y1:img_Y2, img_X1:img_X2, :); figure('name'.'Position clipped image');
imshow(img9);
title('Color license plate image after location clipping') % Save extracted license plate image imwrite(img9,'License plate image.jpg'); %% license plate image preprocessing plate_img = imread('License plate image.jpg'); % to grayscale image plate_img1 = rGB2gray (plate_img); % RGB image to gray image figure; subplot(1.2.1);
imshow(plate_img1);
title('Grayscale image');
subplot(1.2.2);
imhist(plate_img1);
title('Gray histogram after gray processing'); % histogram equalization plate_img2 = histeq(plate_img1); figure('name'.'Histogram equalization');
subplot(1.2.1);
imshow(plate_img2);
title('Histogram equalization of the image');
subplot(1.2.2);
imhist(plate_img2);
title('histogram'); % binary processing plate_img3 = im2bw(plate_img2,0.76);
figure('name'.'Binarization');
imshow(plate_img3);
title('Binary image of license plate'); % Median filter plate_img4 = medFilT2 (plate_img3); figure('name'.'Median filtering');
imshow(plate_img4);
title('Median filtered image'); Plate_img5 = my_imsplit(plate_img4); [m, n] = size(plate_img5); s = sum(plate_img5); %sum(x) is the vertical sum, the sum of each column, the result is the row vector; j =1;
k1 = 1;
k2 = 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(plate_img5(:, [k1+5:k2- 5))); plate_img5(:, k1+num+5) = 0;
    end
end

y1 = 10;
y2 = 0.25;
flag = 0;
word1 = [];
while flag == 0
    [m, n] = size(plate_img5);
    left = 1;
    width = 0;
    while sum(plate_img5(:, width+1)) ~= 0
        width = width + 1;
    end
    if width < y1
        plate_img5(:,1:width]) = 0;
        plate_img5 = my_imsplit(plate_img5);
    else
        temp = my_imsplit(imcrop(plate_img5, [1.1,width,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;
        end
        plate_img5(:,1:width]) = 0;
        plate_img5 = my_imsplit(plate_img5);
    end
end

figure;
subplot(2.4.1), imshow(plate_img5); % split the second character [word2,plate_img5]= getWord (plate_img5); subplot(2.4.2), imshow(plate_img5); % split the third character [word3,plate_img5]= getWord (plate_img5); subplot(2.4.3), imshow(plate_img5); % split the fourth character [word4,plate_img5]= getWord (plate_img5); subplot(2.4.4), imshow(plate_img5); % split the fifth character [word5,plate_img5]= getWord (plate_img5); subplot(2.3.4), imshow(plate_img5); % split out the sixth character [word6,plate_img5]= getWord (plate_img5); subplot(2.3.5), imshow(plate_img5); % split out the seventh character [word7,plate_img5]= getWord (plate_img5); subplot(2.3.6), imshow(plate_img5);

 figure;
 subplot(5.7.1),imshow(word1),title('1');
 subplot(5.7.2),imshow(word2),title('2');
 subplot(5.7.3),imshow(word3),title('3');
 subplot(5.7.4),imshow(word4),title('4');
 subplot(5.7.5),imshow(word5),title('5');
 subplot(5.7.6),imshow(word6),title('6');
 subplot(5.7.7),imshow(word7),title('7');

 word1=imresize(word1,[40 20]); %imresize: B=imresize(A,ntimes,method); One method is optional on bilinear (bilinear), bicubic, box, lanczors2, lanczors3 word2 = imresize (word2, [40 20]);
 word3=imresize(word3,[40 20]);
 word4=imresize(word4,[40 20]);
 word5=imresize(word5,[40 20]);
 word6=imresize(word6,[40 20]);
 word7=imresize(word7,[40 20]);

 subplot(5.7.15),imshow(word1),title('11');
 subplot(5.7.16),imshow(word2),title('22');
 subplot(5.7.17),imshow(word3),title('33');
 subplot(5.7.18),imshow(word4),title('44');
 subplot(5.7.19),imshow(word5),title('55');
 subplot(5.7.20),imshow(word6),title('66');
 subplot(5.7.21),imshow(word7),title('77');
 
 imwrite(word1,'1.jpg'); % create 7-bit license plate character image imwrite(word2,'2.jpg');
 imwrite(word3,'3.jpg');
 imwrite(word4,'4.jpg');
 imwrite(word5,'5.jpg');
 imwrite(word6,'6.jpg');
 imwrite(word7,'7.jpg');

Copy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

2 Reference [1] CAI Limei. MATLAB Image Processing — Theory, Algorithm and Case Analysis [M]. Tsinghua University Press, 2020. [2] Yang Dan, ZHAO Haibin, LONG Zhe. Examples of MATLAB Image Processing In detail [M]. Tsinghua University Press, 2013. [3] Zhou Pin. MATLAB Image Processing and Graphical User Interface Design [M]. Tsinghua University Press, 2013. [4] LIU Chenglong. Guo Runhua, SU Tingting, MA Xiaowei. Proficient in MATLAB Image Processing [M]. Tsinghua University Press, 2015. Journal of tsinghua university (science & technology), 2013,53 (9) : 1221-1226. [6] lu Yang. Daqing: Northeast Petroleum University, 2018. [7] LI Qiang, ZHANG Juan. An improved method of defaced license plate recognition based on template matching [J]. Intelligent computer and application, 2019,9(03). [8] liang kai. Design and Implementation of License Plate Recognition System Based on MATLAB [D]. Harbin: Heilongjiang University, 2018. [9] LIU Xiongfei, ZHU Shengchun. [10] zeng quan, tan beihai. Multi-feature extraction of license plate characters and recognition algorithm based on BP neural network [J]. Computer simulation, 2014,31 (10) : 161-164,290. License Plate Recognition System Based on SVM and BP Neural Network [J]. Electronic Science and Technology, 2016, 29(1) : 98-101.