Intelligent city garbage classification and identification method based on machine vision

CN117975125BActive Publication Date: 2026-09-29GRAND BLUE URBAN ENVIRONMENT SERVICE CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410083861.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-19
Publication Date
2026-09-29
Estimated Expiration
2044-01-19

AI Technical Summary

Technical Problem

[0004]本发明提供基于机器视觉的智慧城市垃圾分类识别方法,以解决现有的问题

Benefits of technology

[0049]本发明实施例中,获取草坪上的垃圾图像的灰度图像和其灰度直方图,其基于草坪的绿色背景,对图像进行加权灰度化,调整通道的权重,增加灰度图像中目标与背景区域的灰度差异,提供图像分割的准确性。再得到分割阈值序列和标准灰度级,将分割阈值序列中第一个数据,记为第一阈值,获取第一阈值对应的填充性、填充范围判断值,从而得到灰度直方图中的填充范围,再获取填充范围内每个灰度级的填充数量,从而得到第一阈值对应的更新灰度直方图,由此得到分割阈值序列中所有数据对应的填充性,从而得到最优分割阈值,其利用迭代法对图像进行分割,基于目标和背景区域像素点数量差距较大的现象,对灰度直方图进行分析,选定初始阈值,根据迭代过程中阈值的变化情况,对像素点分别进行填充处理,获得较为均衡的直方图分布,进一步保障图像分割的准确性,从而得到灰度图像中的垃圾区域,将其传输至现有的垃圾分类识别软件中,得到垃圾分类识别结果。至此本发明通过获取图像中更加精准的垃圾区域,减少背景区域对垃圾分类识别的影响,提高垃圾分类识别的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117975125B_ABST
    Figure CN117975125B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image data processing, in particular to a smart city garbage classification and identification method based on machine vision, comprising: obtaining a gray image of garbage image on a lawn and a gray histogram thereof, and obtaining a segmentation threshold sequence and a standard gray level; taking the first data in the segmentation threshold sequence as a first threshold; obtaining a filling property and a filling range judgment value corresponding to the first threshold, so as to obtain a filling range in the gray histogram; then obtaining the filling quantity of each gray level in the filling range, so as to obtain an updated gray histogram corresponding to the first threshold; thus obtaining the filling property corresponding to all data in the segmentation threshold sequence, so as to obtain a garbage area in the gray image, which is transmitted to existing garbage classification and identification software to obtain a garbage classification and identification result. The present application can obtain a more accurate garbage area in the image, reduce the influence of the background area on garbage classification and identification, and improve the accuracy of garbage classification and identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, and more specifically to a smart city waste sorting and identification method based on machine vision. Background Technology

[0002] Littering is rampant these days, and the variety of types of waste makes cleanup costly. For example, plastic waste and fallen leaves on lawns require different cleaning methods. Therefore, smart cities often use machine vision for waste sorting to facilitate cleanup. Before waste sorting, waste identification is necessary, which involves using machine vision to capture images from surveillance footage to identify all types of waste.

[0003] Existing problem: For garbage identification before garbage sorting, due to the difference between garbage color and environment, iterative threshold segmentation is usually used. The result is relatively fixed. It only performs threshold segmentation on the image based on histogram. The result is often affected by background factors and it is difficult to completely segment the garbage, thus reducing the accuracy of subsequent garbage sorting. Summary of the Invention

[0004] This invention provides a machine vision-based smart city waste sorting and identification method to solve existing problems.

[0005] The smart city waste sorting and identification method based on machine vision of the present invention adopts the following technical solution:

[0006] One embodiment of the present invention provides a smart city waste sorting and identification method based on machine vision, the method comprising the following steps:

[0007] Images of trash on the lawn are collected, converted to grayscale to obtain grayscale images, and then the grayscale histogram of the grayscale images is obtained.

[0008] In the grayscale histogram, the segmentation threshold sequence and standard grayscale levels are obtained based on all grayscale levels and the number of pixels at each grayscale level.

[0009] The first data in the segmentation threshold sequence is denoted as the first threshold. Based on the difference between the first threshold, the standard gray level, and the maximum and minimum gray levels in the gray-level histogram, the fillability and fill range judgment values ​​corresponding to the first threshold are obtained.

[0010] Based on the fill range judgment value, the fill range in the grayscale histogram is obtained; within the fill range in the grayscale histogram, based on the fillability corresponding to the first threshold and the number of pixels at all gray levels in the grayscale histogram, the fill quantity for each gray level within the fill range is obtained.

