A milk powder quality detection method and system based on image processing

By analyzing the intensity of the gradient and potential impurity probability of the surface image of the milk powder, and optimizing the aggregation hierarchical clustering algorithm, the detection error caused by noise pixel points in the traditional method is solved, and more accurate milk powder quality detection is achieved.

CN120147306BActive Publication Date: 2025-07-18SHAANXI SHENGQUAN DAIRY TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510607143.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-13
Publication Date
2025-07-18
Estimated Expiration
2045-05-13

AI Technical Summary

Technical Problem

Traditional milk powder quality detection methods rely on manual and physical and chemical analysis, are inefficient and prone to artificial errors, and the condensation hierarchical clustering algorithm cannot accurately identify impurity defects in the presence of noise pixel points.

Method used

By obtaining the intensity of the gradient of pixel points in the surface image of the milk powder, the possibility of noise pixel points is corrected, the cluster merging distance in the agglomeration hierarchical clustering algorithm is optimized, and the pixel points in the impurity area are identified.

Benefits of technology

It improves the accuracy and efficiency of milk powder quality detection, reduces the impact of noise pixel points on clustering results, and identifies more accurate impurity areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120147306B_ABST
    Figure CN120147306B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and in particular, to a milk powder quality detection method and system based on image processing. The method includes the steps of: collecting an image of the milk powder surface, obtaining the neighboring pixel points of each pixel point in the milk powder surface image, and obtaining the gradient severity of each pixel point based on the neighboring pixel points; obtaining the potential impurity probability of each pixel point; according to the gradient severity and the potential impurity probability, obtaining the possibility of each pixel point being a noise pixel point, clustering the pixel points in the milk powder surface image, obtaining the representativeness of each pair of representative pixel points of each group of clusters, obtaining the distance between each group of clusters, substituting the method for obtaining the distance between each group of clusters into the agglomerative hierarchical clustering algorithm to cluster the milk powder surface image, obtaining a clustering result, and identifying the impurity region pixel points according to the clustering result. The present invention improves the accuracy of impurity region detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and particularly to a milk powder quality detection method and system based on image processing. Background Art

[0002] The detection of milk powder quality is an important part of food safety management. Especially in the production process of infant milk powder, any tiny impurity or defect may pose a serious threat to the health of infants. With the high attention of consumers to food quality and safety, the detection of milk powder quality has become an issue that cannot be ignored. Traditional milk powder quality detection methods mainly rely on manual detection and basic physical and chemical analysis. These methods are not only inefficient, but also may have human errors and cannot effectively detect potential impurity defects, especially some tiny impurities that are difficult to detect. The agglomerative hierarchical clustering algorithm is an unsupervised learning method based on image data. By clustering the gray value differences of different pixel points in the image, potential impurity defects in milk powder can be identified, which can not only improve production efficiency, but also provide safer and higher-quality products for consumers.

[0003] During the process of recursively clustering potential impurity defects in the milk powder surface image using the agglomerative hierarchical clustering algorithm, if the complete-linkage method is used for aggregation, when determining whether two clusters are merged, the farthest distance between the two clusters will be selected as the basis (the maximum gray value difference between pixel points). However, during the acquisition and transmission of the milk powder surface image, data loss or damage may occur, resulting in noise in some areas of the milk powder surface image. Then, the existence of noise pixel points may cause the farthest distance between the two clusters to be inaccurate. Summary of the Invention

[0004] In order to solve the technical problem that the existence of noise pixel points in the milk powder surface image may cause the inaccurate acquisition of the farthest distance between two clusters in the agglomerative hierarchical clustering algorithm, the present invention provides a milk powder quality detection method and system based on image processing.

[0005] In a first aspect, the present invention provides a milk powder quality detection method based on image processing, adopting the following technical solution:

[0006] A milk powder quality detection method based on image processing includes the steps of:

[0007] Collect the milk powder surface image and obtain the gradient intensity of each pixel point in the milk powder surface image;

[0008] Obtain the potential impurity probability of each pixel point , representing the potential impurity probability of the m-th pixel point; represents the number of edge pixels in the neighborhood area of the m-th pixel point; represents the average Euclidean distance between the j-th edge pixel and all other edge pixels in the neighborhood area of the m-th pixel point; According to the gradient severity and the potential impurity probability, obtain the possibility that each pixel point is a noise pixel point;

