A blood spot egg detection method
By calculating the degree of grayscale anomalies and potential blood spot coefficients of pixel points, the recursive aggregation process of the condensed hierarchical clustering algorithm is optimized, and the misorganization problem caused by grayscale similar impurities is solved, and more accurate blood spot egg detection is achieved.
Patent Information
- Application Number
- CN202510742716.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The existing condensation hierarchical clustering algorithms are prone to incorrectly merge the blood spot area due to impurities with similar grayscale differences in the clustering segmentation of egg surface images, resulting in inaccurate detection of blood spot eggs.
By calculating the degree of grayscale anomalies and potential blood spot coefficients of each pixel point, the recursive aggregation process of the agglomeration hierarchical clustering algorithm is optimized, the group of clusters with the greatest merging priority is selected for merging, and the inter-cluster distance and pixel point number threshold are filtered to improve the accuracy of cluster segmentation.
Effectively distinguish between soil, impurity areas and blood spot areas on the surface of the egg, improve the accuracy and reliability of blood spot egg detection, and ensure the accuracy of clustering and segmentation results.
Smart Images

Figure CN120259311B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for detecting blood spot eggs. Background Art
[0002] Eggs are a common food. Blood-spotted eggs are caused by minor bleeding in the ovaries or oviducts during egg-laying, which results in blood adhering to or penetrating the eggshell, forming blood spots or streaks. While blood-spotted eggs pose no direct health risk, their appearance does not meet consumers' visual expectations and is often perceived as inferior. Many consumers avoid eggs with blood spots. Therefore, before eggs are put on shelves, they must be inspected to determine if they contain blood spots, ensuring accurate classification and processing.
[0003] Agglomerative hierarchical clustering (AHC) is a bottom-up clustering and segmentation method that analyzes the similarities between pixels in an image to segment it into distinct regions. During the recursive clustering process, AHC typically merges the two clusters with the smallest grayscale difference.
[0004] However, when using agglomerative hierarchical clustering algorithms to perform cluster segmentation on egg surface images and then detecting blood spots based on the cluster segmentation results, the eggshell surface often contains impurities (such as dirt and stains) with grayscale values similar to those of the blood spots. These impurities have similar grayscale values, and this similarity is particularly pronounced under poor lighting conditions or low image quality. In these situations, traditional agglomerative clustering algorithms can mistakenly merge pixels in the blood spot area with those in the impurity area, resulting in inaccurate identification of the blood spot area and inaccurate blood spot egg detection results. Summary of the Invention
[0005] To address the problem that a merging rule based on grayscale differences easily leads to the mismerging of blood spot areas and impurity areas, making it impossible to effectively distinguish between blood spot areas and non-blood spot areas, resulting in inaccurate blood spot egg detection results, the present invention proposes a blood spot egg detection method, which includes:
[0006] Collecting surface images of the egg;
[0007] In the surface image, the grayscale abnormality of each pixel is determined based on the grayscale difference between each pixel and its local area; the grayscale abnormality of each pixel is determined based on the grayscale fluctuation of its local area and the grayscale abnormality of its local area. Channel value, comprehensively determines the potential blood spot coefficient of each pixel;
[0008] Cluster segmentation is performed based on the grayscale values and potential blood spot coefficients of all pixels using an agglomerative hierarchical clustering algorithm, and blood spot egg detection is performed based on the cluster segmentation results. The cluster segmentation includes multiple recursive aggregations. During each recursive aggregation, the following operations are performed to optimize the selection method of the clusters that need to be merged, including:
[0009] In each recursive aggregation, among all the generated clusters, any two clusters are grouped as a cluster, and the current multiple groups of clusters to be merged are selected according to the grayscale difference of each group of clusters;
[0010] Determine the merging priority of each group of clusters to be merged according to the difference in average grayscale values and average potential blood spot coefficients of all pixels of the two clusters included in each group of clusters to be merged;
[0011] A group of clusters to be merged with the highest merging priority is selected as the clusters currently to be merged, and the merging is performed to complete this recursive aggregation.
[0012] This technical solution helps to highlight the pixels that are more likely to belong to the blood spot area by obtaining the grayscale abnormality of each pixel to reflect the uniqueness of the pixel in terms of grayscale. In addition, by analyzing the grayscale fluctuation of the surrounding area of each pixel and the grayscale fluctuation of the pixel in the blood spot area, the grayscale of the blood spot area is analyzed. The characteristics of the channels are used to comprehensively quantify the potential blood spot coefficient of each pixel. This coefficient more accurately represents the probability that the pixel belongs to the blood spot area, providing more discriminative feature information for subsequent cluster segmentation, which helps to improve the accuracy of blood spot area identification. In addition, during the recursive aggregation process using agglomerative hierarchical clustering segmentation, not only the difference in grayscale values is considered, but also the difference in the average potential blood spot coefficient is introduced to determine the merging priority of each group of clusters. By combining these two factors, the rationality of merging two clusters can be more comprehensively evaluated, avoiding the mistaken merging of blood spot areas and impurity areas based solely on grayscale values. This allows the clustering process to more accurately merge pixels that truly belong to the blood spot area, thereby improving the accuracy of blood spot egg detection results.
[0013] Furthermore, the merging priority of each group of clusters to be merged is determined based on the following formula:
[0014] ;
[0015] In the formula, For the The first recursive aggregation The merge priority of the clusters to be merged, For the The first recursive aggregation The grayscale mean of all pixels in the first cluster contained in the cluster to be merged, For the The first recursive aggregation The grayscale mean of all pixels in the second cluster contained in the cluster to be merged, For the The first recursive aggregation The average potential blood spot coefficient of all pixels in the first cluster included in the cluster to be merged, For the The first recursive aggregation The average potential blood spot coefficient of all pixels in the second cluster included in the cluster to be merged, is the preset hyperparameter, is the absolute value symbol, is the natural exponential function.
[0016] This technical solution simultaneously considers the difference in grayscale means and the difference in average potential blood spot coefficient between the two clusters. The difference in grayscale means can reflect the difference in brightness between clusters, while the difference in average potential blood spot coefficient incorporates information related to blood spot characteristics. Therefore, the merging decision is not only based on traditional grayscale information, but also incorporates the potential possibility of the pixel point belonging to a blood spot, thereby more comprehensively measuring the similarity between clusters and the rationality of the merging.
[0017] Furthermore, the potential blood spot coefficient of each pixel is determined based on the following formula:
[0018] ;
[0019] In the formula, For the The potential blood spot coefficient of each pixel, For the The grayscale abnormality of each pixel, For the The grayscale fluctuation degree of the local area of the pixel point, For the All pixels in the local area of pixels The mean of the channel values, is the natural exponential function, is the normalization function.
[0020] This technical solution comprehensively considers the grayscale abnormality of each pixel, the grayscale fluctuation of the local area of each pixel, and the average R channel value of all pixels in the local area of each pixel. It analyzes the characteristics of each pixel from multiple dimensions and can more comprehensively and accurately describe the correlation between each pixel and the blood spot characteristics.
[0021] Furthermore, the method for detecting blood spot eggs based on the cluster segmentation results includes:
[0022] The cluster segmentation result includes multiple result clusters;
[0023] A pre-set inter-cluster distance threshold and a pixel number threshold are provided, wherein the inter-cluster distance is used to measure the similarity between any two result clusters; result clusters whose inter-cluster distance is less than the inter-cluster distance threshold are retained, and result clusters whose inter-cluster distance is greater than or equal to the inter-cluster distance threshold are eliminated; among the retained result clusters, if there is one or more result clusters whose number of pixels is less than the pixel number threshold, the current egg is determined to be a blood spot egg; if there is no result cluster whose number of pixels is less than the pixel number threshold, the current egg is determined not to be a blood spot egg.
[0024] This technical solution focuses on analyzing cluster segmentation results from blood spot egg detection. It uses inter-cluster distance to measure the similarity between clusters. By filtering using a preset inter-cluster distance threshold, it can select clusters with similar characteristics. Clusters with fewer pixels are consistent with the fine texture characteristics of blood spot eggs. Based on a preset pixel count threshold, the cluster segmentation results are further filtered, removing clusters that do not conform to blood spot characteristics and retaining only those that are highly suspected of blood spotting, thereby achieving a more accurate blood spot identification.
[0025] Furthermore, according to the grayscale difference of each group of clusters, the method of selecting the current multiple groups of clusters to be merged includes: taking the grayscale mean of all pixel points of the two clusters contained in each group of clusters as the grayscale value of each of the two clusters; calculating the absolute value of the difference between the grayscale values of the two clusters as the grayscale difference of the group of clusters; sorting all the clusters from small to large according to the grayscale difference, and selecting the top N groups of clusters to be merged as the current multiple groups of clusters to be merged, where N is a preset value.
[0026] Furthermore, the surface image is an image that has been grayscale processed.
[0027] Furthermore, the local area of a pixel includes: the pixel as the center and the surrounding areas. The range of pixels is regarded as the local area of the pixel. is the default value.
[0028] Furthermore, the grayscale abnormality degree of each pixel is determined based on the following formula:
[0029] ;
[0030] In the formula, For the The grayscale abnormality of each pixel, For the The grayscale mean of the local area of pixels, is the grayscale mean of the surface image, is the normalization function, are the preset hyperparameters.
[0031] This technology compares the grayscale mean of the surface image with the grayscale mean of the local area. It measures the grayscale uniqueness of each pixel relative to both the local area and the entire image. This uniqueness may be due to blood spots, impurities, or other anomalies. By analyzing the degree of grayscale abnormality, pixels that may be blood spots can be initially identified.
[0032] Furthermore, the grayscale fluctuation degree of the local area of pixels is determined based on the range or variance of the grayscale values of all pixels in the local area.
[0033] Furthermore, after determining that the current egg is a blood spot egg, the following operations are performed:
[0034] The contour detection algorithm is used to perform contour detection on the result cluster where the number of pixels is less than the pixel number threshold, and the area formed by the contour is regarded as the blood spot area.
[0035] The present invention has the following effects:
[0036] The present invention optimizes the clustering segmentation effect by selecting multiple clusters with the smallest grayscale value differences during the recursive aggregation process of the clustering algorithm, and combining the potential blood spot coefficient of the pixel points to optimize the selection method of the clusters that currently need to be merged, thereby achieving effective distinction between the soil, impurity areas and blood spot areas on the egg surface, and improving the accuracy and reliability of the blood spot egg identification detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic flow chart of the method of the present invention;
[0038] Figure 2 It is a schematic flow chart of the method of step S4 of the present invention. DETAILED DESCRIPTION
[0039] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0040] The present invention provides a blood spot egg detection method, such as Figure 1 As shown in , including:
[0041] S1: Collect surface images of eggs.
[0042] A high-definition camera is used to capture images of the egg's surface. This high-resolution camera captures complete surface detail, providing rich raw data for subsequent testing. The surface image is an RGB image, with each pixel having an R, G, and B channel value. The R channel value for each pixel is obtained first, as it provides unique insights when detecting blood-spotted eggs. Next, grayscale processing is performed to convert the color surface image into a grayscale image. Grayscale processing not only reduces image complexity but also effectively reflects the brightness characteristics of the image during blood-spot detection, making it crucial for distinguishing blood-spotted areas from normal areas.
[0043] S2: Evaluate the grayscale abnormality of each pixel in the surface image.
[0044] Blood spots on the egg surface often appear different in color and brightness than normal eggshell areas in images, and the grayscale values of the pixels in blood spots are typically lower. The lower the grayscale value of a pixel's local area, the greater the grayscale abnormality of the pixel, indicating a higher likelihood that the pixel belongs to a blood spot.
[0045] Therefore, taking each pixel as the center, the All pixels within the pixel range (including itself) are regarded as the local area of the pixel, and the grayscale abnormality of each pixel is determined based on the following formula:
[0046]
[0047] In the formula, For the The grayscale abnormality of each pixel, For the The grayscale mean of the local area of pixels is equal to the grayscale mean of all pixels in the local area. is the grayscale mean of the surface image, is the normalization function, It is a preset hyperparameter used to prevent the denominator from being 0. (Experience points).
[0048] In this formula, The smaller the The lower the gray value of the local area of the pixel point, the The greater the possibility that the pixel belongs to the blood spot area, the Since most of the egg surface is normal and the blood spot area is usually small, the grayscale average of the surface image is dominated by the normal area. The larger the The greater the difference between the gray value of the local area of the pixel and the normal area, the greater the difference between the gray value of the local area of the pixel and the normal area. The lower the gray value of the local area of the pixel point, the greater the credibility, which increases the The grayscale abnormality of each pixel.
[0049] S3: Determine the potential blood spot coefficient of each pixel.
[0050] When blood spots are present on the egg surface, the pixels in these spots have a high grayscale consistency, indicating minimal grayscale variation. This is because blood spots are formed when bleeding from the ovaries or oviducts adheres to the eggshell during egg-laying, and their physical properties result in a relatively uniform grayscale in the image. In contrast, dirt and other impurities are unevenly distributed on the egg surface due to the random nature of their sources and attachment patterns, resulting in large fluctuations in the grayscale values of the areas they belong to in the image. For example, dirt may be attached in various forms, such as lumps and granules, with significant differences in grayscale values between its edges and interior, manifesting as large grayscale variations in the image.
[0051] Therefore, grayscale consistency analysis can be performed on the local area of each pixel. The more consistent the grayscale values of all pixels in the local area of a pixel, the greater the likelihood that the pixel belongs to the blood spot area. This evaluation method can, to a certain extent, eliminate misjudgments that may occur due to similar grayscale values but different grayscale variation characteristics. For example, in some images with uneven lighting, there may be areas with grayscale values similar to blood spots. However, by analyzing the grayscale variation characteristics, if the grayscale value of the area fluctuates greatly, it can be judged that it is more likely to be an impurity area rather than a blood spot, thereby improving detection accuracy.
[0052] Although the grayscale variation characteristics can distinguish most blood spot areas from impurity areas, the present invention takes into account that some soil and impurity areas may also have a high grayscale value consistency, which will affect the detection results. Therefore, the present invention further introduces the R channel value of the pixel point. The pixel points in the blood spot area on the egg surface will have a large numerical value in the R channel value. This is because blood contains substances such as hemoglobin, which will show a large numerical value in the red channel of the image. However, soil and impurity substances generally do not have such obvious high numerical characteristics in the R channel. This makes the R channel value an important basis for distinguishing blood spot areas from impurity areas with similar grayscale variation characteristics. Incorporating the R channel value of the pixel point into the calculation of the potential blood spot coefficient further enhances the accuracy of the detection.
[0053] In one embodiment, the potential blood spot coefficient of each pixel is determined based on the following formula:
[0054]
[0055] In the formula, For the The potential blood spot coefficient of each pixel is used to reflect the possibility that the pixel belongs to the blood spot area. For the The grayscale abnormality of each pixel, For the The grayscale fluctuation degree of the local area of the pixel point is usually based on the The grayscale fluctuation degree is determined by the range (the difference between the maximum grayscale value and the minimum grayscale value) or variance of the grayscale values of all pixels in the local area of a pixel. Here, the range is selected to represent the degree of grayscale fluctuation. The larger the range, the greater the degree of grayscale fluctuation. For the All pixels in the local area of pixels The mean of the channel values, is the natural exponential function, is the normalization function.
[0056] In this formula, The smaller the The better the grayscale consistency of the local area of the pixel point, the The more likely a pixel point is to belong to the blood spot area, the greater the potential blood spot coefficient of the pixel point is. Build and The negative correlation between The larger the All pixels in the local area of pixels The larger the channel value, the more it conforms to the characteristics of the blood spot area, further increasing the The probability that the pixel belongs to the blood spot area, that is, The greater the potential blood spot coefficient of each pixel, the greater the potential blood spot coefficient of each pixel.
[0057] In summary, the potential blood spot coefficient is calculated by comprehensively analyzing the grayscale variation characteristics of each pixel's local area and the numerical characteristics of the R channel value, fully utilizing the ability of these different characteristics to distinguish blood spots from impurity areas. The grayscale variation characteristics are judged from the perspective of image texture and uniformity, while the R channel numerical characteristics complement the specific color channel characteristics. The two are combined and mutually verified.
[0058] This comprehensive evaluation method can more comprehensively and accurately quantify the possibility that a pixel belongs to a blood spot area, effectively distinguishing areas belonging to soil and impurities from potential blood spot areas, and providing a more discriminatory basis for subsequent steps such as clustering and segmentation of blood spot egg detection based on pixel features.
[0059] S4: Cluster segmentation is performed based on the grayscale values and potential blood spot coefficients of all pixels using the agglomerative hierarchical clustering algorithm. During each recursive aggregation, the selection method of the cluster that needs to be merged is optimized.
[0060] Specifically, if Figure 2 As shown, it includes steps S41 to S43:
[0061] S41: Select multiple groups of clusters to be merged.
[0062] In each recursive aggregation, among all the generated clusters, any two clusters are grouped as a cluster.
[0063] The grayscale mean of all pixels in each of the two clusters within each group is used as the grayscale value of each cluster. The absolute value of the difference between the grayscale values of the two clusters is calculated as the grayscale difference of the cluster. This calculation method effectively quantifies the degree of grayscale difference between clusters. Grayscale is a fundamental and important feature in image analysis. For blood spot egg detection, blood spot areas and non-blood spot areas often differ in grayscale. This calculation based on the grayscale mean difference can effectively reflect the degree of similarity (or difference) in grayscale between the areas represented by different clusters.
[0064] All clusters are sorted by grayscale difference, from smallest to largest. The top N clusters are selected as the current multiple clusters to be merged. The empirical value of N is 5. This is because clusters with small grayscale differences are more similar in grayscale characteristics, and the areas they represent are more likely to belong to the same category, such as clusters in different parts of a bloodstain area or clusters in different parts of a normal eggshell area without a bloodstain. This screening method provides a reasonable set of candidate clusters for further analysis of merging priorities, reduces unnecessary calculations and interference, and improves clustering efficiency and accuracy.
[0065] S42: Determine the merging priority of each group of clusters to be merged.
[0066] Traditional clustering algorithms rely solely on grayscale differences. This can lead to mismatches in blood spot detection due to grayscale similarities between impurity and blood spots, impacting clustering and subsequent detection accuracy. Therefore, this step incorporates the difference in the average potential blood spot coefficient. This, combined with the previously assessed likelihood of a pixel being a blood spot, evaluates the merging priority of each cluster to be merged. Based on this priority, the appropriate set of clusters to be merged is selected for merging, optimizing the clustering process and resulting in more accurate clustering results.
[0067] In one embodiment, the merging priority of each group of clusters to be merged is determined based on the following formula:
[0068]
[0069] In this formula, For the The first recursive aggregation The merge priority of the clusters to be merged, For the The first recursive aggregation The grayscale mean of all pixels in the first cluster contained in the cluster to be merged, For the The first recursive aggregation The grayscale mean of all pixels in the second cluster contained in the cluster to be merged, For the The first recursive aggregation The average potential blood spot coefficient of all pixels in the first cluster included in the cluster to be merged, For the The first recursive aggregation The average potential blood spot coefficient of all pixels in the second cluster included in the cluster to be merged, To prevent or A hyperparameter of 0, (Experience points) is the absolute value symbol, is the natural exponential function.
[0070] In this formula, The smaller the The more similar the grayscale features of the two clusters to be merged are, the higher the priority of merging should be. The smaller the The more consistent the possibility that the two clusters to be merged belong to the blood spot area, the higher the priority of merging the two clusters. That is to say, the more consistent the grayscale features of the two clusters and the more consistent the possibility that they belong to the blood spot area, the more similar the characteristics of the pixels corresponding to the two clusters in the surface image are to the characteristics of the pixels in the blood spot area, and the more the two clusters need to be optimized and merged. Build 、 and negative correlation.
[0071] In summary, by combining the two factors of grayscale difference and average potential blood spot coefficient difference, the similarity between clusters can be comprehensively measured, so that the merging decision is more in line with the actual situation of blood spot egg detection, effectively avoiding misjudgment and improving the accuracy of clustering.
[0072] S43: Determine the cluster that needs to be merged according to the merging priority, and perform this recursive aggregation.
[0073] Specifically, the set of clusters with the highest merge priority is selected as the current cluster to be merged, and merged to complete this recursive aggregation. Because the merge priority comprehensively considers key factors such as grayscale and blood spot characteristics, merging the clusters with the highest merge priority first ensures that each merge is consistent with the actual distribution of blood spot and non-blood spot areas in the image to the greatest extent possible.
[0074] In complex eggshell surface images, among multiple clusters with similar grayscale, those with similar and higher average potential blood spot coefficients will be merged first due to their high merging priority, thereby accurately merging the areas that truly belong to blood spots, effectively avoiding erroneous merging with non-blood spot areas, and significantly improving the accuracy of blood spot area identification.
[0075] During each recursive aggregation process of the agglomerative hierarchical clustering algorithm for clustering and segmenting the surface image, steps S41 to S43 are performed to optimize the agglomerative hierarchical clustering algorithm. The optimized agglomerative hierarchical clustering algorithm ultimately obtains multiple result clusters with higher reliability, and can segment the clusters belonging to the blood spot area from the surface image, providing a clear and reliable basis for blood spot egg detection.
[0076] S5: Perform blood spot egg detection based on cluster segmentation results.
[0077] In cluster analysis, inter-cluster distance is an important indicator for measuring the similarity between clusters. By setting an appropriate inter-cluster distance threshold, clusters with similar characteristics can be screened out. For blood spot egg detection, blood spot regions have certain similarities in image features and are clearly distinguishable from non-blood spot regions. When the inter-cluster distance is less than a certain threshold, it indicates that the regions represented by these clusters are more similar in image features (such as color, texture, and other comprehensive features reflected by clustering) and are more likely to belong to the same category, such as blood spots or certain impurity areas on the eggshell.
[0078] This step further considers that blood spots typically appear as small, scattered areas on the egg surface, containing relatively few pixels. By setting a pixel count threshold, clusters that match this characteristic can be further filtered out. When the number of pixels within a cluster is less than a certain value, it is more likely to correspond to a blood spot on the egg surface. This is because clusters formed by normal eggshell areas or large areas of impurities tend to have more pixels than clusters formed by blood spots.
[0079] In one embodiment, the method for detecting blood-spotted eggs is:
[0080] The preset inter-cluster distance threshold is 1.5 (empirical value). The result clusters with inter-cluster distance less than 1.5 are retained, and the characteristics of these result clusters are relatively similar. The result clusters with inter-cluster distance greater than or equal to 1.5 are eliminated.
[0081] A pixel count threshold of 10 (empirical value) is preset. If one or more of the retained clusters have fewer than 10 pixels, the egg is considered a blood spot. Specifically, if clusters with an inter-cluster distance less than 1.5 and fewer than 10 pixels within a cluster meet the characteristics of a blood spot on an egg's surface, the egg is considered to have a blood spot. If no clusters have fewer than 10 pixels, the egg is considered not to have a blood spot.
[0082] For example, there are 4 result clusters numbered 1, 2, 3, and 4, containing 9, 14, 22, and 7 pixels respectively. The cluster spacings between 1 and 2, 3, and 4 are 1.1, 2.2, and 1.3 respectively; the cluster spacings between 2 and 1, 3, and 4 are 1.1, 1.9, and 1.2 respectively; the cluster spacings between 3 and 1, 2, and 4 are 2.2, 1.9, and 2.1 respectively; and the cluster spacings between 4 and 1, 2, and 3 are 1.3, 1.2, and 2.1 respectively.
[0083] Based on the inter-cluster distance threshold of 1.5, cluster 3 is eliminated, and clusters 1, 2, and 4 are retained. Among these retained clusters, the number of pixels in clusters 1 and 4 is less than 10, so the egg is determined to be a blood-spotted egg. The areas corresponding to clusters 1 and 4 are the blood spots on the egg surface.
[0084] In summary, this step first retains clusters with high similarity based on the inter-cluster distance threshold, and then searches for clusters that meet the blood spot pixel number characteristics among these retained clusters based on the pixel number threshold. This can accurately determine whether the egg currently being tested is a blood spot egg.
[0085] In one embodiment, after determining that the current egg is a blood-spotted egg, the following operations are further performed:
[0086] Use a contour detection algorithm, such as the Canny edge detection algorithm, to perform contour detection on the result cluster whose number of pixels is less than a pixel number threshold, and use the area formed by the contour as the blood spot area.
[0087] This operation further improves the accuracy of detection, because the contour detection algorithm can accurately outline the boundaries of the blood spot area, so that the position and shape of the blood spot area in the surface image can be precisely located. In food quality inspection, the blood spot area on the egg surface can be marked, which helps to evaluate the quality grade of the eggs and provide more detailed and accurate information for the classification and processing of eggs.
[0088] While various embodiments of the present invention have been shown and described herein, it will be obvious to those skilled in the art that such embodiments are provided by way of example only.
Claims
1. A method for detecting blood spot eggs, characterized in that: include: Collecting surface images of the egg; In the surface image, the grayscale abnormality of each pixel is determined based on the grayscale difference between each pixel and its local area; the grayscale abnormality of each pixel is determined based on the grayscale fluctuation of its local area and the grayscale abnormality of its local area. The channel value comprehensively determines the potential blood spot coefficient of each pixel, which satisfies the relationship: ; For the The potential blood spot coefficient of each pixel, For the The grayscale abnormality of each pixel, For the The grayscale fluctuation degree of the local area of the pixel point, For the All pixels in the local area of pixels The mean of the channel values, is the natural exponential function, is the normalization function; Cluster segmentation is performed based on the grayscale values and potential blood spot coefficients of all pixels using an agglomerative hierarchical clustering algorithm, and blood spot egg detection is performed based on the cluster segmentation results. The cluster segmentation includes multiple recursive aggregations. During each recursive aggregation, the following operations are performed to optimize the selection method of the clusters that need to be merged, including: In each recursive aggregation, among all the generated clusters, any two clusters are grouped as a cluster, and the current multiple groups of clusters to be merged are selected according to the grayscale difference of each group of clusters; The merging priority of each group of clusters to be merged is determined based on the difference in the average grayscale value and the average potential blood spot coefficient of all pixels of the two clusters contained in each group of clusters to be merged, satisfying the relationship: ; For the The first recursive aggregation The merge priority of the clusters to be merged, 、 Respectively The first recursive aggregation The grayscale mean of all pixels in the first cluster and the grayscale mean of all pixels in the second cluster included in the cluster to be merged. 、 Respectively The first recursive aggregation The average potential blood spot coefficient of all pixels in the first cluster and the average potential blood spot coefficient of all pixels in the second cluster included in the cluster to be merged. is the preset hyperparameter, is the absolute value symbol; A group of clusters to be merged with the highest merging priority is selected as the clusters currently to be merged, and the merging is performed to complete this recursive aggregation.
2. The blood spot egg detection method according to claim 1, characterized in that: Methods for blood spot egg detection based on cluster segmentation results include: The cluster segmentation result includes multiple result clusters; Preset an inter-cluster distance threshold and a pixel number threshold, wherein the inter-cluster distance is used to measure the similarity between any two result clusters; The result clusters whose inter-cluster distance is less than the inter-cluster distance threshold are retained, and the result clusters whose inter-cluster distance is greater than or equal to the inter-cluster distance threshold are eliminated; Among the retained result clusters, if there is one or more result clusters whose number of pixels is less than the pixel number threshold, the current egg is determined to be a blood spot egg; if there is no result cluster whose pixel number is less than the pixel number threshold, the current egg is determined not to be a blood spot egg.
3. The blood spot egg detection method according to claim 1, characterized in that: Methods for selecting the current multiple groups of clusters to be merged according to the grayscale difference of each group of clusters include: The grayscale mean of all pixels in each of the two clusters contained in each group of clusters is used as the grayscale value of each of the two clusters; Calculate the absolute value of the difference between the grayscale values of two clusters as the grayscale difference of the cluster; sort all clusters from small to large according to the grayscale difference, and select the top N clusters to be merged as the current multiple clusters to be merged, where N is a preset value.
4. The blood spot egg detection method according to claim 1, characterized in that: The surface image is an image that has been grayscale processed.
5. The blood spot egg detection method according to claim 1, characterized in that: The local area of a pixel includes: the pixel as the center, the area around the center The range of pixels is regarded as the local area of the pixel. is the default value.
6. The blood spot egg detection method according to claim 1, characterized in that: The grayscale abnormality of each pixel is determined based on the following formula: ; In the formula, For the The grayscale abnormality of each pixel, For the The grayscale mean of all pixels in the local area of pixels, is the grayscale mean of the surface image, is the normalization function, are the preset hyperparameters.
7. The blood spot egg detection method according to claim 1, characterized in that: The degree of grayscale fluctuation in the local area of each pixel is determined based on the range or variance of the grayscale values of all pixels in the local area.
8. The blood spot egg detection method according to claim 2, characterized in that: After determining that the current egg is a blood spot egg, the following operations are performed: The contour detection algorithm is used to perform contour detection on the result cluster where the number of pixels is less than the pixel number threshold, and the area formed by the contour is regarded as the blood spot area.
Citation Information
Patent Citations
Improved hierarchical clustering method for sewage abnormity detection
CN109858572A
Driver standard behavior detection and early warning method and system based on machine vision
CN119251804A