[0011] Based on the amount of fill for all gray levels within the fill range, the updated gray-level histogram corresponding to the first threshold is obtained; based on the updated gray-level histogram corresponding to the first threshold, the fill property corresponding to all data in the segmentation threshold sequence is obtained; based on the fill property corresponding to all data in the segmentation threshold sequence, the optimal segmentation threshold is obtained, and the garbage region in the gray-level image is obtained; the garbage region is transmitted to the existing garbage classification and recognition software to obtain the garbage classification and recognition result.

[0012] Furthermore, the specific steps for obtaining the segmentation threshold sequence and standard gray levels based on all gray levels and the number of pixels at each gray level are as follows:

[0013] Based on the gray levels from small to large, the number of pixels corresponding to each gray level in the gray level histogram is counted sequentially to obtain the number sequence;

[0014] Peak detection method is used to obtain local maxima in the quantity sequence;

[0015] The initial threshold is obtained based on the number of local maxima in the quantity sequence;

[0016] Starting from the initial threshold, an iterative thresholding method is used on the gray-level histogram, and the segmentation threshold after each iteration is recorded sequentially to obtain a segmentation threshold sequence.

[0017] The standard gray level is obtained by using all the data in the quantity sequence and their corresponding gray levels.

[0018] Furthermore, the specific steps for obtaining the initial threshold based on the number of local maxima in the quantity sequence are as follows:

[0019] If the number of local maxima in the quantity sequence is greater than or equal to two, the average of the gray levels corresponding to the last and first local maxima in the quantity sequence is recorded as the initial threshold.

[0020] If the number of local maxima in the quantity sequence is less than two, the average of the maximum and minimum gray levels in the gray-level histogram is denoted as the initial threshold.

[0021] Furthermore, the specific steps for obtaining the standard gray level based on all data in the quantity sequence and their corresponding gray levels are as follows:

[0022] In a sequence of quantities, each data point is summed with all the data points preceding it to obtain a sequence of cumulative values.

[0023] Half of the number of pixels in a grayscale image is defined as the number threshold.

[0024] In the cumulative value sequence, the minimum value among the differences between each data point and the quantity threshold is counted, and the data corresponding to the minimum value is recorded as the standard data.

[0025] The maximum value among all gray levels corresponding to the standard data is denoted as the standard gray level.

[0026] Furthermore, the specific calculation formula for obtaining the fillability and fill range judgment values ​​corresponding to the first threshold based on the first threshold, standard gray level, and the difference between the maximum and minimum gray levels in the gray-level histogram is as follows:

[0027]

[0028] Where M represents the fillability corresponding to the first threshold, g' is the fill range judgment value, g0 is the standard gray level, g1 is the first threshold, and g max and g min These are the maximum and minimum gray levels in the gray-level histogram, respectively, and exp() is an exponential function with the natural constant as its base.

[0029] Furthermore, the specific steps for obtaining the fill range in the grayscale histogram based on the fill range judgment value are as follows:

[0030] If the fill range judgment value is greater than 1, the gray range formed by the maximum gray level to the standard gray level in the gray level histogram is recorded as the fill range in the gray level histogram.

[0031] If the fill range judgment value is less than 1, the gray range formed by the minimum gray level to the standard gray level in the gray level histogram is recorded as the fill range in the gray level histogram.

[0032] Furthermore, within the filling range of the grayscale histogram, based on the filling property corresponding to the first threshold and the number of pixels at all gray levels in the grayscale histogram, the specific calculation formula for the filling quantity of each gray level within the filling range is as follows:

[0033]

[0034] Where S j N represents the fill amount for the j-th gray level within the fill range. j Let g'1 be the number of pixels at the j-th gray level within the filling range, N be the sum of the number of pixels at all gray levels within the filling range, M be the filling property corresponding to the first threshold, g'1 be the sum of the number of pixels at all gray levels less than or equal to the first threshold in the gray-level histogram, g″1 be the sum of the number of pixels at all gray levels greater than the first threshold in the gray-level histogram, and || be the absolute value function.

[0035] Furthermore, the specific steps for obtaining the updated grayscale histogram corresponding to the first threshold based on the fill quantity of all grayscale levels within the fill range are as follows:

[0036] Within the filling range of the grayscale histogram, a new grayscale histogram is formed by adding the number of pixels at each grayscale level to the number of filling pixels. This new grayscale histogram is denoted as the updated grayscale histogram corresponding to the first threshold.

[0037] Furthermore, the specific steps for obtaining the filling properties of all data in the segmentation threshold sequence based on the updated grayscale histogram corresponding to the first threshold are as follows:

[0038] In the updated grayscale histogram corresponding to the first threshold, obtain the filling property corresponding to the second data in the segmentation threshold sequence and the updated grayscale histogram corresponding to the second data in the segmentation threshold sequence;

[0039] The method for obtaining the fillability corresponding to the second data is the same as that for obtaining the fillability corresponding to the first threshold.

[0040] The updated grayscale histogram corresponding to the second data is obtained in the same way as the updated grayscale histogram corresponding to the first threshold.

[0041] In the updated grayscale histogram corresponding to the second data in the segmentation threshold sequence, obtain the filling property and the updated grayscale histogram corresponding to the third data in the segmentation threshold sequence.

[0042] The method for obtaining the fillability corresponding to the third data is the same as that for obtaining the fillability corresponding to the first threshold.

[0043] The updated grayscale histogram corresponding to the third data is obtained in the same way as the updated grayscale histogram corresponding to the first threshold.

[0044] By analogy, the filling properties corresponding to all data in the segmentation threshold sequence are obtained.

[0045] Furthermore, the specific steps for obtaining the optimal segmentation threshold and the garbage region in the grayscale image based on the padding properties of all data in the segmentation threshold sequence are as follows:

[0046] In the segmentation threshold sequence, the difference between the filling property of all data and the preset judgment threshold is calculated respectively, and the data corresponding to the minimum value of the difference is recorded as the optimal segmentation threshold;

[0047] In a grayscale image, the region consisting of all pixels with grayscale values ​​greater than the optimal segmentation threshold is called a garbage region.

[0048] The beneficial effects of the technical solution of the present invention are:

[0049] In this embodiment of the invention, a grayscale image of litter on a lawn and its grayscale histogram are acquired. Based on the green background of the lawn, the image is weighted grayscale, and the channel weights are adjusted to increase the grayscale difference between the target and background regions in the grayscale image, thus improving the accuracy of image segmentation. A segmentation threshold sequence and standard grayscale levels are then obtained. The first data in the segmentation threshold sequence is designated as the first threshold. The fillability and fill range judgment values ​​corresponding to the first threshold are obtained, thereby obtaining the fill range in the grayscale histogram. The fill quantity for each grayscale level within the fill range is then obtained, resulting in the updated grayscale histogram corresponding to the first threshold. This yields the fillability corresponding to all data in the segmentation threshold sequence, thus obtaining the optimal segmentation threshold. An iterative method is used to segment the image. Based on the phenomenon of a large difference in the number of pixels between the target and background regions, the grayscale histogram is analyzed, an initial threshold is selected, and the pixels are filled according to the changes in the threshold during the iteration process, resulting in a more balanced histogram distribution, further ensuring the accuracy of image segmentation. This yields the litter region in the grayscale image, which is then transmitted to existing waste classification and recognition software to obtain the waste classification and recognition results. Thus, this invention improves the accuracy of waste classification and identification by obtaining more precise waste areas in images and reducing the impact of background areas on waste classification and identification. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 This is a flowchart illustrating the steps of the smart city waste sorting and identification method based on machine vision according to the present invention.

[0052] Figure 2 This is a schematic diagram of a litter image on a lawn to be classified and identified, provided in this embodiment.

[0053] Figure 3 This is a grayscale histogram diagram of a litter image on a lawn to be classified and identified, provided in this embodiment. Detailed Implementation

[0054] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of the machine vision-based smart city waste sorting and identification method proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0056] The specific solution of the smart city waste classification and identification method based on machine vision provided by the present invention will be described in detail below with reference to the accompanying drawings.

[0057] Please see Figure 1 The diagram illustrates a flowchart of a smart city waste sorting and identification method based on machine vision, according to an embodiment of the present invention. The method includes the following steps:

[0058] Step S001: Collect images of trash on the lawn, perform grayscale processing to obtain a grayscale image, and obtain the grayscale histogram of the grayscale image.

[0059] This embodiment uses image processing technology to segment potential litter on a lawn. By analyzing the histogram distribution of the image, optimization is performed for cases where there is a significant difference in the number of background and foreground pixels, resulting in better segmentation results.

[0060] This embodiment uses drones or park surveillance to collect images of litter on the lawn, and then performs grayscale processing on the litter images to obtain grayscale images. Figure 2 This is a schematic diagram of a litter image on a lawn to be classified and identified, provided in this embodiment.