[0009] Obtain each pair of representative pixel points of each group of clusters; Obtain the representativeness of each pair of representative pixel points of each group of clusters , represents the representativeness of the j-th pair of representative pixel points of the i-th group of clusters; represents the average of the possibilities that the two pixel points in the j-th pair of representative pixel points of the i-th group of clusters are noise pixel points; represents the distance between the j-th pair of representative pixel points of the i-th group of clusters; norm() represents the normalization function;

[0010] Based on the representativeness, obtain the distance between each group of clusters; Substitute the method for obtaining the distance between each group of clusters into the agglomerative hierarchical clustering algorithm to cluster the milk powder surface image, obtain the clustering result, and identify the impurity region pixel points according to the clustering result.

[0011] The innovation of the present invention lies in analyzing the difference between the impurity region and the noise pixel points, obtaining the potential impurity probability of each pixel point, correcting the gradient severity of the pixel points according to the potential impurity probability, obtaining the possibility that each pixel point is a noise pixel point, and avoiding the accuracy of the noise pixel point recognition by the impurity region pixel points; Then, according to the possibility that each pixel point is a noise pixel point, correct the distance between each pair of representative pixel points of each group of clusters to obtain the representativeness of each pair of representative pixel points of each group of clusters; Furthermore, select the distance between the pair of representative pixel points with the largest representativeness as the distance between each group of clusters for merging, solve the influence of the noise pixel points on the distance between each group of clusters, facilitate obtaining a more accurate clustering result subsequently, and identify the impurity region pixel points.

[0012] Preferably, the obtaining of the gradient severity of each pixel point in the milk powder surface image includes:

[0013] Obtain the neighborhood pixels of each pixel point;

[0014] ;

[0015] In the formula, represents the gradient severity of the m-th pixel point; represents the number of neighborhood pixels of the m-th pixel point; represents the gray value of the m-th pixel point; represents the gray value of the e-th neighborhood pixel of the m-th pixel point; represents the variance of the grayscale values of the neighborhood pixels of the m-th pixel; || represents the absolute value symbol; exp() represents the exponential function with the natural constant as the base.

[0016] Preferably, the obtaining of the neighborhood pixels of each pixel includes:

[0017] Regarding each pixel in the eight-neighborhood of each pixel as the neighborhood pixel of each pixel.

[0018] Preferably, the obtaining of the number of edge pixels in the neighborhood area of the pixel includes:

[0019] Preset the side length of the neighborhood area , use the canny edge detection algorithm to detect the milk powder surface image, and obtain the edge pixels in the milk powder surface image; construct a neighborhood area with as the neighborhood area of each pixel, and obtain the number of edge pixels in the neighborhood area of each pixel.

[0020] It is convenient to subsequently analyze the potential impurity probability of each pixel.

[0021] Preferably, the obtaining of the possibility that each pixel is a noise pixel includes:

[0022] ;

[0023] In the formula, represents the possibility that the m-th pixel is a noise pixel; represents the degree of gradient sharpness of the m-th pixel; represents the potential impurity probability of the m-th pixel; exp() represents the exponential function with the natural constant as the base.

[0024] It is convenient to subsequently correct the distance between each pair of pixels in each group of clusters, obtain the representativeness of each pair of representative pixels in each group of clusters, and then select the distance between the pair of representative pixels with the greatest representativeness as the distance between each group of clusters more accurately.

[0025] Preferably, the obtaining of each pair of representative pixels of each group of clusters includes:

[0026] Obtain each pair of pixels in each group of clusters and the distance between each pair of pixels;

[0027] Preset the logarithmic parameter G of pixel pairs. If the number of pixel pairs in the i-th cluster is less than or equal to G, at this time, the pair of pixel points corresponding to the maximum distance in the i-th cluster is denoted as a pair of representative pixel points of the i-th cluster; if the number of pixel pairs in the i-th cluster is greater than G, according to the order of the distances of each pair of pixel points in the i-th cluster from large to small, all pairs of pixel points in the i-th cluster are sorted to obtain the pixel pair sequence of the i-th cluster, and the first G pairs of pixel points in the pixel pair sequence of the i-th cluster are denoted as each pair of representative pixel points of the i-th cluster.

