A license plate image processing method
By calculating the extended area and grayscale values of pixel points in the license plate image, dynamically adjusting the window size for local binarization, solving the accuracy of license plate recognition in lighting changes and complex environments, achieving higher recognition accuracy and robustness.
Patent Information
- Application Number
- CN202411195956.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-29
AI Technical Summary
The existing license plate recognition methods have low accuracy in lighting changes and complex environments, especially when shadowed areas and noise are in great influence, resulting in poor recognition results.
By extracting the grayscale image of the license plate area, calculate the extended area and grayscale value of each pixel point, adjust the initial window size, and dynamic adjustment of adaptive window size based on local and global features, local binarization is performed to improve identification accuracy sex.
It effectively reduces the impact of shadow and noise on license plate recognition, improves the accuracy of license plate identification, and is suitable for vehicle management in complex environments.
Smart Images

Figure CN118711192B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a license plate image processing method. Background Art
[0002] The environmental protection intelligent management and control platform is a system that integrates monitoring and governance functions. It is used to monitor and control dust pollution in industrial and mining enterprises and other places to achieve the goals of clean and green transportation. The governance function modules in the platform include a variety of unorganized governance equipment, such as dust collectors, fog cannons, fog curtains, dry fog equipment, cleaning vehicles, car washers, etc., which are used to reduce dust pollution.
[0003] In order to effectively manage and monitor clean transport vehicles to ensure the comprehensiveness and accuracy of clean transport work, the platform needs to schedule and record clean transport vehicles such as sweepers, and display the trajectory of sweepers on maps of each monitoring area through monitoring points. Therefore, it is necessary to accurately identify the license plate of the sweeper. The existing Chinese patent document with announcement number CN110866430B discloses a license plate recognition method and device, which includes: cutting out a license plate area image on the original input image to accurately locate the license plate; extracting character edge information from the image with accurate upper and lower boundaries located based on the edge detection operator to obtain a complete license plate; performing character cutting on the accurately located complete license plate according to the binarization algorithm and connected domain analysis; recognizing the cut characters through a convolutional neural network to obtain a detection result.
[0004] However, when using the above-mentioned traditional binarization algorithm to recognize the license plate of a street sweeper, since the street sweeper works in different environments, there may be changes in lighting and complex backgrounds, which may lead to shadow areas in the license plate image, and it is easy to introduce noise in the environment, such as dust and stains. These factors may affect the effect of license plate recognition. At this time, the accuracy of license plate recognition by the binarization algorithm is low. Summary of the invention
[0005] In order to solve the problem that the accuracy of license plate recognition is low when the license plate area image produces shadows or image noise introduced by the environment, the present invention proposes a license plate image processing method, which specifically adopts the following scheme:
[0006] Extracting a grayscale image of the license plate area, expanding each pixel in the grayscale image to obtain an extended area of the pixel, and determining the possibility of a shadow area of the pixel according to the area of a circumscribed rectangle of the extended area and the grayscale value of the pixel, wherein the possibility of the shadow area is negatively correlated with the area of the circumscribed rectangle and the grayscale value;
[0007] Accumulate the grayscale values of each column of pixel points in the grayscale image to obtain a grayscale cumulative value sequence, and obtain the minimum value points closest to the left and right sides of each maximum value point in the grayscale cumulative value sequence;
[0008] According to the ratio of the prominence of the maximum point to the cumulative value of the prominence of all maximum points, and the horizontal span between the nearest minimum points on the left and right sides of the maximum point, the initial window size of the local binarization is calculated, and the initial window size is positively correlated with the horizontal span and the ratio;
[0009] The initial window size is adjusted according to the possibility of the shadow area to obtain an adaptive window size of the pixel point, and the grayscale image is locally binarized based on the adaptive window size to perform license plate number recognition.
[0010] The above technical solution can preliminarily estimate the size and position of the shadow area in the license plate image by calculating the circumscribed rectangular area of the extended area of each pixel, and quantify the shadow area possibility of the pixel according to the circumscribed rectangular area of the extended area and the grayscale value of the pixel. The darker the grayscale value of the pixel, the more likely it is to be in the shadow area, and the smaller the extended area of the pixel, the more likely it is to be in the shadow area, thereby reducing the possibility of misjudging the shadow area. By accumulating the grayscale values of each column of pixels in the grayscale image to form a grayscale cumulative value sequence, the character width is reflected by the horizontal span between the nearest minimum points on both sides of each maximum point, and the prominence of each maximum point relative to the nearest minimum points on both sides is calculated, and the prominence of the maximum point is calculated. The ratio of the accumulated value of the prominence degree of all maximum points is used as the weight to weight the horizontal span. The larger the weight is, the larger the character width is, and the larger the initial window size is required. In this way, the initial window size related to the license plate character width is obtained, which is helpful to improve the accuracy of character recognition. By combining the initial window size with the local features and global features of each pixel point, the window size used for each pixel point in local binarization is dynamically adjusted, and the local binarization process is optimized. In the local binarization process, windows of different sizes can be used according to pixels with different local features, which reduces the interference of noise and shadows on character details, improves the accuracy of license plate recognition, and facilitates effective management of vehicles.
[0011] Furthermore, the adaptive window size of the pixel point satisfies the following relationship:
[0012] ;
[0013] In the formula, is the grayscale image at Line The adaptive window size of the pixels in the column, is the initial window size, is the maximum grayscale value in the grayscale image, is the maximum grayscale value of all pixels within the initial window size of the pixel, is the gray value of the pixel, is the natural exponential function, , is the maximum and minimum possible values of the shadow areas of all pixels within the initial window size of the pixel, is an odd conversion function.
[0014] The above technical solution can achieve adaptive window size adjustment by considering the difference between the grayscale value of the pixel point and the maximum grayscale value of the local area, as well as the difference in the possibility of shadow area. This means that under different lighting conditions, the window size can be automatically adjusted to adapt to the image characteristics of different areas in the grayscale image and obtain accurate binarization results.
[0015] Furthermore, the method for obtaining the initial window size is:
[0016] A coordinate system is constructed with the serial number of each column as the horizontal coordinate and the cumulative sum of the grayscale values of the pixels in each column as the vertical coordinate, wherein each value of the grayscale cumulative value sequence corresponds to a point in the coordinate system;
[0017] The initial window size is calculated according to the following formula:
[0018]
[0019] In the formula, is the initial window size, is the total number of maximum points in the grayscale cumulative value sequence, is the serial number of the maximum point, , Respectively The maximum point is at the nearest minimum point on the left and right. , They are , The horizontal axis of For the The value of the maximum point, for The numerical value of for The numerical value of For the The ratio of the prominence of a maximum point to the cumulative prominence of all maximum points, is an odd conversion function.
[0020] The above technical solution uses the ratio of the prominence of each maximum point to the cumulative value of the prominence of all maximum points as the weight of the horizontal span, and performs weighted averaging to obtain an initial window size that is suitable for the line width of the character area, thereby improving the accuracy of the local binarization result.
[0021] Furthermore, the initial window size range of the pixel point is centered on the pixel point. The size of the square window.
[0022] Furthermore, the method for obtaining the possibility of the shadow area of the pixel point is:
[0023] Normalize the grayscale value of any pixel in the grayscale image and convert the grayscale value of the pixel to within the interval;
[0024] If the grayscale value of the pixel exceeds the preset grayscale value range, the shadow area possibility of the pixel is ,in, is the grayscale image Line The normalized grayscale value of the pixel in the column; otherwise, the shadow area possibility of the pixel is , For the Line The area of the circumscribed rectangle of the extended area of the pixel points of the column, is the area of the grayscale image, is the width of the grayscale image, is the height of the grayscale image.
[0025] The above technical solution converts the gray value of the pixel into Within the interval, shadow and non-shadow areas can be distinguished more intuitively. By distinguishing pixels in different grayscale value ranges, the accuracy of license plate recognition can be improved, especially when dealing with complex backgrounds, local shadows or lighting changes. By adjusting the possibility of shadow areas according to the area of the extended area, the false alarm rate can be reduced, especially when dealing with pixels with similar grayscale values but not actually in the shadow area.
[0026] Furthermore, the extreme value points in the grayscale cumulative value sequence are obtained by a difference method, and the extreme value points include maximum value points and minimum value points.
[0027] Furthermore, the prominence of the maximum point satisfies the following relationship:
[0028]
[0029] In the formula, For the The prominence of the maximum point, For the The value of the maximum point, for The numerical value of for The numerical value of .
[0030] The prominence calculated by the above technical solution reflects the significance of the maximum point relative to the minimum point nearby. The greater the prominence, the higher the significance of the maximum point in its neighborhood, which reflects the grayscale distribution characteristics of the characters in the license plate image. The prominence of the maximum point can be used to evaluate the width of the license plate characters. Maximum points with high prominence usually correspond to wider character lines, while maximum points with low prominence may correspond to narrower character lines or background areas. Therefore, the area corresponding to the maximum point with high prominence can use a smaller window to capture details, while the area corresponding to the maximum point with low prominence can use a larger window to reduce the impact of noise.
[0031] Further, each pixel in the grayscale image is expanded to obtain an expanded area of the pixel, including:
[0032] Step 1: Taking each pixel as the central pixel, setting the extension area of the central pixel. Initially, the extension area only includes the central pixel itself, and all the adjacent pixels of the central pixel are the pixels to be added.
[0033] Step 2: Among the pixels to be added, the pixels to be added that have the same grayscale value as the central pixel are added to the extended area;
[0034] Step 3: For all newly added pixels in the extended area, obtain their adjacent pixels outside the extended area as new pixels to be added, and continue to execute step 2;
[0035] Step 4: Repeat steps 2 to 3 continuously until the grayscale values of all new pixels to be added are different from the grayscale value of the central pixel, then stop expanding to obtain an extended area of the central pixel, in which the grayscale value of each pixel in the extended area is the same as the grayscale value of the central pixel.
[0036] The above technical solution can accurately identify a set of pixels with the same grayscale value by finding all adjacent pixels with the same grayscale value as the central pixel and adding them to the extended area, which is conducive to accurate recognition of characters in the license plate image.
[0037] Further, locally binarizing the grayscale image based on the adaptive window size to perform license plate number recognition includes:
[0038] For each pixel, a local area is determined using the adaptive window size of the pixel;
[0039] Calculate the mean or median of the grayscale values in the local area as a local threshold;
[0040] Compare each pixel point in the local area with the local threshold, if the gray value of the pixel point is greater than or equal to the local threshold, set the pixel point to white, if the gray value of the pixel point is less than the local threshold, set the pixel point to black, to obtain a binary image;
[0041] The black part in the binary image is the background, and the white part is the license plate number.
[0042] The above technical solution uses an adaptive window size to perform local binarization on the grayscale image, thereby improving the robustness of the local binarization, that is, the license plate number can be accurately recognized even under the influence of noise and local shadows in a complex environment.
[0043] The present invention has the following effects:
[0044] The present invention can effectively quantify the possibility of shadow areas and reduce the possibility of misjudging shadow areas by calculating the circumscribed rectangular area of the extended area and the grayscale value of the pixel points. Different adaptive window sizes are set for different pixels in combination with the possibility of shadow areas to optimize the local binarization process, improve the accuracy of license plate number recognition, and reduce the influence of shadows and noise in the license plate image on license plate recognition. It is suitable for complex environments and can conveniently and effectively manage vehicles based on accurately recognized license plates. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0046] Figure 1 It is a schematic flow chart of the method of the present invention;
[0047] Figure 2 is a schematic diagram of a character E in a grayscale image of a license plate region of the present invention;
[0048] Figure 3 It is a schematic diagram of the maximum and minimum points corresponding to the character E in the grayscale image of the license plate area of the present invention;
[0049] Figure 4 is a schematic diagram of a character O in a grayscale image of a license plate region of the present invention;
[0050] Figure 5 It is a schematic diagram of the maximum and minimum points corresponding to the character O in the grayscale image of the license plate area of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0052] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0053] Reference Figure 1 , a license plate image processing method, including steps S1 to S4, specifically as follows:
[0054] S1: Extract the grayscale image of the license plate area and evaluate the possibility of the shadow area for each pixel in the grayscale image.
[0055] When the cleaning vehicle enters the area to be cleaned, the camera collects the front face image of the cleaning vehicle, and then the semantic segmentation method, template matching method, edge detection method, key point matching method, etc. can be used to extract the image of the license plate area. In order to facilitate subsequent processing, the image of the license plate area is grayscaled to obtain a grayscale image of the license plate area.
[0056] Since the shadows in the license plate area are usually distributed continuously and in patches in the license plate area, that is, the shadows are not randomly scattered on the license plate, but form a coherent area. In addition, no matter where the shadow appears on the license plate, the relative size of the pixel grayscale values at most positions in the area covered by the shadow remains basically unchanged. Based on this feature, it is helpful to preliminarily identify the shadow area by analyzing the difference in the grayscale values of the pixels.
[0057] This step evaluates the shadow area possibility of each pixel in the grayscale image, that is, the possibility of each pixel being in the shadow area is evaluated. The greater the shadow area possibility of a pixel, the more likely it is that the pixel is in the shadow area. Conversely, the smaller the shadow area possibility of a pixel, the more likely it is that the pixel is not in the shadow area. The specific evaluation method is as follows:
[0058] S11: Determine the extended area of each pixel:
[0059] S111: Taking each pixel as a central pixel, setting an extension area of the central pixel. Initially, the extension area only includes the central pixel itself, and all the adjacent pixels (eight neighborhoods) of the central pixel are pixels to be added.
[0060] S112: among the pixels to be added, the pixels to be added having the same grayscale value as the central pixel are added to the extended area. This step is also called performing an extension operation.
[0061] S113: for all the newly added pixels in the extended area, the adjacent pixels outside the extended area are obtained as new pixels to be added, and S112 is continued, that is, the adjacent pixels outside the extended area in the eight neighborhoods of each newly added pixel are obtained, and the adjacent pixels with the same gray value as the central pixel among these adjacent pixels are added to the extended area;
[0062] S114: Continuously repeat the operations of S112-S113 to continuously increase the expansion area of the central pixel until the grayscale values of all new pixels to be added are different from the grayscale value of the central pixel, then stop expanding. At this time, the expansion area of the central pixel is obtained, and the grayscale value of each pixel in the expansion area is the same as that of the central pixel.
[0063] S12: Determine the possibility of the pixel being a shadow area according to the area of the circumscribed rectangle of the extended area and the grayscale value of the pixel.
[0064] S121: Normalize the grayscale value of any pixel in the grayscale image and convert the grayscale value of the pixel to In the grayscale image, Line Taking the pixel points of the column as an example, the specific normalization method of its gray value is:
[0065]
[0066] In the formula, is the grayscale image Line The normalized grayscale value of the pixel in the column, is the gray value of the pixel, is the minimum grayscale value in the grayscale image, is the maximum grayscale value in the grayscale image, and the normalized The value of Within the range.
[0067] Since the effect of the shadow on the license plate area is to darken some areas of the license plate area, The smaller the value, the more likely the corresponding pixel is in the shadow area.
[0068] In the grayscale image of the license plate area, including the character area and the background area, the character area has a larger grayscale value than the background area, and the character area is brighter, while the background area has a smaller grayscale value and is darker than the character area.
[0069] S122: Determine the shadow area possibility of the pixel point.
[0070] The preset gray value range has an upper limit of GC and a lower limit of GF. In this embodiment, GC is set to 0.8 and GF is set to 0.2. The preset gray value range is ;
[0071] when Beyond When, that is When , the shadow area possibility of the pixel is calculated according to the following formula:
[0072]
[0073] In the formula, is the grayscale image Line The probability of the shaded area of the pixel in the column.
[0074] If the background area is covered by shadows, the grayscale value of the background area with a small grayscale value will be reduced, making the background area darker and the grayscale value of the pixels in the background area smaller. When , it means that the smaller the gray value of the pixel, the darker the pixel, and the more likely the pixel is in the background area covered by the shadow. The larger the value, the greater the possibility that the pixel is in the shadow area.
[0075] If the character area is not covered by shadows, the relative difference in grayscale values between the pixels in the background area and the pixels in the character area is greater. When , it means that the pixel has a larger gray value. The brighter the pixel, the more likely it is to be in the character area not covered by the shadow. The smaller the value, the less likely the pixel is to be a shadow.
[0076] when Not exceeded When, that is When , the shadow area of the pixel is likely to be Calculate according to the following formula:
[0077]
[0078] In this formula, For the Line The area of the circumscribed rectangle of the extended area of the pixel points of the column, is the area of the grayscale image, is the width of the grayscale image, is the height of the grayscale image.
[0079] Because when a pixel point may be in the character area covered by the shadow, it may also be in the background area not covered by the shadow. At this time, the gray value of the pixel point is larger than that of the background area covered by the shadow, and smaller than that of the character area not covered by the shadow. That is, when When only through The size of the pixel cannot effectively distinguish the location of the pixel.
[0080] Considering that the character area in the license plate area image is independent, the extended area of the corresponding pixel has a smaller circumscribed rectangular area, while the background area is continuous and the corresponding pixel has a larger circumscribed rectangular area. Therefore, the circumscribed rectangular area of the extended area of each pixel can be calculated to assist in judging whether the pixel is in the character area covered by the shadow. Specifically, the area ratio of the circumscribed rectangle of the extended area of the pixel and the grayscale image is used to determine whether the pixel is in the character area covered by the shadow. A smaller upward correction is made. If the area ratio is larger, it means that the pixel point has a wider extension area, and the pixel point is more likely to be in the background area not covered by the shadow. The smaller the correction degree, the smaller the possibility of the shadow area of the pixel. If the area ratio is smaller, it means that the extended area of the pixel is smaller, and the pixel is more likely to be in the character area covered by the shadow. The larger the upward correction, the more likely the pixel is to be in the shadow area.
[0081] At this point, the method in this step can calculate the shadow area possibility of each pixel in the grayscale image of the license plate area to preliminarily evaluate the position of each pixel.
[0082] S2: Obtain a grayscale cumulative value sequence of the grayscale image, and calculate an initial window size for local binarization according to data features of the grayscale cumulative value sequence.
[0083] In order to improve the accuracy of license plate number recognition, it is necessary to perform local binarization on the grayscale image of the license plate area image. When performing local binarization, the choice of window size is crucial. If the window size is too large, the edges of the license plate characters may be blurred, resulting in loss of character details. If the window size is too small, the local binarization may be too sensitive to noise, affecting the accuracy of character recognition. Therefore, the window size should be adapted to the line width of the character area to ensure that the window contains sufficient background information and character information. Therefore, this step calculates the initial size of the local binarization window based on the distribution of grayscale values of all pixels, hereinafter referred to as the initial size.
[0084] S21: Accumulating the grayscale values of each column of pixels in the grayscale image, the grayscale values of each column of pixels obtain a grayscale accumulated value, and the grayscale values of all columns of pixels obtain a grayscale accumulated value sequence.
[0085] The difference method is used to identify all extreme points in the grayscale cumulative value sequence, including maximum points and minimum points. A coordinate system is constructed with the serial number of each column as the horizontal coordinate and the cumulative sum of the grayscale values of the pixels in each column as the vertical coordinate. Each value of the grayscale cumulative value sequence corresponds to a point in the coordinate system.
[0086] S22: Calculate the initial window size for local binarization.
[0087] For each maximum point in the grayscale cumulative value sequence, the minimum point closest to the left side of the maximum point and the minimum point closest to the right side of the maximum point are obtained, the horizontal coordinate difference between the minimum points closest to the two sides of the maximum point is calculated as the horizontal span between the two nearest minimum points, and the prominence of the maximum point is evaluated, that is, the prominence of the maximum point relative to the minimum points closest to the two sides, and then the cumulative value of the prominence of all the maximum points in the grayscale cumulative value sequence is calculated, and finally, according to the ratio of the prominence of the maximum point and the cumulative value of the prominence, as well as the horizontal span between the minimum points closest to the left and right sides of the maximum point, the initial window size of the local binarization is calculated, and the initial window size is positively correlated with the horizontal span and the ratio.
[0088] The gray value is accumulated in the sequence Take the maximum point as an example, the nearest minimum point on its left is , the nearest minimum point on the left is , then The prominence of the maximum point satisfies the following relationship:
[0089]
[0090] In the formula, For the The prominence of the maximum point, For the The value of the maximum point, for The numerical value of for The value of , in this formula, Indicates the grayscale cumulative value sequence The difference between the maximum point and the nearest minimum point on the left, Indicates the grayscale cumulative value sequence The sum of the difference between the maximum point and the nearest minimum point on the right Reflects the The prominence of a maximum value relative to its nearby values. The larger the value, the The more prominent the maximum value is relative to its neighboring values, the easier it is to calculate by dividing Adjust the value range of this value by , use this formula to characterize the The prominence of a maximum value.
[0091] Calculate the The ratio of the prominence of the maximum point to the cumulative prominence of all maximum points :
[0092]
[0093] In this formula, It is the total number of maximum points in the gray value accumulation sequence.
[0094] Based on the above content, the calculation formula for the local binary window size is:
[0095]
[0096] In this formula, is the initial window size for local binarization, is the total number of maximum points in the grayscale cumulative value sequence, is the serial number of the maximum point, , Respectively The maximum point is at the nearest minimum point on the left and right. , They are , The horizontal axis of is an odd conversion function, , no matter what value the independent variable x takes, The values of are all odd numbers. Indicates The ratio of the prominence of a maximum point to the cumulative prominence of all maximum points.
[0097] In this formula, Indicates The horizontal span between the nearest minimum points on both sides of the maximum point. The larger the horizontal span, the closer the maximum point is. The wider the character line corresponding to the maximum point, the smaller the horizontal span, indicating that the The narrower the character line corresponding to the maximum point (column), in order to include enough background information and character information in the initial window of local binarization, the size of the initial window of local binarization needs to be determined according to the width of the character line. The wider the character line, the larger the initial window size should be. This can ensure that enough background information and character information are included and reduce the influence of noise. The narrower the character line, the smaller the initial window size should be. This can avoid blurring of character details and prevent loss of character area details. Therefore The larger the initial window size, The smaller it is, the smaller the initial window size will be.
[0098] Since different character areas have different grayscale value distributions, combined with Figure 2 , Figure 3 As shown in , the vertical line in the left part of the character area "E" has more high grayscale value pixels, and the corresponding maximum point B1 in the vertical accumulation sequence is more prominent. The nearest minimum points on the left and right sides of the maximum point B1 are A1 and C1, that is, the maximum point B1 is more prominent than the nearest minimum points A1 and C1 on the left and right sides of itself. The horizontal span between the nearest minimum points A1 and C1 on both sides reflects the vertical line width of the left half of "E". Because the vertical line in the left half is the widest among all the line widths of the character area, the overall line width of "E" can be reflected by the horizontal span between A1 and C1. The corresponding window size is set based on the line width to ensure the effect of local binarization.
[0099] Combination Figure 4 , Figure 5As shown in , the character area "O" is usually a symmetrical circle or ellipse, and the vertical lines on its left and right parts have more high grayscale value pixels. The corresponding maximum points in the vertical accumulation sequence are B2 and D2, and the minimum points on the left and right sides of B2 are A2 and C2. The minimum points on the left and right sides of D2 are C2 and E2. B2 is more prominent than A2 and C2 on its two sides, and D2 is more prominent than C2 and E2 on its two sides. The overall line width of the character area "O" can be represented by the horizontal span between A2 and C2, and can also be represented by the horizontal span between C2 and E2. Figure 3 , Figure 5 In the figure, the horizontal axes are the serial numbers (subscripts) of the maximum points, and the vertical axes are the grayscale cumulative values corresponding to the maximum points (the grayscale cumulative values of the columns where the maximum points are located).
[0100] Furthermore, this formula converts The ratio of the prominence of the maximum point to the cumulative prominence of all maximum points , as the weight of the horizontal span between the nearest minimum points on both sides of the maximum point, the horizontal span between the nearest minimum points on both sides of the maximum point is weighted based on the weight. The larger the weight, the more prominent the maximum point is, and the more likely it is that the horizontal span between the nearest minimum points on both sides of the maximum point is the character line width. Conversely, the smaller the weight, the less prominent the maximum point is, and the less likely it is that the horizontal span between the nearest minimum points on both sides of the maximum point is the character line width.
[0101] Furthermore, the formula performs weighted average of the lateral span between the nearest minimum points on both sides of all maximum points and the above weights, and the obtained value is used as the overall line width of the character area in the grayscale image of the license plate area. The wider the overall line width, the larger the window should be used to reduce the influence of noise while ensuring that the window contains sufficient background information and character information to calculate the local threshold. The narrower the overall line width, the smaller the window should be used to avoid blurring of character details. At the same time, in order to facilitate the selection of the window center point, the initial window size is converted to an odd number through an odd conversion function.
[0102] S3: Using the shadow area possibility of each pixel, the initial window size is adjusted to obtain an adaptive window size for each pixel.
[0103] In order to improve the accuracy of license plate recognition, it is necessary to dynamically adjust the initial window size according to the structure of the license plate characters, background differences and the influence of shadows. This is because there may be large differences between the character area and the background area of the license plate, and the shadow will also affect the license plate area, resulting in better local binarization effects in some areas according to the initial window size, while poor local binarization effects in other areas. Therefore, it is necessary to adjust the window size used for each pixel according to the local and global features of the grayscale image of the license plate area.
[0104] The specific steps are as follows:
[0105] Analyze local features and global features: By analyzing the local features of each pixel within the initial window size range (such as the grayscale value distribution of the pixel, edge information, etc.) and the global features of the grayscale image of the license plate area (such as the overall grayscale distribution, character line width, etc.), the position of the pixel in the grayscale image of the license plate area relative to the character area and background area can be determined.
[0106] Determine the area where the pixel is located: By combining the local features of each pixel within the initial window size range with the global features of the grayscale image, the area where the pixel is located (character area, background area or shadow area) can be determined.
[0107] Adjust window size: Calculate the window size of each pixel when performing local binarization. For pixels in different areas, use different window sizes to optimize the local binarization results.
[0108] In order to ensure that the local binarization processing can adapt to the differences between the character area and the background area in the grayscale image, as well as the influence of the shadow area, this step dynamically adjusts the window size used for each pixel during local binarization to obtain an adaptive window size for each pixel to improve the accuracy of license plate recognition.
[0109] The adaptive window size of the pixel point satisfies the following relationship:
[0110]
[0111] In the formula, is the grayscale image at Line The adaptive window size of the pixels in the column, is the initial window size, is the maximum grayscale value in the grayscale image, is the maximum grayscale value of all pixels within the initial window size of the pixel, is the gray value of the pixel, is the natural exponential function, , is the maximum and minimum possible values of the shadow areas of all pixels within the initial window size of the pixel, is an odd-number conversion function, the initial window size range of the pixel point is centered on the pixel point, The size of the square window.
[0112] In this formula, is the grayscale image at Line The difference between the grayscale value of the pixel point in the column and the maximum grayscale value within the initial window size range of the pixel point. The larger the value, the more likely the pixel point is to be in the background area containing noise. A larger window should be used to reduce the impact of noise on local binarization and ensure the stability of the background area. The threshold obtained by the grayscale value of the pixel point in the window is more conducive to distinguishing the background area from the character area during the local binarization process. The smaller the value, the more likely the pixel point is to be inside the character area or the background area. A smaller window should be used to retain the details of the character edge. At the same time, it also prevents the situation where the window size that does not contain noise contains noise. At the same time, in order to facilitate calculation, the window size is divided by 255. Normalization is performed. The larger the normalized value is, the larger the window used by the pixel is. The smaller the value is, the smaller the window used by the pixel is.
[0113] In this formula, Indicates the grayscale image at Line The difference between the maximum grayscale value within the initial window size range of the pixel point of the column and the maximum grayscale value in the grayscale image. The smaller the value, the more likely the pixel point is in the character area. A smaller window should be used to more finely capture the details of the edge of the character, so as to ensure the clarity and integrity of the character outline. The larger the value, the more likely the pixel point is in the background area. A larger window should be used to comprehensively consider the pixel information in a larger range, so as to better eliminate the influence of shadows and noise on binarization. At the same time, in order to facilitate calculation, the normalization operation is performed by dividing by 255. The larger the normalized value, the larger the window used by the pixel point, and the smaller the value, the smaller the window used by the pixel point.
[0114] In this formula, is the grayscale image at Line The maximum difference between the shadow area possibilities of all pixels within the initial window size range of the pixel points of the column (calculated in step S1). The larger the value, the more likely the pixel point is to be at the edge of the shadow area and the area not covered by the shadow. A smaller window should be used to flexibly adapt to the grayscale changes at the edge of the shadow area. The smaller the value, the more likely the pixel point is to be inside the shadow area or inside the area not covered by the shadow. A larger window should be used to better smooth the grayscale changes, reduce the influence of noise, and make the binarization result more stable.
[0115] S4: Local binarization based on adaptive window size of all pixels for license plate recognition.
[0116] For each pixel, a local area corresponding to the pixel is determined according to the adaptive window size of the pixel, with the pixel as the center, and the mean or median of the grayscale value in the local area is calculated as the local threshold. In this embodiment, the mean grayscale value is used as the local threshold;
[0117] Each pixel point in the local area is compared with the local threshold. If the grayscale value of the pixel point is greater than or equal to the local threshold, the pixel point is set to white. If the grayscale value of the pixel point is less than the local threshold, the pixel point is set to black to obtain a final binary image. The black part in the binary image is the background, and the white part is the license plate number. In this way, the license plate number is accurately identified. After the license plate number is identified, the cleaning vehicle can be accurately and effectively monitored and managed.
[0118] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0119] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A license plate image processing method, characterized in that: include: Extracting a grayscale image of the license plate area, expanding each pixel in the grayscale image to obtain an extended area of the pixel, and determining the possibility of a shadow area of the pixel according to the area of a circumscribed rectangle of the extended area and the grayscale value of the pixel, wherein the possibility of the shadow area is negatively correlated with the area of the circumscribed rectangle and the grayscale value; Accumulate the grayscale values of each column of pixel points in the grayscale image to obtain a grayscale cumulative value sequence, and obtain the minimum value points closest to the left and right sides of each maximum value point in the grayscale cumulative value sequence; According to the ratio of the prominence of the maximum point to the cumulative value of the prominence of all maximum points, and the horizontal span between the nearest minimum points on the left and right sides of the maximum point, the initial window size of the local binarization is calculated, and the initial window size is positively correlated with the horizontal span and the ratio; The initial window size is adjusted by using the possibility of the shadow area to obtain an adaptive window size of the pixel point, and the grayscale image is locally binarized based on the adaptive window size to perform license plate number recognition; The adaptive window size of the pixel point satisfies the following relationship: ; In the formula, is the grayscale image at Line The adaptive window size of the pixels in the column, is the initial window size, is the maximum grayscale value in the grayscale image, is the maximum grayscale value of all pixels within the initial window size of the pixel, is the gray value of the pixel, is the natural exponential function, , is the maximum and minimum possible values of the shadow areas of all pixels within the initial window size of the pixel, is an odd conversion function; The method for obtaining the initial window size is: A coordinate system is constructed with the serial number of each column as the horizontal coordinate and the cumulative sum of the grayscale values of the pixels in each column as the vertical coordinate, wherein each value of the grayscale cumulative value sequence corresponds to a point in the coordinate system; The initial window size is calculated according to the following formula: ;In the formula, is the initial window size, is the total number of maximum points in the grayscale cumulative value sequence, is the serial number of the maximum point, , Respectively The maximum points are at the nearest minimum points on the left and right sides. , They are , The horizontal axis of For the The ratio of the prominence of a maximum point to the cumulative prominence of all maximum points, is an odd conversion function; The method for obtaining the possibility of the shadow area of the pixel point is: normalizing the grayscale value of any pixel point in the grayscale image, converting the grayscale value of the pixel point to If the gray value of the pixel exceeds the preset gray value range, the shadow area possibility of the pixel is ,in, is the grayscale image Line The normalized grayscale value of the pixel in the column; otherwise, the shadow area possibility of the pixel is , For the Line The area of the circumscribed rectangle of the extended area of the pixel points of the column, is the area of the grayscale image, is the width of the grayscale image, is the height of the grayscale image.
2. The license plate image processing method according to claim 1, characterized in that: The initial window size range of the pixel point is centered on the pixel point. The size of the square window.
3. The license plate image processing method according to claim 1, characterized in that: The extreme value points in the grayscale cumulative value sequence are obtained by a difference method, and the extreme value points include a maximum value point and a minimum value point.
4. The license plate image processing method according to claim 1, characterized in that: The prominence of the maximum point satisfies the following relationship: ; In the formula, For the The prominence of the maximum point, For the The value of the maximum point, for The numerical value of for The numerical value of .
5. The license plate image processing method according to claim 1, characterized in that: Expanding each pixel in the grayscale image to obtain an expanded area of the pixel includes: Step 1: Taking each pixel as the central pixel, setting the extension area of the central pixel. Initially, the extension area only includes the central pixel itself, and all the adjacent pixels of the central pixel are the pixels to be added. Step 2: Among the pixels to be added, the pixels to be added that have the same grayscale value as the central pixel are added to the extended area; Step 3: For all newly added pixels in the extended area, obtain their adjacent pixels outside the extended area as new pixels to be added, and continue to execute step 2; Step 4: Repeat steps 2 to 3 continuously until the grayscale values of all new pixels to be added are different from the grayscale value of the central pixel, then stop expanding to obtain an extended area of the central pixel, in which the grayscale value of each pixel in the extended area is the same as the grayscale value of the central pixel.
6. The license plate image processing method according to claim 1, characterized in that: Locally binarizing the grayscale image based on the adaptive window size to perform license plate number recognition, including: For each pixel, a local area is determined using the adaptive window size of the pixel; Calculate the mean or median of the grayscale values in the local area as a local threshold; Compare each pixel point in the local area with the local threshold. If the grayscale value of the pixel point is greater than or equal to the local threshold, set the pixel point to white. If the grayscale value of the pixel point is less than the local threshold, set the pixel point to black to obtain a binary image, in which the black part is the background and the white part is the license plate number.
