Milk powder quality detection method and system based on image processing

By analyzing the possibility of noise pixel points in the surface image of milk powder and correcting the clustering distance, the problem of noise affecting clustering results is solved, and more accurate identification of impurity areas is achieved.

CN120147306AActive Publication Date: 2025-06-13SHAANXI SHENGQUAN DAIRY TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When clustering milk powder surface images using a condensed hierarchical clustering algorithm, the presence of noisy pixel points may lead to inaccurate acquisition of the farthest distance between the two clusters, affecting the accuracy of the clustering results.

Method used

By analyzing the gradient intensity and potential impurity probability of each pixel point, the possibility that each pixel point is a noisy pixel point is obtained, and the distance between each cluster is corrected according to these possibilities, and the distance between each cluster with the largest degree is selected as the distance between each cluster for merging.

Benefits of technology

The influence of noisy pixel points on clustering results is effectively avoided, the accuracy of clustering results is improved, and the pixel points in impurity areas can be more accurately identified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120147306A_ABST
    Figure CN120147306A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a milk powder quality detection method and system based on image processing. The method comprises the steps of collecting a milk powder surface image, obtaining a neighborhood pixel point of each pixel point in the milk powder surface image, and obtaining the gradient intensity of each pixel point based on the neighborhood pixel points; obtaining the potential impurity probability of each pixel point; obtaining the possibility that each pixel point is a noise pixel point according to the gradient intensity and the potential impurity probability, clustering the pixel points in the milk powder surface image, obtaining the representation degree of each pair of representative pixel points of each cluster, obtaining the distance between the clusters, and obtaining the distance between the clusters; and substituting an acquisition method of the distance between each group of clusters into an agglomerated hierarchical clustering algorithm to cluster the milk powder surface image to obtain a clustering result, and identifying the pixel points of the impurity region according to the clustering result, so that the accuracy of impurity region detection is improved.
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 lead to inaccurate determination of the farthest distance between the two clusters. 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 lead to inaccurate determination 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 the first aspect, the present invention provides a milk powder quality detection method based on image processing, adopting the following technical solution: A milk powder quality detection method based on image processing includes the steps of: Collect a milk powder surface image and obtain the gradient severity of each pixel point in the milk powder surface image; 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 Euclidean distance between the j-th edge pixel and all other edge pixels in the neighborhood area of the m-th pixel; according to the gradient severity and the potential impurity probability, obtain the possibility that each pixel is a noise pixel; Obtain each pair of representative pixels of each group of clusters; obtain the representativeness of each pair of representative pixels of each group of clusters , represents the representativeness of the j-th pair of representative pixels of the i-th group of clusters; represents the average possibility that the two pixels in the j-th pair of representative pixels of the i-th group of clusters are noise pixels; represents the distance between the j-th pair of representative pixels of the i-th group of clusters; norm() represents the normalization function; 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 pixels according to the clustering result.

[0006] The innovation of the present invention lies in analyzing the difference between the impurity region and the noise pixels, obtaining the potential impurity probability of each pixel, correcting the gradient severity of the pixel according to the potential impurity probability, obtaining the possibility that each pixel is a noise pixel, and avoiding the accuracy of the noise pixel recognition by the impurity region pixels; then correcting the distance between each pair of representative pixels of each group of clusters according to the possibility that each pixel is a noise pixel, obtaining the representativeness of each pair of representative pixels of each group of clusters; furthermore, selecting the distance between the pair of representative pixels with the largest representativeness as the distance between each group of clusters for merging, solving the influence of the noise pixels on the distance between each group of clusters, facilitating the subsequent obtaining of a more accurate clustering result and identifying the impurity region pixels.

[0007] Preferably, the obtaining of the gradient severity of each pixel in the milk powder surface image includes: Obtain the neighborhood pixels of each pixel; ; In the formula, represents the gradient severity of the m-th pixel; represents the number of neighborhood pixels of the m-th pixel; represents the gray value of the m-th pixel; represents the gray value of the e-th neighborhood pixel of the m-th pixel; represents the variance of the gray 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.