[0028] Preferably, the obtaining of each pair of pixel points and the distance between each pair of pixel points in each cluster includes:

[0029] When using the hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, any two clusters are denoted as a group of clusters; randomly obtain one pixel point from each of the two clusters in any group of clusters to obtain a pair of pixel points of this group of clusters. Similarly, obtain several pairs of pixel points of this group of clusters; denote the absolute value of the difference in the gray values of each pair of pixel points in this group of clusters as the distance between each pair of pixel points in this group of clusters.

[0030] Preferably, the obtaining of the distance between each group of clusters includes:

[0031] Denote the pair of representative pixel points corresponding to the maximum value in the representation degree as the optimal representative pixel points, and use the distance of the optimal representative pixel points as the distance between the i-th group of clusters.

[0032] It avoids the influence of noise pixel points on the distance between each group of clusters.

[0033] Preferably, the identifying of the impurity region pixel points according to the clustering result includes:

[0034] Preset a distance threshold T2. If the distance between any two groups of clusters in the clustering result is less than the distance threshold, denote the two clusters in this group of clusters as the clusters to be analyzed, and obtain several clusters to be analyzed in the clustering result; if the number of pixel points in any cluster to be analyzed is greater than 1 and less than 5, denote the pixel points in this cluster to be analyzed as the impurity region pixel points.

[0035] The obtained impurity region pixel points are more accurate.

[0036] In a second aspect, the present invention provides a milk powder quality detection system based on image processing, adopting the following technical solution:

[0037] A milk powder quality detection system based on image processing includes: a processor and a memory, and the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned milk powder quality detection method based on image processing is implemented.

[0038] By adopting the above technical solution, a computer program is generated from the above method for detecting the quality of milk powder based on image processing and stored in a memory to be loaded and executed by a processor, so as to manufacture a terminal device according to the memory and the processor, which is convenient to use.

[0039] The present invention has the following technical effects: The purpose of the present invention is to analyze the difference between the impurity region and the noise pixel points, obtain the potential impurity probability of each pixel point, correct the gradient severity of the pixel points according to the potential impurity probability, and obtain the possibility of each pixel point being a noise pixel point, avoiding the influence of the pixel points in the impurity region on the accuracy of the recognition of noise pixel points; then, according to the possibility of each pixel point being a noise pixel point, the distance between each pair of representative pixel points in each group of clusters is corrected to obtain the representativeness of each pair of representative pixel points in each group of clusters; furthermore, the distance between the pair of representative pixel points with the largest representativeness is selected as the distance between each group of clusters for merging, solving the influence of the noise pixel points on the distance between each group of clusters, facilitating the subsequent obtaining of a more accurate clustering result and identifying the pixel points in the impurity region. Description of the Drawings

[0040] Figure 1 is the flowchart of the method in an embodiment of the method for detecting the quality of milk powder based on image processing according to the present invention. Detailed Embodiments

[0041] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention.

[0042] An embodiment of the present invention discloses a method for detecting the quality of milk powder based on image processing. Referring to Figure 1 , it includes steps S1 - S4:

[0043] S1: Collect the image of the milk powder surface.

[0044] In the implementation of the present invention, a high - definition camera is used to shoot the surface of the milk powder to obtain the RGB image of the milk powder surface. Then, the RGB image of the milk powder surface is grayscale - processed to obtain the image of the milk powder surface.

[0045] S2: Obtain the neighborhood pixel points of each pixel point in the milk powder surface image. Based on the neighborhood pixel points, obtain the gradient severity of each pixel point; obtain the potential impurity probability of each pixel point; according to the gradient severity and the potential impurity probability, obtain the possibility of each pixel point being a noise pixel point.