[0061] It should be noted that the image grayscale processing in this embodiment uses a weighted average method, which is a well-known technique, and the specific method will not be described here. To better increase the difference between foreground and background pixels, since the color of lawn is usually green, and to reduce the influence of background pixels on segmentation, in the grayscale process using the weighted average method, this embodiment sets the weight of the red component in the image to 0.587, the weight of the blue component to 0.299, and the weight of the green component to 0.114. This is used as an example for description; other values ​​can be set in other embodiments. It should also be noted that in autumn and winter, the grass is dry, and the background image is a withered yellow. Yellow is composed of red and green, so the weight of blue should be increased during the weighted average grayscale process. This embodiment does not impose a limitation on this.

[0062] During iterative thresholding of an image, the threshold will tend to be pushed towards the more numerous pixel group, affecting the segmentation result, due to the potentially large difference in the number of pixels between the foreground and background. Therefore, it is necessary to optimize the pixel distribution of the image.

[0063] The grayscale histogram of the grayscale image is obtained using the grayscale value statistical method. The grayscale value statistical method is a well-known technique, and its specific implementation will not be described here. Figure 3 This is a grayscale histogram diagram of a litter image on a lawn to be classified and identified, provided in this embodiment. Figure 3 The horizontal axis represents grayscale levels, and the vertical axis represents the number of pixels.

[0064] Step S002: In the grayscale histogram, based on all grayscale levels and the number of pixels at each grayscale level, obtain the segmentation threshold sequence and the standard grayscale level.

[0065] Based on the distribution of pixels in the image's grayscale histogram and the performance of each iteration's result in the grayscale histogram, the probability of grayscale filling and removal is determined. For example, if the foreground grayscale value is large and the background grayscale value is small, resulting in a large difference in the number of pixels between the background and foreground, and the background has a large number of pixels, the influence of the number on the mean during the iteration process after selecting an initial threshold will cause the segmentation threshold to concentrate towards the foreground, making it difficult to obtain good segmentation results.

[0066] During the iteration process, an initial threshold needs to be selected first. However, choosing the average of the maximum and minimum grayscale values ​​in the image at a fixed point can be affected by noisy pixels and result in a large computational load. Furthermore, there may be other plants with different colors from the grass in the image, as well as bare land where the lawn is not completely covered. The histogram distribution of these areas will have a certain impact on the iterative threshold segmentation.

[0067] An image histogram represents the gray-level distribution characteristics of the image. Peaks will appear on the histogram. By analyzing the cases where there are large and small peaks in the image, the peaks represent a certain type of pixel, which can save the need to traverse the gray-level values ​​of this type of pixel.

[0068] In the grayscale histogram of a grayscale image, the number of pixels corresponding to each grayscale level is counted sequentially from smallest to largest, resulting in a count sequence. Peak detection is then used to obtain local maxima within this count sequence. Peak detection is a well-known technique, and its specific method will not be described here.

[0069] When the number of local maxima in the quantity sequence is greater than or equal to 2, the average of the gray level corresponding to the last local maximum and the gray level corresponding to the first local maximum in the quantity sequence is recorded as the initial threshold.

[0070] It should be noted that the analysis should consider the peak values ​​in the gray-level histogram. If multiple peaks exist, the threshold value gradually converges during each iteration, thus the difference between adjacent thresholds decreases, gradually approaching the boundary between the two classes. Therefore, the average of the peaks closest to the gray values ​​of 0 and 255 is chosen as the initial threshold. If only a single peak exists, and the initial threshold skips the gray levels of the target or background class, it will be impossible to obtain the target segmentation result in subsequent iterations. In this case, the average of the maximum and minimum gray values ​​of the image should be used as the initial threshold for iteration. Therefore, when the number of local maxima in the sequence is less than 2, the average of the maximum and minimum gray levels in the gray-level histogram is recorded as the initial threshold.

[0071] The iterative thresholding process involves averaging the grayscale values ​​of the two classes based on the initial threshold, and then using this average as the new threshold for iterative classification. When there is a significant difference in the number of pixels between the two classes, the background class, with its larger number of pixels, tends to have a lower grayscale frequency. Since the background class's average value is calculated by multiplying the grayscale level by its frequency, the threshold may shift towards the class with the lower grayscale frequency during iteration, affecting the final segmentation result.

[0072] During the threshold iteration process, the threshold value changes, and the degree of change can measure the influence of a certain type of pixel on the threshold change. The probability of pixel removal and filling is obtained based on the degree of influence, and the pixel removal and filling operations are then performed based on this probability. To ensure efficiency, the number of iterations n is set to 20 in this embodiment. This is used as an example for description; other values ​​can be set in other embodiments, and this embodiment is not limited to them.

