Intelligent identification method of electric vehicle entry based on secondary AI algorithm
Image enhancement in electric vehicle home intelligent recognition technology is carried out through secondary AI algorithms, which solves the problem of recognition accuracy caused by poor image quality and achieves higher recognition accuracy and detail retention.
Patent Information
- Application Number
- CN202411082897.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-08-08
AI Technical Summary
Existing intelligent recognition technology for electric vehicles entering homes can easily lead to high misrecognition and omission rates when the image quality is poor, and the traditional histogram equalization method cannot effectively retain or highlight the key features of electric vehicles, affecting the recognition accuracy.
Using a method based on the secondary AI algorithm, image enhancement is performed by detecting the gray level distribution of the grayscale image, including gray level mapping, noise smoothing, sub-histogram construction and adjustment, and segmented equalization processing to ensure that image details are retained. and reduce noise introduction.
It improves the accuracy of electric vehicle entry recognition. Through effective image enhancement technology, it enhances the layering and detail expression of the image, reduces the misrecognition rate and omission rate, and ensures the accurate detection of electric vehicle characteristics.
Smart Images

Figure CN118609063B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an intelligent recognition method for electric vehicle entry based on a secondary AI algorithm. Background Art
[0002] In the context of the rapid development of intelligent technology, electric vehicle entry intelligent recognition technology is an emerging application that aims to identify and track the entry and exit of electric vehicles by automatically analyzing images. However, when the image quality is poor, details in the image will be lost, making it difficult to accurately capture the characteristics of the electric vehicle, and increasing the difficulty of the recognition algorithm to parse the image. In this case, directly using the original image for electric vehicle entry intelligent recognition often leads to high misrecognition and omission rates.
[0003] Existing methods usually use histogram equalization for image enhancement. However, since histogram equalization is based on the pixel statistical information of the entire image, it does not consider the contextual information around the pixel points. A uniform adjustment of a single grayscale level will cause the local contrast of some areas to be weakened or over-enhanced, which will lead to a decrease in image quality in these areas. In addition, histogram equalization has the phenomenon of grayscale merging. Therefore, traditional methods cannot better retain or highlight the key features of electric vehicles. When the intelligent recognition algorithm is used for electric vehicle home recognition in the subsequent process, it will still affect the recognition accuracy. Therefore, it is necessary to further use secondary AI methods to enhance the image on the basis of ensuring the image details. To ensure the accuracy of electric vehicle home recognition is a problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides an intelligent electric vehicle entry recognition method based on a secondary AI algorithm to solve the problem of using a secondary AI method to achieve image enhancement while ensuring image details to ensure the accuracy of electric vehicle entry recognition.
[0005] An embodiment of the present invention provides an electric vehicle entry intelligent recognition method based on a secondary AI algorithm, the method comprising the following steps:
[0006] When an electric vehicle enters a house, a grayscale image of the electric vehicle is obtained, and according to the grayscale distribution in the grayscale image, whether the grayscale image needs to be enhanced;
[0007] If it is detected that the grayscale image needs to be enhanced, each grayscale level in the grayscale image is mapped to obtain a corresponding mapped grayscale level, and each mapped grayscale level is adjusted according to a difference between adjacent mapped grayscale levels to obtain an adjusted mapped grayscale level;
[0008] performing noise smoothing on the grayscale image according to all adjusted mapped grayscale levels to obtain a first grayscale image, dividing the first grayscale image into N regions, and constructing a first sub-histogram and a second sub-histogram according to a contrast difference between each region and its adjacent regions;
[0009] Each grayscale level in the first sub-histogram and the second sub-histogram is adjusted respectively to obtain an adjusted first sub-histogram and an adjusted second sub-histogram respectively, an image-enhanced grayscale image is obtained according to the adjusted first sub-histogram and the adjusted second sub-histogram, and the electric vehicle is identified as entering a house according to the image-enhanced grayscale image.
[0010] Preferably, the detecting whether the grayscale image needs to be enhanced according to the grayscale distribution in the grayscale image comprises:
[0011] Constructing a grayscale histogram of the grayscale image, obtaining the grayscale difference between every two adjacent grayscale levels whose occurrence probability is not 0 in the grayscale histogram, and obtaining the mean of the grayscale differences as the grayscale interval mean;
[0012] Counting the number of gray levels with a non-zero probability of appearing in the gray histogram, and calculating the ratio between the number of gray levels and the total number of gray levels within the gray range as the overall average gray interval;
[0013] A first ratio between the grayscale interval mean and the overall average grayscale interval is calculated. If the first ratio is less than a preset value, it is determined that the grayscale image needs to be enhanced. If the first ratio is not less than the preset value, it is determined that the grayscale image does not need to be enhanced.
[0014] Preferably, mapping each grayscale level in the grayscale image to obtain a corresponding mapped grayscale level comprises:
[0015] For any gray level in the grayscale histogram, the cumulative value of the occurrence probability of each gray level before the gray level and the occurrence probability of the gray level is calculated as the cumulative occurrence probability of the gray level, and the product of the maximum gray level and the cumulative occurrence probability of the gray level is taken as the mapping gray level corresponding to the gray level.
[0016] Preferably, adjusting each of the mapped gray levels according to the difference between adjacent mapped gray levels to obtain the adjusted mapped gray level includes:
[0017] For any mapped gray level, obtain the previous mapped gray level of the mapped gray level, count at least one gray level corresponding to the previous mapped gray level to obtain a first maximum gray level, count at least one gray level corresponding to the mapped gray level to obtain a second maximum gray level;
[0018] Obtaining a first difference between the first maximum gray level and the second maximum gray level, obtaining a j-th gray level corresponding to the mapped gray level, obtaining a second difference between the j-th gray level and the first maximum gray level, and calculating a difference ratio between the first difference and the second difference;
[0019] A third difference between the mapped gray level and the previous mapped gray level is obtained to obtain a product between the third difference and the difference ratio, and a sum of the product and the mapped gray level is used as the adjusted mapped gray level of the j-th gray level.
[0020] Preferably, performing noise smoothing on the grayscale image according to all adjusted mapped grayscale levels to obtain a first grayscale image, and dividing the first grayscale image into N regions comprises:
[0021] For any adjusted mapping gray level, obtaining a binary image of the adjusted mapping gray level, clustering all pixels in the binary image to obtain at least one clustering region and an isolated point;
[0022] Taking each isolated point in the binary image corresponding to the adjusted mapped grayscale as a noise point, obtaining the grayscale mean of the pixels in the neighborhood of each noise point to replace the grayscale value of the corresponding noise point, and obtaining a first grayscale image;
[0023] According to the coordinates of each noise point in the first grayscale image, each noise point is divided into a corresponding clustering area to obtain N final clustering areas, and one final clustering area is regarded as a region.
[0024] Preferably, constructing the first sub-histogram and the second sub-histogram according to the contrast difference between each of the regions and its adjacent regions comprises:
[0025] For any region in the first grayscale image, calculating an absolute value of a difference between an adjusted mapped grayscale level corresponding to the region and an adjusted mapped grayscale level corresponding to any other region as a contrast ratio between the region and the other region;
[0026] According to the contrast between every two regions in the first grayscale image, an average contrast is obtained, and if the contrast between any two regions is greater than or equal to the average contrast, a first sub-histogram is constructed using the adjusted mapped grayscale levels corresponding to all pixels in the two regions;
[0027] If the contrast between any two regions is less than the average contrast, a second sub-histogram is constructed using the adjusted mapped gray levels corresponding to all pixels in the two regions.
[0028] Preferably, the adjusting each gray level in the first sub-histogram and the second sub-histogram respectively to obtain an adjusted first sub-histogram and an adjusted second sub-histogram accordingly comprises:
[0029] Detecting whether the first sub-histogram and the second sub-histogram have the same gray level, and if it is detected that the first sub-histogram and the second sub-histogram have the same gray level, taking the same gray level as a stable gray level;
[0030] For any sub-histogram of the first sub-histogram and the second sub-histogram, taking any gray level in the sub-histogram as a target gray level, if the target gray level is greater than a maximum stable gray level among the stable gray levels or less than a minimum stable gray level among the stable gray levels, determining at least one region involved in the target gray level in the first gray image as a target region;
[0031] Acquire the contrast between the target area and each other area in the first grayscale image, obtain the contrast mean as the regional contrast, calculate the average value of the regional contrasts corresponding to all target areas as the overall contrast of the target grayscale, obtain the average overall contrast according to the overall contrast of each grayscale in the first grayscale image, calculate the contrast difference between the average overall contrast and the overall contrast of the target grayscale, and obtain the contrast ratio between the contrast difference and the overall contrast of the target grayscale;
[0032] Obtaining a reference grayscale of the target grayscale, calculating a grayscale difference between the target grayscale and the reference grayscale, obtaining an adjustment coefficient according to the type of the sub-histogram, obtaining a multiplication result between the contrast ratio, the grayscale difference and the adjustment coefficient, and using the difference between the multiplication result and the target grayscale as a grayscale adjustment result of the target grayscale;
[0033] If the target gray level is between any two stable gray levels, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of the target gray level using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of the target gray level, and obtain a grayscale adjustment result of the target gray level;
[0034] The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
[0035] Preferably, the obtaining of a reference grayscale of the target grayscale includes:
[0036] According to the grayscale difference between the target grayscale and each of the stable grayscales, obtaining the stable grayscale corresponding to the minimum grayscale difference as the nearest stable grayscale of the target grayscale;
[0037] If there are no other gray levels between the target gray level and the most recent stable gray level, the most recent stable gray level is used as a reference gray level for the target gray level; if there are other gray levels between the target gray level and the most recent stable gray level, the other gray levels closest to the target gray level are used as reference gray levels for the target gray level.
[0038] Preferably, after detecting whether the first sub-histogram and the second sub-histogram have the same gray level, the method further includes:
[0039] If it is detected that the first sub-histogram and the second sub-histogram do not have the same gray level, obtaining the maximum gray level and the minimum gray level between the first sub-histogram and the second sub-histogram as stable gray levels;
[0040] For any sub-histogram of the first sub-histogram and the second sub-histogram, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of each gray level in the sub-histogram using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of each gray level in the sub-histogram, and obtain a grayscale adjustment result of each gray level in the sub-histogram;
[0041] The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
[0042] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0043] When an electric vehicle enters a residence, the present invention obtains a grayscale image of the electric vehicle, and detects whether the grayscale image needs to be enhanced according to the grayscale distribution in the grayscale image; if it is detected that the grayscale image needs to be enhanced, each grayscale in the grayscale image is mapped respectively to obtain a corresponding mapped grayscale, and each mapped grayscale is adjusted according to the difference between adjacent mapped grayscales to obtain an adjusted mapped grayscale; noise smoothing is performed on the grayscale image according to all adjusted mapped grayscales to obtain a first grayscale image, and the first grayscale image is divided into N regions, and a first sub-histogram and a second sub-histogram are constructed according to the contrast difference between each region and its adjacent regions; each grayscale in the first sub-histogram and the second sub-histogram is adjusted respectively to obtain an adjusted first sub-histogram and an adjusted second sub-histogram, and an image-enhanced grayscale image is obtained according to the adjusted first sub-histogram and the adjusted second sub-histogram, and the entry recognition of the electric vehicle is performed according to the image-enhanced grayscale image. Among them, by removing noise from the grayscale image and dividing the regions, the histograms of high-contrast regions and low-contrast regions are constructed according to the contrast differences between the regions, so as to avoid excessive enhancement of the global histogram equalization, and then the grayscale level of the position interval of each grayscale level in each histogram is adjusted respectively to obtain the grayscale image after image enhancement. By performing segmented equalization on the high-contrast region, the contrast enhancement amplitude within each equalization range is limited, the details are effectively retained and the introduction of noise is reduced, and the visual unnaturalness caused by excessive enhancement is avoided; the low-contrast region is segmentedly equalized to enhance the local contrast so that the hidden details can be displayed, thereby enhancing the layering and detail expression of the image. Therefore, when the electric vehicle entry recognition is performed according to the grayscale image after image enhancement, the details and characteristics of the electric vehicle itself can be more effectively detected, thereby improving the accuracy of electric vehicle entry recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1 This is a method flow chart of an electric vehicle entry intelligent identification method based on a secondary AI algorithm provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0046] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0047] It should be noted that the terms "first", "second", etc. in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0048] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.
[0049] See also Figure 1 , is a method flow chart of an electric vehicle entry intelligent identification method based on a secondary AI algorithm provided in the first embodiment of the present invention, such as Figure 1 As shown, the method may include:
[0050] Step S101, when an electric vehicle enters a house, a grayscale image of the electric vehicle is obtained, and according to the grayscale distribution in the grayscale image, it is detected whether the grayscale image needs to be enhanced.
[0051] When the grayscale histogram of the collected image is dark or bright, the grayscale distribution in the grayscale histogram will be relatively concentrated. Therefore, in the embodiment of the present invention, when the electric vehicle enters the house, the image of the electric vehicle is collected, and the image is grayed to obtain a corresponding grayscale image, and then an initial judgment is made based on the grayscale distribution in the grayscale image, that is, based on the grayscale distribution in the grayscale image, whether the grayscale image needs to be enhanced is detected. The specific judgment method is:
[0052] Constructing a grayscale histogram of the grayscale image, obtaining the grayscale difference between every two adjacent grayscale levels whose occurrence probability is not 0 in the grayscale histogram, and obtaining the mean of the grayscale differences as the grayscale interval mean;
[0053] Counting the number of gray levels with a non-zero probability of appearing in the gray histogram, and calculating the ratio between the number of gray levels and the total number of gray levels within the gray range as the overall average gray interval;
[0054] A first ratio between the grayscale interval mean and the overall average grayscale interval is calculated. If the first ratio is less than a preset value, it is determined that the grayscale image needs to be enhanced. If the first ratio is not less than the preset value, it is determined that the grayscale image does not need to be enhanced.
[0055] In one embodiment, a grayscale histogram of a grayscale image is constructed, wherein the horizontal axis of the grayscale histogram is the grayscale level and the vertical axis is the probability of occurrence of the grayscale level. The intervals between adjacent grayscale levels in the grayscale histogram are calculated, and the adjacent grayscale levels are all grayscale levels with a probability of occurrence that is not 0, that is, for two adjacent grayscale levels with a probability of occurrence that is not 0, the grayscale difference between the latter grayscale level and the former grayscale level is the interval between the two adjacent grayscale levels, and the average value of the intervals between all adjacent grayscale levels is calculated as the grayscale interval mean value A of the grayscale histogram. The number of grayscale levels with a probability of occurrence that is not 0 in the grayscale histogram is obtained, and then the ratio between 256 and the obtained number of grayscale levels is calculated, and the obtained ratio is used as the overall average grayscale interval B of the grayscale image.
[0056] The ratio between the grayscale interval mean A and the overall average grayscale interval B is calculated. If the ratio is less than 1, it is considered that the intervals between adjacent grayscale levels in the grayscale histogram are small, the grayscale distribution is relatively concentrated, the image quality is poor, and image enhancement is required; if the ratio is not less than 1, it is considered that the intervals between grayscale levels in the grayscale histogram are large, the contrast between grayscale levels is high, the quality of the corresponding grayscale image is also high, and image enhancement is not required.
[0057] Step S102, if it is detected that the grayscale image needs to be enhanced, each grayscale level in the grayscale image is mapped respectively to obtain a corresponding mapped grayscale level, and each mapped grayscale level is adjusted according to the difference between adjacent mapped grayscale levels to obtain a corresponding adjusted mapped grayscale level.
[0058] If it is detected that the grayscale image needs to be enhanced, the traditional histogram equalization method maps the original grayscale levels in the grayscale histogram of the grayscale image according to the cumulative distribution probability. The specific mapping process is:
[0059] For any gray level in the grayscale histogram, the cumulative value of the occurrence probability of each gray level before the gray level and the occurrence probability of the gray level is calculated as the cumulative occurrence probability of the gray level, and the product of the maximum gray level and the cumulative occurrence probability of the gray level is taken as the mapping gray level corresponding to the gray level.
[0060] In one embodiment, the calculation expression for the mapped gray level corresponding to the i-th gray level in the gray histogram is:
[0061]
[0062] in, is the mapped gray level of the i-th gray level; L is the total number of gray levels, which is 256 in this embodiment, is the occurrence probability of the kth gray level in the grayscale histogram.
[0063] Similarly, the mapping grayscale of each grayscale level in the grayscale histogram is obtained. It should be noted that the secondary AI algorithm of the embodiment of the present invention refers to further optimizing the grayscale mapping result in the histogram equalization method, so that the features of each grayscale level in the grayscale image and the corresponding area of each grayscale level can complete the image enhancement on the basis of retaining the image details, wherein the mapping results of each grayscale level are adjusted to meet the image enhancement requirements (this is the first AI algorithm), and the enhanced image is subsequently input into the neural network for electric vehicle entry recognition (this is the second AI algorithm).
[0064] Based on the above characteristics, in an embodiment of the present invention, each mapped gray level is adjusted according to the difference between adjacent mapped gray levels, and the adjusted mapped gray level is obtained accordingly. The specific adjustment method is:
[0065] For any mapped gray level, obtain the previous mapped gray level of the mapped gray level, count at least one gray level corresponding to the previous mapped gray level to obtain a first maximum gray level, count at least one gray level corresponding to the mapped gray level to obtain a second maximum gray level;
[0066] Obtaining a first difference between the first maximum gray level and the second maximum gray level, obtaining a j-th gray level corresponding to the mapped gray level, obtaining a second difference between the j-th gray level and the first maximum gray level, and calculating a difference ratio between the first difference and the second difference;
[0067] A third difference between the mapped gray level and the previous mapped gray level is obtained to obtain a product between the third difference and the difference ratio, and a sum of the product and the mapped gray level is used as the adjusted mapped gray level of the j-th gray level.
[0068] In one embodiment, since histogram equalization merges gray levels with lower probability of occurrence, when the same mapped gray level corresponds to multiple gray levels in the gray histogram, it means that these gray levels will be mapped to gray levels of the same size, thereby causing loss of image details. For example, a gray level of 5 corresponds to a mapped gray level of 6, and a gray level of 4 corresponds to a mapped gray level of 6. Therefore, an embodiment of the present invention adjusts the corresponding mapped gray levels according to the interval ratio relationship between the gray levels in these gray histograms to avoid loss of image details while ensuring the gray level change relationship of the image.
[0069] Take a mapping grayscale as an example, assuming that the mapping grayscale is , mapping gray levels The previous mapped gray level is , if the gray level is mapped The gray levels in the corresponding grayscale histogram are as follows from small to large: , the previous mapping gray level The maximum gray level among all gray levels in the corresponding gray level histogram is d. It should be noted that if the previous mapping gray level When there are multiple gray levels in the corresponding gray histogram, d is the maximum gray level among these gray levels. When there is one gray level in the corresponding gray level histogram, d is the corresponding gray level. The corresponding j-th gray level uses the j-th gray level to adjust the mapping gray level , the calculation expression of the corresponding adjusted mapping gray level is obtained as:
[0070]
[0071] in, represents the adjusted mapped gray level of the jth gray level in the gray level histogram, Represents the mapped gray level of the jth gray level in the gray histogram, that is, the mapped gray level before adjustment, Represents the previous mapped gray level of the mapped gray level of the j-th gray level in the gray level histogram, represents the jth gray level in the grayscale histogram, Represents the grayscale mapping The maximum grayscale level of all grayscale levels in the corresponding grayscale histogram, d represents the previous mapped grayscale level The maximum gray level among all gray levels in the corresponding gray level histogram.
[0072] Similarly, according to the gray levels in the multiple gray histograms corresponding to the mapped gray levels, the adjusted mapped gray levels of each gray level in the gray histogram are respectively obtained, that is, each adjusted mapped gray level corresponds one-to-one to each gray level in the gray histogram.
[0073] At this point, the adjusted mapped gray level of each gray level in the gray histogram is obtained.
[0074] Step S103, performing noise smoothing on the grayscale image according to all adjusted mapped grayscale levels to obtain a first grayscale image, dividing the first grayscale image into N regions, and constructing a first sub-histogram and a second sub-histogram according to the contrast difference between each region and its adjacent regions.
[0075] Since global histogram equalization is based on the pixel statistics of the entire image, it does not consider the contextual information around the pixel points. It uniformly adjusts the single gray level, which may weaken the local contrast of some areas, and reduce the image quality of these areas. That is, the improvement of the contrast of the entire image is at the expense of the local contrast. For example, some features of electric vehicles, such as the front, rear or lights, have unreal shapes and contours after global histogram equalization, resulting in misidentification when performing electric vehicle entry recognition. Secondly, if the global histogram equalization is over-enhanced, it will cause image distortion, especially when the brightness difference between the electric vehicle and the background is not large. If the electric vehicle area is over-enhanced, its edges and details become very prominent, which will cause some background areas to be mistakenly identified as electric vehicles during the electric vehicle entry recognition process. Therefore, in an embodiment of the present invention, the grayscale image is first noise-smoothed according to all adjusted mapped grayscale levels to obtain a first grayscale image, the first grayscale image is divided into N regions, and then a first sub-histogram and a second sub-histogram are constructed according to the contrast difference between each region and its adjacent regions. It should be noted that the first sub-histogram and the second sub-histogram are constructed by dividing the image into high-contrast regions and low-contrast regions, and are used for adaptive segmented equalization.
[0076] The grayscale image is noise-smoothed according to all adjusted mapped grayscale levels to obtain a first grayscale image, and the first grayscale image is divided into N regions, including:
[0077] For any adjusted mapping gray level, obtaining a binary image of the adjusted mapping gray level, clustering all pixels in the binary image to obtain at least one clustering region and an isolated point;
[0078] Taking each isolated point in the binary image corresponding to the adjusted mapped grayscale as a noise point, obtaining the grayscale mean of the pixels in the neighborhood of each noise point to replace the grayscale value of the corresponding noise point, and obtaining a first grayscale image;
[0079] According to the coordinates of each noise point in the first grayscale image, each noise point is divided into a corresponding clustering area to obtain N final clustering areas, and one final clustering area is regarded as a region.
[0080] In one embodiment, the pixel points corresponding to each adjusted mapping level are obtained in the grayscale image, and the binary images corresponding to each adjusted mapping grayscale are obtained, wherein the pixel points belonging to the mapping grayscale in the binary image are marked as 1, and the pixel points not belonging to the mapping grayscale are marked as 0. For any binary image, the DBSCAN clustering algorithm is used to cluster the pixels in the binary image to obtain multiple clustering results, each clustering result corresponds to a region, wherein the DBSCAN clustering algorithm belongs to the prior art and is not described here. The same processing is performed on each binary image to obtain the region corresponding to each adjusted mapping grayscale. At this point, the entire grayscale image is divided into a number of regions with different grayscales, and each adjusted mapping grayscale corresponds to multiple regions.
[0081] Since global histogram equalization needs to process each pixel in the image, when there is noise in the grayscale image, global histogram equalization will also enhance the noise and affect the image quality. Noise appears in the image as isolated points that appear randomly and have a large grayscale difference with the surrounding pixels. The DBSCAN clustering algorithm will not classify noise points into any cluster. Therefore, in the embodiment of the present invention, the pixel points that are not divided into clusters in the binary image are considered to be noise points, and the corresponding pixel points are found in the grayscale image according to the coordinates of the noise points. The grayscale average value of the pixels in its eight neighborhoods is used as the corrected grayscale value of the pixel point, and the pixel point is classified into the corresponding area according to the grayscale corrected pixel coordinates, thereby eliminating the interference of noise points in the grayscale image and obtaining a first grayscale image. At this time, the first grayscale image is divided into multiple areas.
[0082] According to the contrast difference between each region and its adjacent regions, a first sub-histogram and a second sub-histogram are constructed, including:
[0083] For any region in the first grayscale image, calculating an absolute value of a difference between an adjusted mapped grayscale level corresponding to the region and an adjusted mapped grayscale level corresponding to any other region as a contrast ratio between the region and the other region;
[0084] According to the contrast between every two regions in the first grayscale image, an average contrast is obtained, and if the contrast between any two regions is greater than or equal to the average contrast, a first sub-histogram is constructed using the adjusted mapped grayscale levels corresponding to all pixels in the two regions;
[0085] If the contrast between any two regions is less than the average contrast, a second sub-histogram is constructed using the adjusted mapped gray levels corresponding to all pixels in the two regions.
[0086] In one embodiment, if the grayscale difference between different areas is uniform, that is, the light and dark contrast between the various parts of the image is natural, and there is no obvious overly bright or overly dark area, it means that the contrast of the image is relatively appropriate at this time. In this embodiment of the present invention, the first grayscale image is divided into high-contrast areas and low-contrast areas according to the contrast difference between each area in the first grayscale image, thereby constructing a grayscale histogram of each contrast area.
[0087] Taking the i-th region in the first grayscale image as an example, obtain the contrast between the i-th region and each other region in the first grayscale image, where the contrast refers to the absolute value of the difference between the adjusted mapped grayscale levels corresponding to the two regions. Similarly, obtain the contrast between every two regions in the first grayscale image, and calculate the average contrast of all contrasts as the overall contrast of the first grayscale image. Obtain all regions with contrast greater than or equal to the average contrast, and the grayscale histogram composed of the adjusted mapped grayscale levels corresponding to all pixels in these regions is called the first sub-histogram, that is, if the contrast between two regions is greater than or equal to the average contrast, the adjusted mapped grayscale levels corresponding to all pixels in these two regions participate in the composition of the first sub-histogram; similarly, the grayscale histogram composed of the adjusted mapped grayscale levels corresponding to all pixels in all regions with contrast less than the average contrast is called the second sub-histogram.
[0088] So far, a first sub-histogram of a high contrast area and a second sub-histogram of a low contrast area in the first grayscale image are obtained.
[0089] Step S104, respectively adjust each gray level in the first sub-histogram and the second sub-histogram to obtain an adjusted first sub-histogram and an adjusted second sub-histogram, obtain an enhanced grayscale image based on the adjusted first sub-histogram and the adjusted second sub-histogram, and perform household recognition of electric vehicles based on the enhanced grayscale image.
[0090] Since the contrast in the embodiment of the present invention refers to the grayscale difference between two areas, and it does not exclude that the same area has a higher contrast in a certain area and a lower contrast with another area at the same time, that is, the area participates in the construction of both the first sub-histogram and the second sub-histogram, therefore, in order to ensure the accuracy of grayscale adjustment of the grayscale image, in the embodiment of the present invention, the grayscale of the first sub-histogram and the second histogram are adjusted respectively to achieve the purpose of image enhancement of the grayscale image.
[0091] The specific process of adjusting the grayscale of the first sub-histogram and the second histogram is as follows:
[0092] Detecting whether the first sub-histogram and the second sub-histogram have the same gray level, and if it is detected that the first sub-histogram and the second sub-histogram have the same gray level, taking the same gray level as a stable gray level;
[0093] For any sub-histogram of the first sub-histogram and the second sub-histogram, taking any gray level in the sub-histogram as a target gray level, if the target gray level is greater than a maximum stable gray level among the stable gray levels or less than a minimum stable gray level among the stable gray levels, determining at least one region involved in the target gray level in the first gray image as a target region;
[0094] Acquire the contrast between the target area and each other area in the first grayscale image, obtain the contrast mean as the regional contrast, calculate the average value of the regional contrasts corresponding to all target areas as the overall contrast of the target grayscale, obtain the average overall contrast according to the overall contrast of each grayscale in the first grayscale image, calculate the contrast difference between the average overall contrast and the overall contrast of the target grayscale, and obtain the contrast ratio between the contrast difference and the overall contrast of the target grayscale;
[0095] Obtaining a reference grayscale of the target grayscale, calculating a grayscale difference between the target grayscale and the reference grayscale, obtaining an adjustment coefficient according to the type of the sub-histogram, obtaining a multiplication result between the contrast ratio, the grayscale difference and the adjustment coefficient, and using the difference between the multiplication result and the target grayscale as a grayscale adjustment result of the target grayscale;
[0096] If the target gray level is between any two stable gray levels, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of the target gray level using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of the target gray level, and obtain a grayscale adjustment result of the target gray level;
[0097] The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
[0098] In one embodiment, first, a stable gray level is determined according to the same gray level between the first sub-histogram and the second sub-histogram, that is, the same gray level is used as the stable gray level. Then, considering that the processing methods of the first sub-histogram and the second sub-histogram are the same, a sub-histogram is used as an example for description, and the overall contrast of each gray level in the sub-histogram is calculated, wherein, for the overall contrast of the x-th gray level, since the x-th gray level corresponds to at least one area, one of the areas to which the x-th gray level belongs is taken as the target area, and the contrast between the target area and each other area in the first gray image is obtained, and the contrast mean is obtained as the regional contrast of the target area. When the x-th gray level corresponds to only one target area, the regional contrast calculated at this time is the overall contrast of the x-th gray level. When the x-th gray level corresponds to multiple target areas, the regional contrast of each target area is obtained respectively, and the average value of the regional contrast is calculated as the overall contrast of the x-th gray level. At this time, each gray level in the sub-histogram corresponds to an overall contrast.
[0099] Finally, since there are three types of positional relationships between each gray level in the sub-histogram and the stable gray level: ① the gray level is less than the minimum stable gray level; ② the gray level is between two stable gray levels; ③ the gray level is greater than the maximum stable gray level; then for the xth gray level in the sub-histogram, when the positional relationship between the xth gray level and the stable gray level is in the case of ① or ③, the distance between each gray level in the sub-histogram and the stable gray level is adjusted in order from small to large, where the calculation expression of the gray adjustment result of the xth gray level is:
[0100]
[0101] in, Represents the grayscale adjustment result of the x-th grayscale level, represents the xth gray level in the subhistogram, Represents the adjustment coefficient. The value of m is 1 or 2. When processing the first sub-histogram, m=1. When processing the second sub-histogram, m is 2. represents the reference gray level of the x-th gray level in the subhistogram, represents the overall contrast of the xth gray level in the subhistogram, represents an average overall contrast obtained according to the overall contrast of each gray level in the first grayscale image.
[0102] It should be noted that when processing the first sub-histogram, the intervals between the gray levels need to be stretched. In case of ①, to widen the interval between the x-th gray level and the stable gray level, the x-th gray level needs to be moved in the direction closer to the stable gray level (that is, towards the larger gray level). greater than 0, Less than 0, then, ; When ③ is the case, it is necessary to move to a smaller gray level. Less than 0, is greater than 0, then .
[0103] When the positional relationship between the x-th grayscale and the stable grayscale is in the case of ②, the two stable grayscales are used as the equalization range, and the overall contrast of each grayscale between the two stable grayscales is normalized, that is, the overall contrast of each grayscale is divided by the cumulative sum of the overall contrast of all grayscales in the equalization range, and the obtained ratio is used as the normalized contrast of each grayscale. According to the normalized contrast of all grayscales in the equalization range, segmented histogram equalization is performed, that is, here the cumulative distribution probability is no longer calculated according to the frequency of occurrence of each grayscale, but the cumulative distribution probability is calculated according to the normalized contrast of each grayscale, and the grayscale adjustment result of the x-th grayscale is obtained. It should be noted that the cumulative distribution probability belongs to a step in the histogram equalization method, and the histogram equalization belongs to the prior art, which will not be repeated here.
[0104] According to the method for obtaining the grayscale adjustment result of the xth grayscale level in the sub-histogram, the same processing is performed on each grayscale level in the sub-histogram in turn to obtain the adjusted sub-histogram, that is, the adjusted first sub-histogram and the adjusted second sub-histogram can be obtained respectively.
[0105] Wherein, obtaining a reference grayscale of the target grayscale includes:
[0106] According to the grayscale difference between the target grayscale and each of the stable grayscales, obtaining the stable grayscale corresponding to the minimum grayscale difference as the nearest stable grayscale of the target grayscale;
[0107] If there are no other gray levels between the target gray level and the most recent stable gray level, the most recent stable gray level is used as a reference gray level for the target gray level; if there are other gray levels between the target gray level and the most recent stable gray level, the other gray levels closest to the target gray level are used as reference gray levels for the target gray level.
[0108] In one embodiment, the reference gray level for the xth gray level in the sub-histogram , obtain the grayscale difference between the xth grayscale and each stable grayscale, take the stable grayscale corresponding to the minimum grayscale difference as the nearest stable grayscale of the xth grayscale, and detect whether there are other grayscales between the xth grayscale and the nearest stable grayscale according to the position distribution of the xth grayscale and the nearest stable grayscale between the sub-histograms. If there are no other grayscales between the xth grayscale and the nearest stable grayscale, then take the nearest stable grayscale as the reference grayscale of the xth grayscale; if there are other grayscales between the xth grayscale and the nearest stable grayscale, then take the other grayscale with the smallest grayscale difference (closest distance) with the xth grayscale as the reference grayscale of the xth grayscale.
[0109] After detecting whether the first sub-histogram and the second sub-histogram have the same gray level, the method further includes:
[0110] If it is detected that the first sub-histogram and the second sub-histogram do not have the same gray level, obtaining the maximum gray level and the minimum gray level between the first sub-histogram and the second sub-histogram as stable gray levels;
[0111] For any sub-histogram of the first sub-histogram and the second sub-histogram, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of each gray level in the sub-histogram using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of each gray level in the sub-histogram, and obtain a grayscale adjustment result of each gray level in the sub-histogram;
[0112] The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
[0113] In one embodiment, considering that there is no area between the first sub-histogram and the second sub-histogram that participates in the construction of both the first sub-histogram and the second sub-histogram, that is, there is no same grayscale between the first sub-histogram and the second sub-histogram, the maximum grayscale and the minimum grayscale between the first sub-histogram and the second sub-histogram are obtained as stable grayscales. At this time, any grayscale in the first sub-histogram and the second sub-histogram is between the two stable grayscales, that is, it meets the situation where the positional relationship between the grayscale and the stable grayscale is in ②. Therefore, according to the grayscale adjustment method in the above situation ②, each grayscale in the first sub-histogram and the second sub-histogram is adjusted respectively to obtain the adjusted first sub-histogram and the adjusted second sub-histogram accordingly.
[0114] Furthermore, an enhanced grayscale image is obtained according to the adjusted first sub-histogram and the adjusted second sub-histogram. By performing segmented equalization on the high-contrast area and limiting the contrast enhancement amplitude within each equalization range, details can be effectively retained and the introduction of noise can be reduced, thereby avoiding visual unnaturalness caused by excessive enhancement. Segmented equalization on the low-contrast area can enhance the local contrast, so that hidden details can be revealed, thereby enhancing the layering and detail expression of the image. By processing the high-contrast and low-contrast areas separately and finally merging the two, a balanced enhancement of the overall image can be achieved, so that the image presents a more natural and balanced visual effect while retaining details, and more effectively ensuring the details and characteristics of the electric vehicle itself, thereby ensuring the accuracy of subsequent electric vehicle entry recognition based on the enhanced image.
[0115] After obtaining the grayscale image after image enhancement, the electric vehicle entry recognition is performed according to the grayscale image after image enhancement. Specifically, the grayscale image after image enhancement is input into a trained neural network, and a corresponding bounding box of the electric vehicle is output, wherein the neural network is Yolov5, which belongs to the prior art and is not described in detail here. It should be noted that the electric vehicle entry recognition according to the grayscale image after image enhancement is not the focus of the present invention and is not described in detail here.
[0116] In summary, when an electric vehicle enters a residence, a grayscale image of the electric vehicle is obtained, and according to the grayscale distribution in the grayscale image, whether the grayscale image needs to be enhanced is detected; if it is detected that the grayscale image needs to be enhanced, each grayscale in the grayscale image is mapped respectively to obtain a corresponding mapped grayscale, and each mapped grayscale is adjusted according to the difference between adjacent mapped grayscales to obtain an adjusted mapped grayscale; noise smoothing is performed on the grayscale image according to all adjusted mapped grayscales to obtain a first grayscale image, and the first grayscale image is divided into N regions, and a first sub-histogram and a second sub-histogram are constructed according to the contrast difference between each region and its adjacent regions; each grayscale in the first sub-histogram and the second sub-histogram is adjusted respectively to obtain an adjusted first sub-histogram and an adjusted second sub-histogram, and an image-enhanced grayscale image is obtained according to the adjusted first sub-histogram and the adjusted second sub-histogram, and the entry of the electric vehicle is identified according to the image-enhanced grayscale image. Among them, by removing noise from the grayscale image and dividing the regions, the histograms of high-contrast regions and low-contrast regions are constructed according to the contrast differences between the regions, so as to avoid excessive enhancement of the global histogram equalization, and then the grayscale level of the position interval of each grayscale level in each histogram is adjusted respectively to obtain the grayscale image after image enhancement. By performing segmented equalization on the high-contrast region, the contrast enhancement amplitude within each equalization range is limited, the details are effectively retained and the introduction of noise is reduced, and the visual unnaturalness caused by excessive enhancement is avoided; the low-contrast region is segmentedly equalized to enhance the local contrast so that the hidden details can be displayed, thereby enhancing the layering and detail expression of the image. Therefore, when the electric vehicle entry recognition is performed according to the grayscale image after image enhancement, the details and characteristics of the electric vehicle itself can be more effectively detected, thereby improving the accuracy of electric vehicle entry recognition.
[0117] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. The electric vehicle entry intelligent identification method based on the secondary AI algorithm is characterized by: The method comprises: When an electric vehicle enters a house, a grayscale image of the electric vehicle is obtained, and according to the grayscale distribution in the grayscale image, whether the grayscale image needs to be enhanced; If it is detected that the grayscale image needs to be enhanced, each grayscale level in the grayscale image is mapped to obtain a corresponding mapped grayscale level, and each mapped grayscale level is adjusted according to a difference between adjacent mapped grayscale levels to obtain an adjusted mapped grayscale level; performing noise smoothing on the grayscale image according to all adjusted mapped grayscale levels to obtain a first grayscale image, dividing the first grayscale image into N regions, and constructing a first sub-histogram and a second sub-histogram according to a contrast difference between each region and its adjacent regions; Adjusting each gray level in the first sub-histogram and the second sub-histogram respectively, and obtaining an adjusted first sub-histogram and an adjusted second sub-histogram accordingly, obtaining an image-enhanced grayscale image according to the adjusted first sub-histogram and the adjusted second sub-histogram, and performing household entry recognition of the electric vehicle according to the image-enhanced grayscale image; The step of performing noise smoothing on the grayscale image according to all adjusted mapped grayscale levels to obtain a first grayscale image, and dividing the first grayscale image into N regions comprises: For any adjusted mapping gray level, obtaining a binary image of the adjusted mapping gray level, clustering all pixels in the binary image to obtain at least one clustering region and an isolated point; Taking each isolated point in the binary image corresponding to the adjusted mapped grayscale as a noise point, obtaining the grayscale mean of the pixels in the neighborhood of each noise point to replace the grayscale value of the corresponding noise point, and obtaining a first grayscale image; According to the coordinates of each noise point in the first grayscale image, each noise point is divided into a corresponding clustering area to obtain N final clustering areas, and one final clustering area is regarded as a region, where N represents the total number of regions.
2. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 1 is characterized in that: The step of detecting whether the grayscale image needs to be enhanced according to the grayscale distribution in the grayscale image comprises: Constructing a grayscale histogram of the grayscale image, obtaining the grayscale difference between every two adjacent grayscale levels whose occurrence probability is not 0 in the grayscale histogram, and obtaining the mean of the grayscale differences as the grayscale interval mean; Counting the number of gray levels with a non-zero probability of appearing in the gray histogram, and calculating the ratio between the number of gray levels and the total number of gray levels within the gray level range as the overall average gray interval; A first ratio between the grayscale interval mean and the overall average grayscale interval is calculated. If the first ratio is less than a preset value, it is determined that the grayscale image needs to be enhanced. If the first ratio is not less than the preset value, it is determined that the grayscale image does not need to be enhanced.
3. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 2 is characterized in that: The step of mapping each grayscale level in the grayscale image to obtain a corresponding mapped grayscale level comprises: For any gray level in the grayscale histogram, the cumulative value of the occurrence probability of each gray level before the gray level and the occurrence probability of the gray level is calculated as the cumulative occurrence probability of the gray level, and the product of the maximum gray level and the cumulative occurrence probability of the gray level is taken as the mapping gray level corresponding to the gray level.
4. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 3 is characterized in that: The step of adjusting each of the mapped gray levels according to the difference between adjacent mapped gray levels to obtain the adjusted mapped gray level includes: For any mapped gray level, obtain the previous mapped gray level of the mapped gray level, count at least one gray level corresponding to the previous mapped gray level to obtain a first maximum gray level, count at least one gray level corresponding to the mapped gray level to obtain a second maximum gray level; Obtaining a first difference between the first maximum gray level and the second maximum gray level, obtaining a j-th gray level corresponding to the mapped gray level, obtaining a second difference between the j-th gray level and the first maximum gray level, and calculating a difference ratio between the first difference and the second difference, wherein j represents the sequence number of the gray level corresponding to the mapped gray level; A third difference between the mapped gray level and the previous mapped gray level is obtained to obtain a product between the third difference and the difference ratio, and a sum of the product and the mapped gray level is used as the adjusted mapped gray level of the j-th gray level.
5. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 1 is characterized in that: The step of constructing a first sub-histogram and a second sub-histogram according to the contrast difference between each of the regions and its adjacent regions comprises: For any region in the first grayscale image, calculating an absolute value of a difference between an adjusted mapped grayscale level corresponding to the region and an adjusted mapped grayscale level corresponding to any other region as a contrast ratio between the region and the other region; According to the contrast between every two regions in the first grayscale image, an average contrast is obtained, and if the contrast between any two regions is greater than or equal to the average contrast, a first sub-histogram is constructed using the adjusted mapped grayscale levels corresponding to all pixels in the two regions; If the contrast between any two regions is less than the average contrast, a second sub-histogram is constructed using the adjusted mapped gray levels corresponding to all pixels in the two regions.
6. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 1 is characterized in that: The step of adjusting each gray level in the first sub-histogram and the second sub-histogram to obtain an adjusted first sub-histogram and an adjusted second sub-histogram respectively comprises: Detecting whether the first sub-histogram and the second sub-histogram have the same gray level, and if it is detected that the first sub-histogram and the second sub-histogram have the same gray level, taking the same gray level as a stable gray level; For any sub-histogram of the first sub-histogram and the second sub-histogram, taking any gray level in the sub-histogram as a target gray level, if the target gray level is greater than a maximum stable gray level among the stable gray levels or less than a minimum stable gray level among the stable gray levels, determining at least one region involved in the target gray level in the first gray image as a target region; Acquire the contrast between the target area and each other area in the first grayscale image, obtain the contrast mean as the regional contrast, calculate the average value of the regional contrasts corresponding to all target areas as the overall contrast of the target grayscale, obtain the average overall contrast according to the overall contrast of each grayscale in the first grayscale image, calculate the contrast difference between the average overall contrast and the overall contrast of the target grayscale, and obtain the contrast ratio between the contrast difference and the overall contrast of the target grayscale; Obtaining a reference grayscale of the target grayscale, calculating a grayscale difference between the target grayscale and the reference grayscale, obtaining an adjustment coefficient according to the type of the sub-histogram, obtaining a multiplication result between the contrast ratio, the grayscale difference and the adjustment coefficient, and using the difference between the multiplication result and the target grayscale as a grayscale adjustment result of the target grayscale; If the target gray level is between any two stable gray levels, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of the target gray level using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of the target gray level, and obtain a grayscale adjustment result of the target gray level; The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
7. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 6 is characterized in that: The obtaining of a reference gray level of the target gray level comprises: According to the grayscale difference between the target grayscale and each of the stable grayscales, obtaining the stable grayscale corresponding to the minimum grayscale difference as the nearest stable grayscale of the target grayscale; If there are no other gray levels between the target gray level and the most recent stable gray level, the most recent stable gray level is used as a reference gray level for the target gray level; if there are other gray levels between the target gray level and the most recent stable gray level, the other gray levels closest to the target gray level are used as reference gray levels for the target gray level.
8. The electric vehicle entry intelligent identification method based on the secondary AI algorithm according to claim 6 is characterized in that: After detecting whether the first sub-histogram and the second sub-histogram have the same gray level, the method further includes: If it is detected that the first sub-histogram and the second sub-histogram do not have the same gray level, obtaining the maximum gray level and the minimum gray level between the first sub-histogram and the second sub-histogram as stable gray levels; For any sub-histogram of the first sub-histogram and the second sub-histogram, normalize the overall contrast of each gray level between the two stable gray levels to obtain a corresponding normalized contrast, calculate the cumulative distribution probability of each gray level in the sub-histogram using the normalized contrast of each gray level between the two stable gray levels, perform histogram equalization according to the cumulative distribution probability of each gray level in the sub-histogram, and obtain a grayscale adjustment result of each gray level in the sub-histogram; The grayscale adjustment results of each grayscale level in the first sub-histogram and the second sub-histogram are respectively obtained, and an adjusted first sub-histogram and an adjusted second sub-histogram are correspondingly obtained.