[0046] It should be noted that in the process of recursively clustering potential impurity defects in the milk powder surface image using the agglomerative hierarchical clustering algorithm, if the complete-linkage method is used for aggregation, when determining whether two clusters are merged, the farthest distance between the two clusters will be selected as the basis (the maximum gray value difference between pixel points). However, during the acquisition and transmission of the milk powder surface image, data loss or damage may occur, resulting in noise in some areas of the milk powder surface image. The existence of noise pixel points may lead to inaccurate farthest distances between two clusters.

[0047] It should be further noted that since noise pixel points usually have a large gray value difference from their neighboring pixel points, therefore, if the gray value of any pixel point has a large numerical difference from the gray values of its neighboring pixel points, it indicates that the gradient intensity of this pixel point is greater; if the gray value difference of the neighboring pixel points of this pixel point is smaller, it indicates that the gray value difference between this pixel point and its neighboring pixel points is more accurate, and then the gradient intensity of this pixel point is greater.

[0048] In the embodiment of the present invention, each pixel point in the eight-neighborhood of each pixel point is used as the neighboring pixel point of each pixel point;

[0049] Obtain the gradient intensity of each pixel point:

[0050] ;

[0051] In the formula, represents the gradient intensity of the m-th pixel point; represents the number of neighboring pixel points of the m-th pixel point; represents the gray value of the m-th pixel point; represents the gray value of the e-th neighboring pixel point of the m-th pixel point; represents the variance of the gray values of the neighboring pixel points of the m-th pixel point; || represents the absolute value symbol; exp() represents the exponential function with the natural constant as the base;

[0052] Among them, When the value of is larger, it indicates that the gray value difference between the m-th pixel point and its neighboring pixel points is larger. At this time, the gradient intensity of the m-th pixel point is greater, indicating that the m-th pixel point is more likely to belong to noise pixel points; When the value of is smaller, it indicates that the gray values of the neighboring pixel points of the m-th pixel point are more uniform. At this time, if the gray value difference between the m-th pixel point and its neighboring pixel points is larger, it indicates that the m-th pixel point is more likely to be noise data.

[0053] It should be noted that since there are potential impurity regions in the milk powder surface image, it can be known that the gray values of the edge pixels of the potential impurity regions in the milk powder surface image are relatively close to those of the noise pixels, and the gray value differences between the edge pixels of the potential impurity regions and their neighboring pixels are also relatively large. Therefore, simply relying on the degree of gradient sharpness of the pixels cannot distinguish the noise pixels from the edge pixels of the potential impurity regions;

[0054] The noise pixels are relatively isolated in the milk powder surface image. When the pixel is an edge pixel of a potential impurity region, there will be other edge pixels of potential impurity regions in its neighborhood. Therefore, it is first necessary to perform edge detection on the milk powder surface image to obtain the edge pixels of the milk powder surface image. If the number of edge pixels in the neighborhood region of any pixel is larger, it indicates that the potential impurity probability of this pixel is higher; also, since the edge pixels of the same potential impurity region appear in clusters, if the number of edge pixels in the neighborhood region of any pixel is larger and the distance between the edge pixels is smaller, it indicates that the potential impurity probability of this pixel is higher.

[0055] In the embodiment of the present invention, the canny edge detection algorithm is used to detect the milk powder surface image to obtain the edge pixels in the milk powder surface image; a neighborhood region centered on each pixel in the milk powder surface image is constructed as the neighborhood region of each pixel. The preset side length B of the neighborhood region is 10. In other embodiments, the implementer can preset the value of B according to the specific implementation manner.

[0056] Obtain the potential impurity probability of each pixel:

[0057] ;

[0058] In the formula, represents the potential impurity probability of the m-th pixel; represents the number of edge pixels in the neighborhood region of the m-th pixel; represents the average value of the Euclidean distances between the j-th edge pixel and all other edge pixels in the neighborhood region of the m-th pixel;

[0059] The larger the value of, the greater the possibility that the edge pixels in the reference region of the m-th pixel belong to the potential impurity edge, and then the higher the potential impurity probability of the m-th pixel; The smaller the value of, the more aggregated the distribution of the edge pixels in the reference region of the m-th pixel, then it can be explained that the greater the possibility that the edge pixels in the reference region of the m-th pixel belong to the potential impurity edge, and then the higher the potential impurity probability of the m-th pixel.