[0073] During the iteration process, the threshold changes. When the distribution of the two types of pixels is relatively uniform, the threshold changes slowly, and the difference between adjacent thresholds fluctuates back and forth. However, when the distribution is uneven, the threshold changes rapidly and has a cumulative effect. Since the average gray value of the class with higher gray-level frequency is concentrated near the higher gray-level frequencies, while the average gray value of the class with lower gray-level frequency tends to be closer to the middle of the gray-level range, the resulting average value will be more biased towards the class with lower gray-level frequency. The degree of change indicates the direction of gray-level adjustment.

[0074] On the grayscale histogram of a grayscale image, starting from an initial threshold, iterative thresholding is performed according to the number of iterations n. The segmentation thresholds after each iteration are recorded sequentially to obtain a segmentation threshold sequence. That is, there are n data points in the segmentation threshold sequence. Iterative thresholding is a well-known technique, and the specific method will not be described here.

[0075] When the two gray-level distributions are relatively balanced, the iterative threshold gradually converges. From the initial threshold to the final cutoff threshold, as the initial threshold moves back and forth on the coordinate axis corresponding to the gray levels, adjacent differences exhibit alternating positive and negative values, and the differences gradually decrease, resulting in a curve image similar to damped oscillation. However, when the differences between the two classes are large, the threshold changes by increasing several times consecutively, but the step size gradually decreases, and then the next value change is a decrease, and this process is repeated until the optimal threshold is obtained. In other words, the histogram is traversed to obtain the locations of the gray levels where the two classes of pixels are evenly distributed.

[0076] The direction of threshold change is affected by the number of two types of pixels. The direction and degree of multiple increases in the threshold indicate the possibility of filling gray levels. The difference between the location of the threshold change and the gray level where the peak is located on the histogram indicates the possibility of removing gray levels.

[0077] Therefore, starting from the segmentation threshold obtained in the first iteration, the sum of each data point and all preceding data points is counted sequentially in the quantity sequence to obtain the cumulative value sequence. The calculation process of the cumulative value sequence is as follows: on the gray-level histogram of the gray-level image, the number of pixels accumulated for each gray level is calculated, and the calculation formula is as follows:

[0078]

[0079] Where F n H is the cumulative number of pixels across the first n gray levels in the grayscale histogram. i is the number of pixels at the i-th gray level in the gray-level histogram, and m is the number of categories in the gray-level histogram.

[0080] It should be noted that the number of categories on the grayscale histogram only counts grayscale levels where the number of pixels is not zero, and in the analysis of this embodiment, only grayscale levels with a non-zero number of pixels on the grayscale histogram are used.

[0081] This yields the cumulative value sequence {F1, F2, ..., F...} m}, where F1, F2, F m These are the cumulative values ​​of the number of pixels at the first 1, first 2, and first m gray levels of the grayscale histogram, respectively.

[0082] The number threshold is defined as half the number of pixels in a grayscale image.

[0083] In the cumulative value sequence, the minimum absolute value of the difference between each data point and the quantity threshold is calculated, and the data corresponding to the minimum value is denoted as the standard data. The maximum value among all gray levels corresponding to the standard data is denoted as the standard gray level.

[0084] Step S003: The first data in the segmentation threshold sequence is denoted as the first threshold; based on the difference between the first threshold, the standard gray level, and the maximum and minimum gray levels in the gray-scale histogram, the filling performance and filling range judgment values ​​corresponding to the first threshold are obtained.

[0085] The first data point in the segmentation threshold sequence is denoted as the first threshold. Therefore, in the grayscale histogram, starting from the segmentation threshold obtained in the first iteration, the gray levels along the direction of the iterative segmentation threshold movement have the potential to fill. That is, the formula for calculating the fillability M corresponding to the first threshold is:

[0086]

[0087] Where M represents the fillability corresponding to the first threshold, g' is the fill range judgment value, g0 is the standard gray level, g1 is the first threshold, and g max and g min These represent the maximum and minimum gray levels in the grayscale histogram, respectively. exp() is an exponential function with the natural constant as its base.

[0088] It should be noted that g1-g0 represents the direction of threshold change during the iteration process, i.e., from g1 to g0. The magnitude represents the degree of threshold change during the iteration process. The larger the magnitude, the greater the difference in the number of pixels between the two types. The fill range judgment value reflects the peak distribution position of the histogram and is used to determine the probability of filling the gray-level range of the histogram. When g' is greater than 1, it indicates that there are too many pixels at the smaller gray levels; when g' is less than 1, it indicates that there are too many pixels at the larger gray levels. That is, the further g' is from 1, the greater the difference in the number of pixels at the gray levels, and the more adjustment is needed. Therefore, exp((g1-g0)×(g'-1)) represents the fillability corresponding to the first threshold. The exponential function is used to prevent M from being negative. When the data value in the exponential function is negative, the smaller the negative number, the smaller M is.