[0008] Preferably, the obtaining of the neighborhood pixels of each pixel includes: Each pixel in the eight-neighborhood of each pixel point is used as the neighborhood pixel of each pixel point.

[0009] Preferably, obtaining the number of edge pixels in the neighborhood area of the pixel point includes: Preset the side length of the neighborhood area , use the canny edge detection algorithm to detect the milk powder surface image to obtain the edge pixels in the milk powder surface image; construct a neighborhood area with a radius centered on each pixel in the milk powder surface image as the neighborhood area of each pixel point, and obtain the number of edge pixels in the neighborhood area of each pixel point.

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

[0011] Preferably, obtaining the possibility that each pixel point is a noise pixel point includes: ; In the formula, represents the possibility that the m-th pixel point is a noise pixel point; represents the gradient severity of the m-th pixel point; represents the potential impurity probability of the m-th pixel point; exp() represents the exponential function with the natural constant as the base.

[0012] It is convenient to subsequently correct the distance between each pair of pixel points in each group of clusters, obtain the representative degree of each pair of representative pixel points in each group of clusters, and then select the distance between the pair of representative pixel points with the largest representative degree as the distance between each group of clusters more accurately.

[0013] Preferably, obtaining each pair of representative pixel points in each group of clusters includes: Obtain each pair of pixel points in each group of clusters 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 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 denoted as a pair of representative pixel points in the i-th group of clusters; if the number of pixel point pairs in the i-th group of clusters is greater than G, sort all pairs of pixel points in the i-th group of clusters according to the order from large to small of the distance between each pair of pixel points in the i-th group of clusters to obtain the pixel point pair sequence of the i-th group of clusters, and denote the first G pairs of pixel points in the pixel point pair sequence of the i-th group of clusters as each pair of representative pixel points in the i-th group of clusters.

[0014] Preferably, obtaining each pair of pixel points in each group of clusters and the distance between each pair of pixel points includes: When clustering the pixel points in the milk powder surface image using the hierarchical clustering algorithm, any two clusters are recorded as a group cluster; any one pixel point is obtained from each of the two clusters of any group cluster to obtain a pair of pixel points of the group cluster. Similarly, several pairs of pixel points of the group cluster are obtained; the absolute value of the difference in the gray values of each pair of pixel points of the group cluster is recorded as the distance between each pair of pixel points of the group cluster.

[0015] Preferably, the obtaining the distance between each group cluster includes: The pair of representative pixel points corresponding to the maximum value in the degree of representation is recorded as the optimal representative pixel point, and the distance of the optimal representative pixel point is used as the distance between the i-th group clusters.

[0016] The influence of noise pixel points on the distance between each group cluster is avoided.

[0017] Preferably, the identifying the impurity region pixel points according to the clustering result includes: A distance threshold T2 is preset. If the distance between any group clusters in the clustering result is less than the distance threshold, the two clusters in the group cluster are recorded as the clusters to be analyzed, and several clusters to be analyzed in the clustering result are obtained; if the number of pixel points in any cluster to be analyzed is greater than 1 and less than 5, the pixel points in the cluster to be analyzed are recorded as the impurity region pixel points.

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

[0019] In a second aspect, the present invention provides a milk powder quality detection system based on image processing, adopting the following technical solution: A milk powder quality detection system based on image processing includes: a processor and a memory. 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.

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

[0021] 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, obtain the possibility that each pixel point is a noise pixel point, and avoid the influence of the pixel points in the impurity region on the accuracy of the recognition of noise pixel points; then correct the distance between each pair of representative pixel points of each cluster according to the possibility that each pixel point is a noise pixel point, obtain the representativeness of each pair of representative pixel points of each cluster; and then select the distance between the pair of representative pixel points with the largest representativeness as the distance between each cluster for merging, solve the influence of the noise pixel points on the distance between each cluster, facilitate obtaining a more accurate clustering result subsequently, and identify the pixel points in the impurity region. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is the flowchart of a milk powder quality detection method based on image processing in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

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