[0060] It should be noted that the greater the degree of gradient sharpness, the greater the possibility that the pixel is a noise pixel or an edge pixel of a potential impurity region. At this time, if the potential impurity probability of the pixel is smaller, it indicates that the pixel is more likely to be a noise pixel; if the potential impurity probability of the pixel is larger, it indicates that the pixel is more likely to be an edge pixel of a potential impurity region. Therefore, the potential impurity probability of the pixel and the degree of gradient sharpness of the pixel are used to obtain the possibility that the pixel is a noise pixel.

[0061] Obtain the possibility that each pixel is a noise pixel:

[0062] ;

[0063] In the formula, represents the possibility that the m-th pixel is a noise pixel; represents the degree of gradient sharpness of the m-th pixel; represents the potential impurity probability of the m-th pixel; exp() represents the exponential function with the natural constant as the base. When the degree of gradient sharpness of the m-th pixel is greater and the potential impurity probability of the m-th pixel is smaller, it indicates that the possibility that the m-th pixel is a noise pixel is greater.

[0064] The larger the value of, the greater the degree of gradient sharpness when the m-th pixel is analyzed based on the gray values of its neighboring pixels, and then the greater the possibility that the m-th pixel is a noise pixel; The larger, the greater the possibility that all edge pixels in the reference region of the m-th pixel belong to the potential impurity edge, and then the smaller the possibility that the m-th pixel is a noise pixel.

[0065] S3: Cluster the pixels in the milk powder surface image, obtain the representativeness of each pair of representative pixels in each cluster group, and get the distance between each cluster group.

[0066] It should be noted that during the process of recursively clustering the potential impurity defects in the milk powder surface image using the agglomerative hierarchical clustering algorithm, if the complete-linkage method is used for aggregation, then when determining whether two clusters are merged, the farthest distance between the two clusters (the maximum gray value difference between pixels) will be selected as the basis to judge whether the two clusters are merged. However, in order to improve the accuracy of the merger, it is necessary to correct the farthest distance between the two clusters according to the possibility that the pixel is a noise pixel to exclude the influence of noise on the merger;

[0067] Therefore, in this step, several pairs of pixel points with large differences in grayscale values need to be selected from each group of clusters as each pair of representative pixel points for each group of clusters. Then, the grayscale difference between each pair of representative pixel points is corrected according to the average value of the probabilities that the two pixel points in each pair of representative pixel points are noise pixel points, and the representativeness of each pair of representative pixel points is obtained. If the grayscale difference between any pair of representative pixel points in any group of clusters is larger, and the average value of the probabilities that the two pixel points in this pair of representative pixel points are noise pixel points is smaller, it indicates that the representativeness of this pair of representative pixel points in this group of clusters is greater. At this time, the distance between this pair of representative pixel points in this group of clusters should be used as the distance between this group of clusters.

[0068] In the embodiment of the present invention, when using the hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, any two clusters are recorded as a group of clusters; any one pixel point is obtained from each of the two clusters in any group of clusters to obtain a pair of pixel points for this group of clusters. Similarly, several pairs of pixel points for this group of clusters are obtained; the absolute value of the difference in grayscale values of each pair of pixel points in this group of clusters is recorded as the distance between each pair of pixel points in this group of clusters.

[0069] Preset the parameter G for the number of pairs of pixel points , if the number of pairs of pixel points in the i-th group of clusters is less than or equal to G, at this time, the pair of pixel points corresponding to the maximum distance in the i-th group of clusters is recorded as a pair of representative pixel points for the i-th group of clusters;

[0070] If the number of pairs of pixel points in the i-th group of clusters is greater than G, all pairs of pixel points in the i-th group of clusters are sorted according to the order of the distances from large to small of each pair of pixel points in the i-th group of clusters to obtain the sequence of pairs of pixel points in the i-th group of clusters, and the first G pairs of pixel points in the sequence of pairs of pixel points in the i-th group of clusters are recorded as each pair of representative pixel points for the i-th group of clusters.

[0071] Obtain the representativeness of each pair of representative pixel points for each group of clusters:

[0072] ;