[0089] Step S004: Based on the fill range judgment value, obtain the fill range in the grayscale histogram; within the fill range in the grayscale histogram, based on the fill property corresponding to the first threshold and the number of pixels on all grayscale levels in the grayscale histogram, obtain the fill quantity for each grayscale level within the fill range.

[0090] Therefore, in the grayscale histogram of the grayscale image, when g' is greater than 1, the filling range is [g0, g...]. max When g' is less than 1, the filling range is [g]. min ,g0].

[0091] It should be noted that when g' equals 1, it means that the number of pixels on both sides of g0 in the grayscale histogram is similar, and the range of grayscale levels is similar, that is, the grayscale histogram is good and does not need adjustment. Therefore, 1 is used as the threshold for g'. Thus, when g' equals 1, the grayscale histogram is recorded as the updated grayscale histogram corresponding to the first threshold.

[0092] The above has established the possibilities for grayscale frequency processing. Based on the magnitude of these possibilities, grayscale frequency removal and filling of the image can yield a relatively balanced grayscale distribution result between the two types of pixels. Since other colored plants and bare soil may exist in the image, their corresponding grayscale values ​​are close to those of the grass category. These are non-target grayscale levels with low grayscale frequencies, and their grayscale levels differ significantly from those of the garbage target. Furthermore, the grayscale values ​​of these pixels are distributed on both sides of the grass grayscale peak; therefore, they will be treated as background pixels in the image during processing. The grayscale frequency is calculated by dividing the number of pixels at the grayscale level by the number of pixels in the grayscale histogram. In subsequent calculations, the frequency can be directly represented by the number of pixels at the grayscale level.

[0093] The frequency of gray levels is adjusted accordingly based on the fill level. During the filling process, the greater the increase in the threshold, the greater the degree of fill required for gray levels in the direction of increase.

[0094] Therefore, the formula for calculating the amount of fill for each gray level within the fill range on the gray-level histogram of a gray-level image is:

[0095]

[0096] Where S j N represents the fill amount for the j-th gray level within the fill range. j Let be the number of pixels at the j-th gray level within the filling range, N be the sum of the number of pixels at all gray levels within the filling range, M be the filling property corresponding to the first threshold, g'1 be the sum of the number of pixels at all gray levels less than or equal to the first threshold in the gray-level histogram, g″1 be the sum of the number of pixels at all gray levels greater than the first threshold in the gray-level histogram, q be the number of gray levels within the filling range, and || be the absolute value function.

[0097] It should be noted that: This represents the weight of the j-th gray level within the fill area; the larger the value, the more fill is needed. M×|g'1-g″1| represents the baseline quantity; the larger the value, the more fill is needed in the fill area. Therefore, the product of the two is used. This indicates the amount of fill for the j-th gray level within the fill range.

[0098] Step S005: Based on the number of fills for all gray levels within the fill range, obtain the updated gray-level histogram corresponding to the first threshold; based on the updated gray-level histogram corresponding to the first threshold, obtain the fill property corresponding to all data in the segmentation threshold sequence; based on the fill property corresponding to all data in the segmentation threshold sequence, obtain the optimal segmentation threshold and obtain the garbage region in the gray-level image; transmit the garbage region to the existing garbage classification and recognition software to obtain the garbage classification and recognition result.

[0099] Within the filling range of the grayscale histogram of the grayscale image, a new grayscale histogram is formed by adding the number of pixels at each grayscale level to the filling amount, and this new grayscale histogram is denoted as the updated grayscale histogram corresponding to the first threshold.

[0100] On the updated grayscale histogram corresponding to the first threshold, the filling and updated grayscale histogram corresponding to the second data in the segmentation threshold sequence are obtained in the manner described above.

[0101] On the updated grayscale histogram corresponding to the second data in the segmentation threshold sequence, the filling and updated grayscale histogram corresponding to the third data in the segmentation threshold sequence are obtained in the same way as described above.

[0102] By analogy, the filling and updated grayscale histograms corresponding to each data point in the segmentation threshold sequence are obtained.

[0103] The judgment threshold set in this embodiment is 1. This is used as an example for description. Other values ​​can be set in other embodiments. This embodiment does not limit the value.