[0024] An embodiment of the present invention discloses a milk powder quality detection method based on image processing. Refer to Figure 1 , including steps S1 - S4: S1: Collect the milk powder surface image.

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

[0026] S2: Obtain the neighborhood pixel points of each pixel point in the milk powder surface image, and 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 that each pixel point is a noise pixel point.

[0027] It should be noted that in the process of recursively clustering the potential impurity defects in the milk powder surface image using the agglomerative hierarchical clustering algorithm, if the complete - link method is used for aggregation, then when determining whether two clusters are merged, the farthest distance between the two clusters (the maximum gray - level difference between pixel points) will be selected as the basis. 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.

[0028] It should be further noted that since the gray value of a noise pixel point usually has a large difference from that of its neighboring pixel points, therefore, if the gray value of any pixel point has a large numerical difference from that 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, then the gradient intensity of this pixel point is greater.

[0029] 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; Obtain the gradient intensity of each pixel point: ; 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; 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 the noise pixel point; 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.

[0030] It should be noted that since there are potential impurity regions in the milk powder surface image, it can be known that the edge pixel points of the potential impurity regions in the milk powder surface image are relatively close to the gray values of the noise pixel points, and the gray value difference between the edge pixel points of the potential impurity regions and their neighboring pixel points is also large. Therefore, simply relying on the gradient intensity of the pixel points cannot distinguish the noise pixel points from the edge pixel points of the potential impurity regions; Noise pixel points are relatively isolated on the milk powder surface image. When a pixel point is an edge pixel point of a potential impurity area, there will be other edge pixel points of potential impurity areas in its neighborhood. Therefore, it is first necessary to perform edge detection on the milk powder surface image to obtain the edge pixel points of the milk powder surface image. The more the number of edge pixel points in the neighborhood area of any pixel point, the greater the probability of potential impurities for that pixel point. Also, since the edge pixel points of the same potential impurity area appear in clusters, if the number of edge pixel points in the neighborhood area of any pixel point is larger and the distance between the edge pixel points is smaller, it indicates that the probability of potential impurities for that pixel point is greater.

[0031] 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 pixel points in the milk powder surface image; a neighborhood area centered on each pixel point in the milk powder surface image is constructed as the neighborhood area of each pixel point. The preset side length B of the neighborhood area is 10. In other embodiments, the implementer can preset the value of B according to the specific implementation manner.

[0032] Obtain the potential impurity probability of each pixel point: ; In the formula, 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; The larger the value of, the greater the possibility that the edge pixel points in the reference area of the m-th pixel point belong to the potential impurity edge, and then the greater the potential impurity probability of the m-th pixel point; The smaller the value of, the more aggregated the distribution of the edge pixel points in the reference area of the m-th pixel point, which can indicate that the edge pixel points in the reference area of the m-th pixel point are more likely to belong to the potential impurity edge, and then the greater the potential impurity probability of the m-th pixel point.

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

[0034] Obtain the possibility that each pixel is a noise pixel: ; 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; when the gradient intensity 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.

[0035] The larger the value of, the greater the gradient intensity of the m-th pixel when analyzing the gray value of its neighboring pixels, and then the greater the possibility that the m-th pixel is a noise pixel; The larger the, the greater the possibility that all edge pixels in the reference area of the m-th pixel belong to potential impurity edges, and then the smaller the possibility that the m-th pixel is a noise pixel.

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

[0037] 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 used 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; Therefore, in this step, several pairs of pixels with large gray value differences need to be selected in each group of clusters as each pair of representative pixels in each group of clusters, and then the gray value difference between each pair of representative pixels is corrected according to the average value of the possibility that each pair of representative pixels in each group of clusters is a noise pixel to obtain the representativeness of each pair of representative pixels. If the gray value difference of any pair of representative pixels in any group of clusters is larger, and the average value of the possibility that the two pixels in this pair of representative pixels are noise pixels is smaller, it indicates that the representativeness of this pair of representative pixels in this group of clusters is greater. At this time, the distance between this pair of representative pixels in this group of clusters should be used as the distance between this group of clusters.