[0073] In the formula, represents the representativeness of the j-th pair of representative pixel points in the i-th group of clusters; represents the average value of the probabilities that the two pixel points in the j-th pair of representative pixel points in the i-th group of clusters are noise pixel points; represents the distance between the j-th pair of representative pixel points in the i-th group of clusters; the smaller the average value of the probabilities that the two pixel points in the j-th pair of representative pixel points are noise pixel points, the higher the authenticity of the two pixel points in the j-th pair of representative pixel points. Then, the distance between the j-th pair of representative pixel points in the i-th group of clusters should be used as the distance for the complete linkage of this group of clusters. At this time, the representativeness of the j-th pair of representative pixel points in the i-th group of clusters is greater.

[0074] Denote the pair of representative pixel points corresponding to the maximum value in the degree as the optimal representative pixel points, and use the distance between the optimal representative pixel points as the distance between the i-th group of clusters.

[0075] S4: Substitute the method for obtaining the distance between each group of clusters into the agglomerative hierarchical clustering algorithm to cluster the milk powder surface image, obtain the clustering result, and identify the impurity region pixel points according to the clustering result.

[0076] It should be noted that the optimization of the complete-linkage method in the recursive aggregation process of the agglomerative hierarchical clustering algorithm is realized. In this step, the optimized agglomerative hierarchical clustering algorithm will be used to detect potential impurities in milk powder. First, substitute the distance between each optimized group of clusters into the agglomerative hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, obtain the clustering result. Then, if the distance between two clusters in the clustering result is larger, it means that these two clusters are less similar. Then, mark these two clusters as the clusters to be analyzed. It is known that the number of pixel points in the noise cluster is very small, and the number of pixel points in the normal cluster is relatively large. After setting a threshold to exclude the noise cluster and the normal cluster in the clusters to be analyzed, the impurity region pixel points are obtained.

[0077] In the embodiment of the present invention, substitute the calculation method of the distance between each group of clusters into the agglomerative hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, and obtain the clustering result;

[0078] Preset the distance threshold T2 = 3. In other embodiments, the implementer can preset the value of T2 according to the specific implementation situation. If the distance between two clusters in any group of clusters in the clustering result is less than the distance threshold when they are merged, mark these two clusters in this group of clusters as the clusters to be analyzed, and obtain several clusters to be analyzed in the clustering result.

[0079] If the number of pixel points in any cluster to be analyzed is greater than 1 and less than 5, mark the pixel points in this cluster to be analyzed as the impurity region pixel points.

[0080] The embodiment of the present invention also discloses a milk powder quality detection system based on image processing, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, a milk powder quality detection method based on image processing according to the present invention is implemented.

[0081] The above system also includes other components well-known to those skilled in the art such as a communication bus and a communication interface, and their settings and functions are known in the art, so they will not be elaborated here.

[0082] In the present invention, the aforementioned memory may be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as, a resistive random access memory, a dynamic random access memory, a static random access memory, an enhanced dynamic random access memory, a high bandwidth memory, a hybrid memory cube, etc., or any other medium that can be used to store the required information and can be accessed by an application program, a module, or both. Any such computer storage medium may be part of the device or accessible or connectable to the device.

[0083] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features.

Claims