[0104] In the segmentation threshold sequence, calculate the absolute value of the difference between the filling property and the judgment threshold for each data point, and count the data corresponding to the minimum value among the absolute values, which is denoted as the optimal segmentation threshold.

[0105] It should be noted that if there are multiple minimum values ​​among the absolute values, the data corresponding to the first minimum value is taken according to the order of the segmentation threshold sequence. That is, the optimal segmentation threshold obtained first in the segmentation threshold iteration process is taken.

[0106] In a grayscale image, the region consisting of all pixels with grayscale values ​​greater than the optimal segmentation threshold is called a garbage region.

[0107] The waste area is transmitted to existing waste sorting and identification software to obtain the waste sorting and identification results for the waste area.

[0108] It should be noted that existing waste sorting and identification software, such as "Image Search" and "Waste Sorting Assistant," only require inputting an image of waste into the software to obtain the waste's classification information and processing method. This embodiment improves the accuracy of waste sorting and identification by enhancing the accuracy of waste area segmentation.

[0109] This invention is now complete.

[0110] In summary, in this embodiment of the invention, a grayscale image of litter on a lawn and its grayscale histogram are obtained. Based on all grayscale levels and the number of pixels at each grayscale level, a segmentation threshold sequence and a standard grayscale level are obtained. The first data in the segmentation threshold sequence is denoted as the first threshold. Based on the difference between the first threshold, the standard grayscale level, and the maximum and minimum grayscale levels in the grayscale histogram, the fillability and fill range judgment values ​​corresponding to the first threshold are obtained, thus obtaining the fill range in the grayscale histogram. Within the fill range in the grayscale histogram, based on the fillability corresponding to the first threshold and the number of pixels at all grayscale levels in the grayscale histogram, the fill quantity for each grayscale level within the fill range is obtained, thus obtaining the updated grayscale histogram corresponding to the first threshold. This yields the fillability corresponding to all data in the segmentation threshold sequence and the optimal segmentation threshold and the litter region in the grayscale image. The litter region is then transmitted to existing waste sorting and recognition software to obtain the waste sorting and recognition result. This invention improves the accuracy of waste sorting and recognition by obtaining a more accurate litter region in the image, reducing the influence of the background region on waste sorting and recognition.

[0111] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A smart city waste sorting and identification method based on machine vision, characterized in that, The method includes the following steps: Images of trash on the lawn are collected, converted to grayscale to obtain grayscale images, and then the grayscale histogram of the grayscale images is obtained. In the grayscale histogram, the segmentation threshold sequence and standard grayscale levels are obtained based on all grayscale levels and the number of pixels at each grayscale level. The first data in the segmentation threshold sequence is denoted as the first threshold. Based on the difference between the first threshold, the standard gray level, and the maximum and minimum gray levels in the gray-level histogram, the fillability and fill range judgment values ​​corresponding to the first threshold are obtained. Based on the fill range judgment value, the fill range in the grayscale histogram is obtained; within the fill range in the grayscale histogram, based on the fillability corresponding to the first threshold and the number of pixels at all gray levels in the grayscale histogram, the fill quantity for each gray level within the fill range is obtained. Based on the amount of fill for all gray levels within the fill range, the updated gray-level histogram corresponding to the first threshold is obtained; based on the updated gray-level histogram corresponding to the first threshold, the fillability corresponding to all data in the segmentation threshold sequence is obtained; based on the fillability corresponding to all data in the segmentation threshold sequence, the optimal segmentation threshold is obtained, and the garbage region in the gray-level image is obtained; the garbage region is transmitted to the existing garbage classification and recognition software to obtain the garbage classification and recognition result; The specific calculation formula for the fillability and fill range judgment values ​​corresponding to the first threshold, based on the differences between the first threshold, standard gray level, and maximum and minimum gray levels in the gray-level histogram, is as follows: ; Where M represents the padding property corresponding to the first threshold. The value is used to determine the range to be filled. Standard grayscale level The first threshold, and These represent the maximum and minimum gray levels in the grayscale histogram, respectively. It is an exponential function with the natural constant as its base.

2. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, The specific steps for obtaining the segmentation threshold sequence and standard gray levels based on all gray levels and the number of pixels at each gray level are as follows: Based on the gray levels from small to large, the number of pixels corresponding to each gray level in the gray level histogram is counted sequentially to obtain the number sequence; Peak detection method is used to obtain local maxima in the quantity sequence; The initial threshold is obtained based on the number of local maxima in the quantity sequence; Starting from the initial threshold, an iterative thresholding method is used on the gray-level histogram, and the segmentation threshold after each iteration is recorded sequentially to obtain a segmentation threshold sequence. The standard gray level is obtained by using all the data in the quantity sequence and their corresponding gray levels.