[0038] In an embodiment of the present invention, when using the hierarchical clustering algorithm to cluster pixel points in the milk powder surface image, any two clusters are denoted as a group cluster; any one pixel point is obtained from each of the two clusters of any group cluster to obtain a pair of pixel points of the group cluster. Similarly, several pairs of pixel points of the group cluster are obtained; the absolute value of the difference in gray values of each pair of pixel points of the group cluster is denoted as the distance between each pair of pixel points of the group cluster. Preset pixel point pair number parameter G , if the number of pixel point pairs of the i-th group 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 group cluster is denoted as a pair of representative pixel points of the i-th group cluster; If the number of pixel point pairs of the i-th group cluster is greater than G, all pairs of pixel points of the i-th group cluster are sorted according to the order of the distances of each pair of pixel points of the i-th group cluster from large to small to obtain the pixel point pair sequence of the i-th group cluster, and the first G pairs of pixel points in the pixel point pair sequence of the i-th group cluster are denoted as each pair of representative pixel points of the i-th group cluster.

[0039] Obtain the representativeness of each pair of representative pixel points of each group cluster: ; In the formula, represents the representativeness of the j-th pair of representative pixel points of the i-th group cluster; represents the mean value of the probabilities that the two pixel points in the j-th pair of representative pixel points of the i-th group cluster are noise pixel points; represents the distance of the j-th pair of representative pixel points of the i-th group cluster; the smaller the mean 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 of the j-th pair of representative pixel points of the i-th group cluster should be used as the distance in the complete linkage of the group cluster. At this time, the representativeness of the j-th pair of representative pixel points of the i-th group cluster is greater.

[0040] The pair of representative pixel points corresponding to the maximum value in the representativeness is denoted as the optimal representative pixel points, and the distance of the optimal representative pixel points is used as the distance between the i-th group clusters.

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

[0042] It should be noted that the optimization of the complete-linkage method in the recursive aggregation process of the agglomerative hierarchical clustering algorithm is achieved. In this step, the optimized agglomerative hierarchical clustering algorithm will be used to detect potential impurities in milk powder. First, the distance between each optimized group of clusters is substituted into the agglomerative hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, and the clustering result is obtained. Then, if the distance between two clusters in the clustering result is larger, it means that these two clusters are less similar, and then these two clusters are marked as 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 pixel points of the impurity area are obtained.

[0043] In the embodiment of the present invention, the calculation method of the distance between each group of clusters is substituted into the agglomerative hierarchical clustering algorithm to cluster the pixel points in the milk powder surface image, and the clustering result is obtained; The preset 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 any group of clusters in the clustering result is less than the distance threshold when they are merged, the two clusters in this group of clusters are marked as clusters to be analyzed, and several clusters to be analyzed in the clustering result are obtained.

[0044] If the number of pixel points in any cluster to be analyzed is greater than 1 and less than 5, the pixel points in this cluster to be analyzed are marked as pixel points of the impurity area.

[0045] 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.

[0046] 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.

[0047] In the present invention, the aforementioned memory can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, device, or device. For example, a computer-readable storage medium can 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 storage 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 can be a part of the device or accessible or connectable to the device.

[0048] 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 described 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: Includes steps: Collecting a surface image of milk powder to obtain the gradient intensity of each pixel point in the surface image of milk powder; Get the potential impurity probability of each pixel , Represents the potential impurity probability of the mth pixel; Represents the number of edge pixels in the neighborhood of the mth pixel; represents the mean of the Euclidean distances between the jth edge pixel and all other edge pixels in the neighborhood of the mth pixel; and obtaining the possibility that each pixel is a noise pixel based on the gradient severity and the potential impurity probability; Get each pair of representative pixels of each cluster; Get the representative degree of each pair of representative pixels of each cluster , represents the representative degree of the jth pair of pixels in the i-th cluster; The jth pair of pixels representing the i-th cluster represents the mean of the probability that the two pixels are noise pixels; represents the distance between the jth pair of pixels in the i-th cluster; norm() represents the normalization function; Based on the representativeness, the distance between each group of clusters is obtained; the method for obtaining the distance between each group of clusters is substituted into the agglomerative hierarchical clustering algorithm to cluster the milk powder surface image to obtain the clustering result, and the impurity area pixel points are identified according to the clustering result.