1. A milk powder quality detection method based on image processing, characterized in that, Including the steps: Collect the surface image of the milk powder, and obtain the gradient severity of each pixel point in the surface image of the milk powder, including: Obtain the neighboring pixel points of each pixel point; ; Wherein, represents the gradient severity of the m-th pixel; represents the number of neighboring pixels of the m-th pixel; represents the gray value of the m-th pixel; represents the gray value of the e-th neighboring pixel of the m-th pixel; represents the variance of the gray values of the neighboring pixels of the m-th pixel; || represents the absolute value symbol; exp() represents the exponential function with the natural constant as the base; Obtain the potential impurity probability of each pixel point , represents the potential impurity probability of the m-th pixel point; represents the number of edge pixel points in the neighborhood area of the m-th pixel point; represents the average value of the Euclidean distances between the j-th edge pixel point and all other edge pixel points in the neighborhood area of the m-th pixel point; According to the gradient severity and the potential impurity probability, obtain the possibility that each pixel point is a noise pixel point; Obtain each pair of representative pixel points of each cluster, including: Obtain each pair of pixel points in each cluster and the distance between each pair of pixel points; Preset the pixel point pair parameter G. If the number of pixel point pairs in the i-th cluster is less than or equal to G, at this time, the pair of pixel points corresponding to the maximum distance in the i-th cluster is denoted as a pair of representative pixel points of the i-th cluster; if the number of pixel point pairs in the i-th cluster is greater than G, according to the order from large to small of the distances between each pair of pixel points in the i-th cluster, sort all pairs of pixel points in the i-th cluster to obtain the pixel point pair sequence of the i-th cluster, and denote the first G pairs of pixel points in the pixel point pair sequence of the i-th cluster as each pair of representative pixel points of the i-th cluster; Obtain the representativeness of each pair of representative pixel points of each cluster: , represents the representative degree of the j-th pair of representative pixel points in the i-th group of clusters; represents the mean of the probabilities that the two pixel points in the j-th pair of representative pixel points in the i-th group of clusters are noise pixel points; represents the distance between the j-th pair of representative pixel points in the i-th group of clusters; norm() represents the normalization function; Based on the representativeness, obtain the distance between each cluster; substitute the method for obtaining the distance between each cluster into the agglomerative hierarchical clustering algorithm to cluster the surface image of the milk powder, obtain the clustering result, and identify the impurity region pixel points according to the clustering result.

2. The milk powder quality detection method based on image processing according to claim 1, wherein, The obtaining of the neighboring pixel points of each pixel point includes: Take each pixel point in the eight-neighborhood of each pixel point as the neighboring pixel point of each pixel point.

3. A milk powder quality detection method based on image processing according to claim 1, characterized in that, The obtaining of the number of edge pixel points in the neighborhood area of the pixel point includes: Preset neighborhood area side length , use the canny edge detection algorithm to detect the milk powder surface image, and obtain the edge pixel points in the milk powder surface image; construct neighborhood area with each pixel point in the milk powder surface image as the center, as the neighborhood area of each pixel point, and obtain the number of edge pixel points in the neighborhood area of each pixel point.

4. The milk powder quality detection method based on image processing according to claim 1, characterized in that, The obtaining of the possibility that each pixel point is a noise pixel point includes: ; In the formula, represents the possibility that the m-th pixel is a noise pixel; represents the gradient intensity of the m-th pixel; represents the potential impurity probability of the m-th pixel; exp() represents the exponential function with the natural constant as the base.

5. A method for detecting the quality of milk powder based on image processing according to claim 1, characterized in that, The obtaining of each pair of pixel points in each cluster and the distance between each pair of pixel points includes: When using the hierarchical clustering algorithm to cluster the pixel points in the surface image of the milk powder, record any two clusters as a group cluster; obtain any one pixel point from each of the two clusters in any group cluster to obtain a pair of pixel points of the group cluster. Similarly, obtain several pairs of pixel points of the group cluster; denote the absolute value of the difference in the gray values of each pair of pixel points of the group cluster as the distance between each pair of pixel points of the group cluster.

6. The milk powder quality detection method based on image processing according to claim 1, wherein The obtaining of the distance between each cluster includes: Denote the pair of representative pixel points corresponding to the maximum value in the representativeness as the optimal representative pixel points, and take the distance between the optimal representative pixel points as the distance between the i-th clusters.

7. A method for detecting the quality of milk powder based on image processing according to claim 1, characterized in that, The identifying of the impurity region pixel points according to the clustering result includes: Preset the distance threshold T2. If the distance between any two clusters in the clustering result is less than the distance threshold, denote the two clusters in the group cluster as the clusters to be analyzed, and obtain several clusters to be analyzed in the clustering result; if the number of pixel points in any cluster to be analyzed is greater than 1 and less than 5, denote the pixel points in the cluster to be analyzed as the impurity region pixel points.

8. A milk powder quality detection system based on image processing, characterized in that, Including: A processor and a memory, the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a method for detecting the quality of milk powder based on image processing according to any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Infant food safety visual detection method

    CN116912820A

  • Milk powder quality visual detection method and system

    CN118691607A