3. The smart city waste sorting and identification method based on machine vision according to claim 2, characterized in that, The specific steps for obtaining the initial threshold based on the number of local maxima in the quantity sequence are as follows: If the number of local maxima in the quantity sequence is greater than or equal to two, the average of the gray levels corresponding to the last and first local maxima in the quantity sequence is recorded as the initial threshold. If the number of local maxima in the quantity sequence is less than two, the average of the maximum and minimum gray levels in the gray-level histogram is denoted as the initial threshold.

4. The smart city waste sorting and identification method based on machine vision according to claim 2, characterized in that, The specific steps for obtaining the standard gray level based on all data in the quantity sequence and its corresponding gray level are as follows: In a sequence of quantities, each data point is summed with all the data points preceding it to obtain a sequence of cumulative values. Half of the number of pixels in a grayscale image is defined as the number threshold. In the cumulative value sequence, the minimum value among the differences between each data point and the quantity threshold is counted, and the data corresponding to the minimum value is recorded as the standard data. The maximum value among all gray levels corresponding to the standard data is denoted as the standard gray level.

5. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, The specific steps for determining the fill range in the grayscale histogram based on the fill range judgment value are as follows: If the fill range judgment value is greater than 1, the gray range formed by the maximum gray level to the standard gray level in the gray level histogram is recorded as the fill range in the gray level histogram. If the fill range judgment value is less than 1, the gray range formed by the minimum gray level to the standard gray level in the gray level histogram is recorded as the fill range in the gray level histogram.

6. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, Within the filling range of the grayscale histogram, based on the filling property corresponding to the first threshold and the number of pixels at all gray levels in the grayscale histogram, the specific calculation formula for the filling quantity of each gray level within the filling range is as follows: in Let j be the amount of fill for the j-th gray level within the fill range. Let J be the number of pixels at the j-th gray level within the filled area. The sum of the number of pixels at all gray levels within the fill range, where M is the fill strength corresponding to the first threshold. This is the sum of the number of pixels at all gray levels less than or equal to the first threshold in the gray-level histogram. It represents the sum of the number of pixels at all gray levels greater than the first threshold in the gray-level histogram, where || is the absolute value function.

7. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, The specific steps for obtaining the updated grayscale histogram corresponding to the first threshold based on the number of fills for all grayscale levels within the fill range are as follows: Within the filling range of the grayscale histogram, a new grayscale histogram is formed by adding the number of pixels at each grayscale level to the number of filling pixels. This new grayscale histogram is denoted as the updated grayscale histogram corresponding to the first threshold.

8. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, The specific steps for obtaining the fillability of all data in the segmentation threshold sequence based on the updated grayscale histogram corresponding to the first threshold are as follows: In the updated grayscale histogram corresponding to the first threshold, obtain the filling property corresponding to the second data in the segmentation threshold sequence and the updated grayscale histogram corresponding to the second data in the segmentation threshold sequence; The method for obtaining the fillability corresponding to the second data is the same as that for obtaining the fillability corresponding to the first threshold. The updated grayscale histogram corresponding to the second data is obtained in the same way as the updated grayscale histogram corresponding to the first threshold. In the updated grayscale histogram corresponding to the second data in the segmentation threshold sequence, obtain the filling property and the updated grayscale histogram corresponding to the third data in the segmentation threshold sequence. The method for obtaining the fillability corresponding to the third data is the same as that for obtaining the fillability corresponding to the first threshold. The updated grayscale histogram corresponding to the third data is obtained in the same way as the updated grayscale histogram corresponding to the first threshold. By analogy, the filling properties corresponding to all data in the segmentation threshold sequence are obtained.

9. The smart city waste sorting and identification method based on machine vision according to claim 1, characterized in that, The specific steps for obtaining the optimal segmentation threshold and the garbage region in the grayscale image based on the padding properties of all data in the segmentation threshold sequence are as follows: In the segmentation threshold sequence, the difference between the filling property of all data and the preset judgment threshold is calculated respectively, and the data corresponding to the minimum value of the difference is recorded as the optimal segmentation threshold; In a grayscale image, the region consisting of all pixels with grayscale values ​​greater than the optimal segmentation threshold is called a garbage region.

Citation Information

Patent Citations

  • Aviation part groove area identification method, device, equipment and medium

    CN115439840A

  • Thresholding methods for lesion segmentation in dermoscopy images

    US20180103892A1