2. The method for detecting milk powder quality based on image processing according to claim 1, characterized in that: The step of obtaining the gradient severity of each pixel point in the milk powder surface image comprises: Get the neighborhood pixels of each pixel; ; In the formula, Represents the gradient intensity of the mth pixel; Represents the number of neighboring pixels of the mth pixel; Represents the gray value of the mth pixel; Represents the gray value of the e-th neighboring pixel of the m-th pixel; Represents the gray value variance of the neighborhood pixels of the mth pixel; || represents the absolute value sign; exp() represents an exponential function with a natural constant as the base.

3. A milk powder quality detection method based on image processing according to claim 2, characterized in that: The step of obtaining the neighboring pixel points of each pixel point includes: Each pixel in the eight neighborhoods of each pixel is regarded as a neighborhood pixel of each pixel.

4. The method for detecting milk powder quality based on image processing according to claim 1, characterized in that: The acquisition of the number of edge pixels 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 a The neighborhood area of ​​​​the pixel point is taken as the neighborhood area of ​​​​each pixel point, and the number of edge pixels in the neighborhood area of ​​​​each pixel point is obtained.

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

6. The method for detecting milk powder quality based on image processing according to claim 1, characterized in that: The step of obtaining each pair of representative pixel points of each cluster includes: Get each pair of pixels in each cluster and the distance between each pair of pixels; A pixel pair number parameter G is preset. If the number of pixel pairs of the i-th cluster is less than or equal to G, a pair of pixel points corresponding to the maximum distance in the i-th cluster is recorded as a pair of representative pixel points of the i-th cluster. If the number of pixel pairs of the i-th cluster is greater than G, all pairs of pixels of the i-th cluster are sorted in descending order according to the distance of each pair of pixels in the i-th cluster to obtain the pixel pair sequence of the i-th cluster, and the first G pairs of pixels in the pixel pair sequence of the i-th cluster are recorded as each pair of representative pixel points of the i-th cluster.

7. The method for detecting milk powder quality based on image processing according to claim 6, characterized in that: The obtaining of each pair of pixels of each cluster and the distance between each pair of pixels comprises: When using the hierarchical clustering algorithm to cluster the pixels in the surface image of milk powder, any two clusters are recorded as a cluster; any pixel point is obtained from the two clusters of any cluster respectively to obtain a pair of pixel points of the cluster, and similarly, several pairs of pixel points of the cluster are obtained; the absolute value of the difference in grayscale values ​​of each pair of pixel points of the cluster is recorded as the distance of each pair of pixel points of the cluster.

8. The method for detecting milk powder quality based on image processing according to claim 1, characterized in that: The obtaining of the distance between each group of clusters includes: A pair of representative pixel points corresponding to the maximum value in the representative degree is recorded as the optimal representative pixel points, and the distance between the optimal representative pixel points is taken as the distance between the i-th group of clusters.

9. The method for detecting milk powder quality based on image processing according to claim 1, characterized in that: The step of identifying pixels in the impurity region according to the clustering result includes: A distance threshold T2 is preset. If the distance between any clusters in the clustering result is less than the distance threshold, two clusters in the cluster are recorded as clusters to be analyzed, and several clusters to be analyzed in the clustering result are obtained; if the number of pixels in any cluster to be analyzed is greater than 1 and less than 5, the pixels in the cluster to be analyzed are recorded as impurity area pixels.

10. A milk powder quality detection system based on image processing, characterized in that: include: A processor and a memory, wherein 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 any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Infant food safety visual detection method

    CN116912820A

  • Dough detection device and method based on dough mixer

    CN118196100A

  • Milk powder quality visual detection method and system

    CN118691607A

  • Method and system for detecting foreign matters in milk powder can

    CN119206632A

  • Visual inspection method and system for goat milk powder quality

    CN119359708A