Stain detection method for fresh egg cleaning

By dynamically adjusting the window size of pixel points in the fresh egg grayscale image, combining the gradient direction entropy and local geometric direction consistency, the problem of the eggshell edges in the Sauvola algorithm being mistakenly recognized as stains, achieving high accuracy in fresh egg stain detection.

CN120259310AActive Publication Date: 2025-07-04EGG NO 1 FOOD CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

When identifying stains on fresh eggs, the existing Sauvola adaptive threshold segmentation algorithm cannot dynamically adjust the size of the neighborhood window of pixels, resulting in the edge of normal eggshell being misidentified as a stain, reducing the accuracy of stain detection.

Method used

By obtaining the gradient direction angle of each pixel point in the fresh egg grayscale image, dividing it into multiple intervals, calculating the gradient direction entropy and local geometric direction consistency, dynamically adjusting the window size of the pixel point, and calculating the segmentation threshold based on the grayscale mean and standard deviation to accurately distinguish the stained area and the normal eggshell area.

Benefits of technology

It improves the accuracy of stain detection in grayscale images of fresh eggs, avoids misidentification of the edges of normal eggshells, and ensures the accuracy of stain detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259310A_ABST
    Figure CN120259310A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image data processing, in particular to a stain detection method for fresh egg cleaning, and the method comprises the steps: determining the gradient direction entropy of a pixel point according to the entropy sum of the number of pixel points located in each gradient direction angle interval in a pixel point initial window in a fresh egg gray image; according to the horizontal component sum and the vertical component sum of the gradient direction angles of all the pixel points in the pixel point initial window, calculating the local geometric direction consistency of the pixel points; calculating the size of a target window of the pixel point; the segmentation threshold value of the pixel point is calculated according to the gray average value and the gray standard deviation of all the pixel points in the pixel point target window, the fresh egg gray image is processed according to the segmentation threshold value of the pixel point, a fresh egg gray image stain detection result is obtained, and the accuracy of the fresh egg stain detection result is effectively 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 data processing. More specifically, the present invention relates to a stain detection method for fresh egg cleaning. Background Art

[0002] Stains on the surface of fresh eggs may come from feces and bedding debris in the chicken coop environment, or impurities contaminated during storage and transportation. These stains not only affect the appearance of fresh eggs, but may also carry a large number of bacteria and microorganisms, contaminating the eggshell surface, and then invading the egg through pores, accelerating the deterioration of fresh eggs, shortening the shelf life, and seriously affecting the edible safety and quality of fresh eggs. Therefore, after fresh eggs enter the processing factory from the farm, they need to be preliminarily detected before cleaning to evaluate the degree of stain contamination and formulate a cleaning strategy.

[0003] The Sauvola adaptive threshold segmentation algorithm is a classic algorithm for image binarization. This algorithm obtains the mean and standard deviation in the neighborhood window for each pixel point in the image, so as to accurately calculate the optimal threshold of the pixel point. The surface of fresh eggs is usually curved and has strong reflectivity, which easily leads to uneven illumination (such as the top of the eggshell being too bright, the side being too dark, and differences in eggshell color and texture, etc.). The Sauvola adaptive threshold segmentation algorithm can dynamically adapt to the brightness changes in different regions by locally calculating the threshold, avoiding misjudging the normal eggshell area as a stain when using the global threshold method in the case of uneven illumination.

[0004] However, the Sauvola adaptive threshold segmentation algorithm uses a neighborhood window of a fixed size. When identifying stains on the surface of fresh eggs, if the neighborhood covers both sides of the edge of the fresh egg, the gray mean value will be flattened, so that when segmenting the stain area on the surface of the fresh egg, the normal edge of the fresh egg may be misidentified as a stain, reducing the accuracy of stain detection.

[0005] In summary, there is an urgent need for a detection method that can accurately and dynamically adjust the size of the neighborhood window of pixel points to accurately identify stains on the surface of fresh eggs. Summary of the Invention

[0006] To solve the above technical problem of how to accurately and dynamically adjust the size of the neighborhood window of pixel points to accurately identify stains on the surface of fresh eggs, the present invention proposes a stain detection method for fresh egg cleaning, which includes the following steps: Obtain the gradient direction angle of each pixel point in the grayscale image of the fresh egg, divide the gradient direction angle into multiple intervals, and determine the gradient direction entropy of the pixel point according to the sum of the entropy values of the number of pixel points in each interval in the initial window of the pixel point; calculate the local geometric direction consistency of the pixel point according to the sum of the horizontal components and the sum of the vertical components of the gradient direction angles of all pixel points in the initial window of the pixel point; calculate the Target window size of the pixel point : ; is the initial window size, and are respectively the abscissa indexes of the pixel point and the pixel point in its initial window, and are respectively the ordinate indexes of the pixel point and the pixel point in its initial window, and are respectively the local geometric direction consistency degrees of the pixel point and the pixel point in its initial window, is the gradient direction entropy of the pixel point, is the exponential function with base e; calculate the segmentation threshold of the pixel point according to the gray mean value and gray standard deviation of all pixel points in the target window of the pixel point, and process the fresh egg gray image according to the segmentation threshold of the pixel point to obtain the stain detection result of the fresh egg gray image.

[0007] The present invention can accurately obtain the stain detection result in the fresh egg gray image by dynamically adjusting the window size of each pixel point in the fresh egg gray image. When dynamically adjusting the window size of the pixel point, the present invention takes into account that the edge of the normal eggshell may be misidentified as a stain, and the degree of gradient direction chaos and the degree of gradient direction consistency between the stain and the edge of the eggshell are not the same. Therefore, when calculating the size of the target window of each pixel point, the present invention can accurately adjust the size of the initial window by respectively obtaining the gradient direction entropy of the pixel point in the initial window and the vector sum of the vertical direction component and the horizontal direction component of the gradient direction of each pixel point, and accurately obtain the size of the final window required for each pixel point, so as to accurately distinguish the stain area and the normal eggshell area on the surface of the fresh egg, and effectively improve the accuracy of the obtained stain detection result of the fresh egg gray image.

[0008] According to a stain detection method for fresh egg cleaning provided by the present invention, before obtaining the gradient direction angle of each pixel point in the fresh egg gray image, it further includes: taking a photo of the surface of the fresh egg for preprocessing to obtain a fresh egg gray image; wherein the preprocessing at least includes image denoising and grayscale processing.

[0009] The present invention takes into account that when obtaining the fresh egg gray image, noise etc. may exist in the obtained fresh egg image due to interference in the surrounding environment or electronic devices. Therefore, the present invention can effectively improve the quality of the picture by preprocessing the photo of the surface of the fresh egg obtained by shooting.

[0010] A stain detection method for fresh egg cleaning provided by the present invention divides the gradient direction angle into multiple intervals, including: according to the preset number of intervals The gradient direction angle is divided into intervals.

[0011] A stain detection method for fresh egg cleaning provided by the present invention, determining the gradient direction entropy of a pixel point according to the entropy sum of the number of pixel points in each interval in the initial window of the pixel point, includes: ; is the gradient direction entropy of the pixel point, is the number of intervals of the gradient direction angle, is the number of pixel points in the initial window of the pixel point located in the th interval, is the logarithmic function with base e, is the linear normalization function.

[0012] The present invention takes into account that there are significant differences in the gradient directions between the eggshell edge and the stain area. The gradient direction of the eggshell edge has a lower degree of disorder, while the stain area has a higher degree of disorder due to its irregularity. Therefore, the present invention analyzes the value of the gradient direction angle in the initial window of the pixel point to obtain the gradient direction entropy of the pixel point, which is used as an important feature to evaluate whether the pixel point is in the stain area, so that the edge pixel points of the stain area can be accurately obtained based on this.

[0013] A stain detection method for fresh egg cleaning provided by the present invention, the obtaining method of the horizontal component and the vertical component of the gradient direction angle of the pixel point, includes: taking the cosine function value of the gradient direction angle of the pixel point as the horizontal component of the pixel point, and taking the sine function value of the gradient direction angle of the pixel point as the vertical component of the pixel point.

[0014] A stain detection method for fresh egg cleaning provided by the present invention, calculating the local geometric direction consistency of the pixel point according to the sum of the horizontal components and the sum of the vertical components of the gradient direction angles of all pixel points in the initial window of the pixel point, includes: ; is the local geometric direction consistency of the pixel point, is the initial window size, 、 are respectively the gradient magnitude and gradient direction angle of the th pixel point in the initial window of the pixel point, is a linear normalization function, , are respectively the horizontal component and vertical component of the gradient direction angle of the pixel in the initial window of the pixel.

[0015] The present invention takes into account that the gradient direction of the pixels in the initial window of the current pixel can evaluate the vector direction of the pixel. Therefore, by obtaining the vector direction of the pixels in the initial window of the current pixel and weighting it by the gradient amplitude of the pixel, the edge of the eggshell area can be accurately highlighted based on this. The larger this value is, the greater the possibility of being the edge of the eggshell area.

[0016] According to a stain detection method for fresh egg cleaning provided by the present invention, calculating the segmentation threshold of the pixel according to the gray mean value and gray standard deviation of all pixels in the target window of the pixel includes: rounding down the size of the target window of the pixel to an odd integer to obtain the final window size of the pixel; ; is the segmentation threshold of the pixel, , are respectively the gray mean value and gray standard deviation of all pixels in the final window of the pixel, is the sensitivity coefficient.

[0017] The present invention takes into account that constructing its final window centered on the current pixel can comprehensively consider the gray features around the current pixel, so as to accurately calculate its segmentation threshold. Therefore, when calculating the segmentation threshold of the pixel after obtaining the target window of the pixel based on the above steps, rounding down the size of the target window of the pixel to an odd integer, so that the surrounding features of the pixel can be accurately evaluated according to the surrounding gray features of the pixel, effectively improving the accuracy of the obtained segmentation threshold.

[0018] According to a stain detection method for fresh egg cleaning provided by the present invention, processing the gray image of the fresh egg according to the segmentation threshold of the pixel includes: if the number of pixels not higher than the segmentation threshold of the pixel in the final window of the pixel of the gray image of the fresh egg is greater than the number threshold, then the pixel is a stain pixel.

[0019] According to a stain detection method for fresh egg cleaning provided by the present invention, processing the gray image of the fresh egg according to the segmentation threshold of the pixel to obtain the stain detection result of the gray image of the fresh egg includes: obtaining all stain pixels in the gray image of the fresh egg and taking the connected domain of the stain pixels as the stain in the gray image of the fresh egg.

[0020] A stain detection method for fresh egg cleaning provided by the present invention is characterized in that after obtaining the stain detection result of the grayscale image of the fresh egg, the method further includes: sending a cleaning prompt for the fresh egg corresponding to the grayscale image of the fresh egg with stains.

[0021] The present invention has the following beneficial effects: Based on the above technical solution, for a stain detection method for fresh egg cleaning provided by the present invention, when obtaining the stain detection result on the surface of the fresh egg, by dynamically adjusting the window size of each pixel point in the grayscale image of the fresh egg, the stain detection result in the grayscale image of the fresh egg can be accurately obtained. When dynamically adjusting the window size of the pixel point, the present invention takes into account that the edge of the normal eggshell may be misidentified as a stain, and the degree of confusion and the degree of consistency of the gradient direction between the stain and the edge of the eggshell are not the same. Therefore, when calculating the size of the target window of each pixel point, the present invention can accurately adjust the size of the initial window based on obtaining the gradient direction entropy of the pixel point in the initial window and the vector sum of the vertical and horizontal components of the gradient direction of each pixel point, and accurately obtain the size of the final window required for each pixel point, so as to accurately distinguish the stain area and the normal eggshell area on the surface of the fresh egg, effectively improving the accuracy of the stain detection result of the grayscale image of the fresh egg obtained. Description of the Drawings

[0022] Figure 1 is a flowchart of the steps of a stain detection method for fresh egg cleaning provided by an embodiment of the present invention; Figure 2 is an example diagram of a grayscale image of a fresh egg provided by an embodiment of the present invention; Figure 3 is a fresh egg stain detection result obtained without dynamically adjusting the neighborhood window size of pixel points provided by an embodiment of the present invention; Figure 4 is a schematic diagram of the stain detection result of the grayscale image of a fresh egg obtained after dynamically adjusting the window size provided by an embodiment of the present invention. Detailed 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 part of the embodiments of the present invention, rather than all of the embodiments.

[0024] An embodiment of the present invention discloses a stain detection method for fresh egg cleaning. This method can dynamically adjust the neighborhood window size of pixel points in the Sauvola adaptive threshold segmentation algorithm according to the change characteristics of pixel points in the grayscale image of the fresh egg, so as to accurately divide the stain area on the surface of the fresh egg.

[0025] Specifically, please refer to Figure 1, Figure 1 Figure 1 is a flowchart of the steps of a stain detection method for fresh egg cleaning provided by an embodiment of the present invention. The method includes the following steps: S1: Obtain a grayscale image of a fresh egg.

[0026] Exemplarily, in the embodiment of the present invention, before obtaining the gradient direction angle of each pixel point in the grayscale image of the fresh egg, it further includes: photographing the surface photo of the fresh egg for preprocessing to obtain the grayscale image of the fresh egg.

[0027] Among them, the preprocessing includes at least image denoising and grayscale processing, and may also include image equalization processing, contrast enhancement, etc., which can be specifically set according to actual needs.

[0028] It can be understood that the initially collected surface photo of the fresh egg is a colored image that may be noisy. Therefore, before obtaining the stain detection result on the surface of the fresh egg, it is necessary to perform preprocessing such as grayscale and denoising on the surface photo of the fresh egg.

[0029] The grayscale image of the fresh egg obtained after preprocessing can be seen in Figure 2 as shown in Figure 2 which is an example diagram of a grayscale image of a fresh egg provided by an embodiment of the present invention. It can be seen from Figure 2 that the collected grayscale image of the fresh egg generally includes a bright eggshell area, a stain and a background area with a lower gray level. The edge of the eggshell area is connected to the background area, and the stain area exists in the eggshell area.

[0030] The conventional Sauvola adaptive threshold segmentation algorithm does not dynamically adjust the neighborhood window size of pixel points, and the directly processed stain area may divide the normal fresh egg edge into the stain area. For details, please refer to Figure 3 as shown in Figure 3 which is a fresh egg stain detection result obtained without dynamically adjusting the neighborhood window size of pixel points provided by an embodiment of the present invention. It can be seen from Figure 3 that the normal area where the edge part of the fresh egg is relatively close to the stain feature is misidentified as a stain, and the accuracy of the finally obtained fresh egg stain detection result is relatively low.

[0031] When dynamically adjusting the window size of pixel points, the window size can be determined according to the possibility that the pixel point is the edge of the stain area. On the grayscale image of the fresh egg, the gradient direction of the eggshell edge is usually regular and orderly, while the gradient direction of the stain area is complex and disorderly. Therefore, the embodiment of the present invention can distinguish the two by obtaining the gradient direction entropy of each pixel point in the initial window of the current pixel point, so as to accurately obtain the stain area in the grayscale image of the fresh egg, that is, perform the following steps.

[0032] S2: Obtain the gradient direction angle of each pixel in the fresh egg grayscale image, and divide the gradient direction angle into multiple intervals, and determine the gradient direction entropy of the pixel according to the sum of the entropy values ​​of the number of pixels in each interval in the initial window of the pixel.

[0033] The size of the initial window may be set to 15, and the initial window size may be set to an odd number according to actual needs.

[0034] Specifically, when obtaining the pixel points in the initial window of the current pixel point, the current pixel point can be taken as the center, and multiple pixel points can be evenly obtained around it to construct its initial window. The shape of the initial window is a rectangle. Finally, (15×15-1) pixels are obtained around the current pixel point and together with the current pixel point, serve as the initial window of the current pixel point.

[0035] It is understandable that the surface of a normal eggshell usually has a relatively uniform texture structure, while the shape and texture of stains are often irregular and complex, which may destroy the regularity of the eggshell surface. The gradient direction angle of a pixel in an image can reflect the direction of grayscale change at that point. In the window of a normal eggshell, the gradient direction angle is concentrated in a few intervals, and the gradient direction angle of the stain area is distributed in more intervals.

[0036] Based on this, the embodiment of the present invention can obtain the number of pixels located in each gradient direction angle interval in the initial window of the current pixel point, so as to accurately obtain the gradient direction entropy of the current pixel point to distinguish the area where the current pixel point is located.

[0037] For example, in an embodiment of the present invention, the gradient direction angle is divided into a plurality of intervals, including: according to a preset number of intervals The gradient direction angle is divided into interval.

[0038] in, It can be set to 16; the number of intervals can be set according to actual needs, and the embodiment of the present invention does not impose too many restrictions on this.

[0039] Specifically, the range of the gradient direction angle of the pixel points in the image is usually 0° to 180°, and it can be divided into 16 intervals according to the preset number of intervals. The width of each interval is 11.25°, where the first interval is [0°, 11.25°), the second interval is [11.25°, 22.5°), and the last interval is [168.75, 180°]. The last interval is left closed and right closed, and the other intervals are left closed and right open. By analogy, all intervals can be obtained, and the embodiments of the present invention are not described in detail here.

[0040] After obtaining the range of each interval of the gradient direction angle of the pixel points based on the above steps, the number of pixel points corresponding to the gradient direction angles in each interval in the initial window of the pixel points can be counted, so that the gradient direction entropy of the current pixel point can be determined according to the entropy sum of the number of pixel points in each interval in the initial window of the current pixel point.

[0041] Exemplarily, in the embodiment of the present invention, to calculate the gradient direction entropy of a pixel point, the following relational expression can be specifically referred to: ; is the gradient direction entropy of the pixel point, is the number of intervals of the gradient direction angle, is the number of pixel points in the initial window of the th pixel point located in the th interval, is the logarithmic function with base e,

[0042] In the above formula, the smaller the gradient direction entropy of the th pixel point, it indicates that the distribution of the gradient direction angles of the pixel points in the th pixel point window is more concentrated, and it is more likely to be a continuous area such as the eggshell edge; on the contrary, the smaller this value is, it indicates that the distribution of the gradient direction angles of the pixel points in the th pixel point window is more discrete, and it is more likely to be a stain edge area.

[0043] According to the above steps to analyze the distribution of the gradient direction angles of the pixel points in the initial window of each pixel point, the gradient direction entropy of each pixel point can be accurately obtained, so as to evaluate the possibility that each pixel point is at the eggshell edge or the edge of the stain area. However, the edge also has the characteristic of continuity. Only obtaining the gradient direction entropy of the pixel points does not consider the coherence of the gradient distribution of the pixel points. In the gray-scale image of fresh eggs, the gradient arrangement direction of the gray-scale values at the eggshell edge is more continuous than that in the stain area. Therefore, when evaluating the possibility that each pixel point is at the eggshell edge or the edge of the stain area, it is also necessary to obtain the geometric direction consistency in the initial window of the pixel points in the gray-scale image of fresh eggs, so as to accurately obtain the window size required for each pixel point, that is, continue to execute the following steps.

[0044] S3: Calculate the local geometric direction consistency of the pixel point according to the sum of the horizontal components and the sum of the vertical components of the gradient direction angles of all pixel points in the initial window of the pixel point.

[0045] It should be noted that the gradient direction angle of each pixel point can correspond to a unit vector, whose horizontal component is the cosine function value and the vertical component is the sine function value. In the gray-scale image of fresh eggs, the gradient arrangement direction of the gray-scale value at the eggshell edge is more continuous than that in the stain area. When analyzing the consistency of the local geometric directions of pixel points, the vectors of the gradient direction angles of the pixel points in the current pixel point window can be superimposed to obtain the overall direction vector of the area, so as to analyze the vector consistency of the gradient direction angles of the pixel points in the current pixel point window. If the gradient directions in the window are highly consistent, it indicates that the pixel point directions in the window have strong coherence; on the contrary, if the gradient directions in the window are relatively disordered, it indicates that the pixel point directions lack coherence.

[0046] To enhance the contribution of pixel points with better coherence when determining the window size, the texture significance of the pixel points at the eggshell edge can be characterized by the gradient magnitude. When calculating the local geometric direction consistency, higher weights are given to more significant texture directions, so that more attention can be paid to the texture features that are discriminative for stain detection.

[0047] Exemplarily, in the embodiment of the present invention, the method for obtaining the horizontal component and the vertical component of the gradient direction angle of a pixel point includes: using the cosine function value of the gradient direction angle of the pixel point as the horizontal component of the pixel point, and using the sine function value of the gradient direction angle of the pixel point as the vertical component of the pixel point.

[0048] After obtaining the horizontal component and the vertical component of each pixel point in the initial window of the current pixel point based on the above method, the local geometric direction consistency of the current pixel point can be calculated based on this.

[0049] Exemplarily, in the embodiment of the present invention, when calculating the local geometric direction consistency of a pixel point, the following relational expression can be referred to: ; is the local geometric direction consistency of the pixel point, is the initial window size, is the gradient magnitude of the th pixel point in the initial window of the pixel point, is the gradient direction angle of the th pixel point in the initial window of the pixel point, is the linear normalization function, is the horizontal component of the gradient direction angle of the th pixel point in the initial window of the pixel point, is the vertical component of the gradient direction angle of the th pixel point in the initial window of the pixel point, is the cosine function, and is the sine function.

[0050] In the above formula, is the cumulative sum of the weighted horizontal components in the initial window of the th pixel point, is the cumulative sum of the weighted vertical components in the initial window of the th pixel point. The larger the cumulative sum, the higher the vector consistency of the gradient direction angles of each pixel point after weighting in the initial window, the stronger the coherence, and the higher the possibility of being the eggshell edge.

[0051] Based on the above steps, the gradient direction entropy and local geometric direction consistency of each pixel point can be obtained respectively. By analyzing the degree of confusion of the gradient direction of the pixel point and the degree of consistency of the local geometric direction, the regular texture of the eggshell and the abnormal texture of the stain can be more accurately distinguished, avoiding misjudgment of a single feature, so as to accurately obtain the window size of each pixel point.

[0052] S4: Calculate the target window size of the pixel point, and calculate the segmentation threshold of the pixel point according to the gray mean value and gray standard deviation of all pixel points in the target window of the pixel point.

[0053] Exemplarily, in the embodiment of the present invention, to calculate the target window size of the pixel point, the following relational formula can be specifically referred to: ; is the target window size of the th pixel point, is the initial window size, is the abscissa index of the th pixel point, is the abscissa index of the th pixel point in the initial window of the th pixel point, is the ordinate index of the th pixel point, is the ordinate index of the th pixel point in the initial window of the th pixel point, is the local geometric direction consistency of the th pixel point, is the local geometric direction consistency of the th pixel point in the initial window of the th pixel point, is the gradient direction entropy of the th pixel point, is the exponential function with e as the base.

[0054] In the above formula, is the continuous confidence of the pixel point on the eggshell edge. Since the eggshell edge is continuous, when the consistency of the pixel point with the local geometric direction within its window is high and the average distance of the pixel point is farther, it indicates that the greater the possibility that the pixel point is the edge of the stain, and the higher the possible degree of the discontinuous stain pixel point misjudged as the eggshell edge. At this time, a larger window needs to be set to avoid missing the detection of the stain.

[0055] The higher the consistency of the local geometric direction of the pixel point and the smaller its gradient direction entropy, the more it conforms to the characteristics of the eggshell edge, and the higher the possibility of being the eggshell edge. At this time, a smaller window needs to be set to avoid misidentifying the normal eggshell edge pixels as stains when detecting the stain area.

[0056] It can be understood that based on the above steps, the target window size of each pixel point can be obtained. However, the size of the obtained target window may be an even non-integer. When determining the pixel point segmentation threshold, the required window is an odd integer length. Therefore, before determining the segmentation threshold based on the target window size of the pixel point in the embodiments of the present invention, the target window size of the pixel point can be first rounded down to an odd integer to obtain the final window size of the pixel point, and its window is constructed based on the final window size of the pixel point, so that the segmentation threshold can be accurately determined in the final window of the pixel point.

[0057] Exemplarily, when constructing its final window based on the final window size of the current pixel point, the current pixel point can be used as the center, and the surrounding pixel points can be evenly obtained around it to construct the final window of the pixel point. The surrounding pixel points and the current pixel point together constitute the final window of the current pixel point.

[0058] Among them, if the number of surrounding pixel points of some current pixel points is not enough to construct its final window, the final window of the current pixel point is constructed with the actually obtained number of surrounding pixel points.

[0059] Illustrate rounding down to an odd integer: If the target window size of the pixel point is 4.8, the size of its final window is 3; if the target window size of the pixel point is 3.2, the size of its final window is 3.

[0060] Exemplarily, in the embodiments of the present invention, to calculate the segmentation threshold of the pixel point, the following relational expression can be specifically referred to: ; is the segmentation threshold of the pixel point, is the gray mean value of all pixel points in the final window of the pixel point, is the The gray standard deviation of all pixel points in the final window of the pixel points is the sensitivity coefficient.

[0061] Among them, the sensitivity coefficient is a preset value used to adjust the sensitivity of the segmentation threshold to the standard deviation. The sensitivity coefficient can be set to 0.2 and can be specifically set according to actual needs.

[0062] After obtaining the segmentation threshold of each pixel point based on the above steps, the pixel points in its final window can be judged according to the segmentation threshold of each pixel point, so as to accurately obtain the stain pixel points.

[0063] S5: Process the gray image of the fresh egg according to the segmentation threshold of the pixel points to obtain the stain detection result of the gray image of the fresh egg.

[0064] Exemplarily, in the embodiment of the present invention, processing the gray image of the fresh egg according to the segmentation threshold of the pixel points includes: if the number of pixel points not higher than the segmentation threshold of the pixel points in the final window of the gray image of the fresh egg is greater than the number threshold, then the pixel point is a stain pixel point.

[0065] Among them, the number threshold can be set to 5, and the number threshold can be specifically set according to actual needs.

[0066] Specifically, the pixel points higher than the segmentation threshold of the current pixel point in the final window of the current pixel point can be marked as 1, the pixel points not higher than the segmentation threshold of the current pixel point can be marked as 0, and the obtained binary image is used as the segmentation result of the final window. If the number of pixel points marked as 0 in the final window of the current pixel point is greater than the number threshold, it means that the current pixel point is a stain pixel point.

[0067] It can be understood that if the number of pixel points marked as 0 in the final window of the current pixel point is not greater than the number threshold, it means that the current pixel point is not in the stain area.

[0068] After obtaining all the stain pixel points in the gray image of the fresh egg, the stain area can be obtained according to the stain pixel points.

[0069] Exemplarily, in the embodiment of the present invention, processing the gray image of the fresh egg according to the segmentation threshold of the pixel points to obtain the stain detection result of the gray image of the fresh egg includes: obtaining all the stain pixel points in the gray image of the fresh egg, and taking the connected domain of the stain pixel points as the stain in the gray image of the fresh egg.

[0070] Specifically, reference can be made to Figure 4 shown Figure 4 is a schematic diagram of the stain detection result of the gray image of the fresh egg obtained by dynamically adjusting the window size provided by the embodiment of the present invention. Combining Figure 3 and Figure 4It can be seen that after dynamically adjusting the window size of pixel points, it is possible to effectively avoid misidentifying the eggshell edge as a stain area, accurately obtain the true stain area, thereby improving the accuracy of detecting stains on the surface of fresh eggs. If there are stains on the surface of a fresh egg, it indicates that there may be contamination on its surface and it needs to be processed in a timely manner.

[0071] Exemplarily, in an embodiment of the present invention, after obtaining the stain detection result of the grayscale image of the fresh egg, it further includes: sending a cleaning prompt for the fresh egg corresponding to the grayscale image with stains.

[0072] Among them, the prompting method can be a sound prompt for the coordinates where the fresh egg with stains is located, or irradiating the fresh egg with stains using light beams of different colors, etc. The prompting method can be specifically set according to actual needs, and the embodiments of the present invention do not limit this too much here.

[0073] It can be seen that in an embodiment of the present invention, when obtaining the stain detection result of the fresh egg, the gradient direction angle of each pixel point in the grayscale image of the fresh egg can be obtained, and the gradient direction angle is divided into multiple intervals. According to the entropy sum of the number of pixel points in each interval in the initial window of the pixel point, the gradient direction entropy of the pixel point is determined; according to the horizontal component sum and the vertical component sum of the gradient direction angles of all pixel points in the initial window of the pixel point, the local geometric direction consistency of the pixel point is calculated; calculate the target window size of the pixel point : ; is the initial window size, , are respectively the abscissa indices of the pixel point and the pixel point in its initial window, , are respectively the ordinate indices of the pixel point and the pixel point in its initial window, , are respectively the local geometric direction consistencies of the pixel point and the pixel point in its initial window, is the gradient direction entropy of the pixel point, is the exponential function with e as the base; the segmentation threshold of the pixel point is calculated according to the grayscale mean value and the grayscale standard deviation of all pixel points in the target window of the pixel point, and the grayscale image of the fresh egg is processed according to the segmentation threshold of the pixel point to obtain the stain detection result of the grayscale image of the fresh egg, effectively improving the accuracy of the stain detection result of the fresh egg.

[0074] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A stain detection method for fresh egg cleaning, characterized in that, Including: Obtain the gradient direction angles of each pixel point in the grayscale image of fresh eggs, divide the gradient direction angles into multiple intervals, and determine the gradient direction entropy of the pixel point according to the sum of entropy values of the number of pixel points in each interval in the initial window of the pixel point; calculate the local geometric direction consistency of the pixel point according to the sum of the horizontal components and the sum of the vertical components of the gradient direction angles of all pixel points in the initial window of the pixel point; calculate the target window size of the pixel point : ; is the initial window size, , are respectively the pixel point and the horizontal coordinate index of the pixel point in its initial window, , are respectively the pixel point and the vertical coordinate index of the pixel point in its initial window, , are respectively the pixel point and the local geometric direction consistency of the pixel point in its initial window, is the gradient direction entropy of the pixel point, is the exponential function with base e; calculate the segmentation threshold of the pixel point according to the gray mean value and gray standard deviation of all pixel points in the target window of the pixel point, and process the fresh egg gray image according to the segmentation threshold of the pixel point to obtain the stain detection result of the fresh egg gray image.

2. The stain detection method for fresh egg cleaning according to claim 1, characterized in that, Before obtaining the gradient direction angles of all pixel points in the grayscale image of the fresh egg, it further includes: Taking a photo of the fresh egg surface and performing preprocessing to obtain a grayscale image of the fresh egg; wherein the preprocessing at least includes image denoising and grayscale processing.

3. The stain detection method for fresh egg cleaning according to claim 1, wherein, Dividing the gradient direction angles into multiple intervals, including: According to the preset number of intervals divide the gradient direction angle into intervals.

4. A stain detection method for fresh egg cleaning according to claim 1, characterized in that, Determining the gradient direction entropy of the pixel point according to the entropy value sum of the number of pixel points in each interval in the initial window of the pixel point, including: ; is the gradient direction entropy of the pixel point, is the number of intervals of the gradient direction angle, is the number of pixel points in the initial window of the pixel point that are located in the th interval, is the logarithmic function with base e, is the linear normalization function.

5. A stain detection method for fresh egg cleaning according to claim 1, characterized in that, The acquisition methods of the horizontal component and the vertical component of the gradient direction angle of the pixel point, including: Taking the cosine function value of the gradient direction angle of the pixel point as the horizontal component of the pixel point, and taking the sine function value of the gradient direction angle of the pixel point as the vertical component of the pixel point.

6. The stain detection method for fresh egg cleaning according to claim 1, wherein, Calculating the local geometric direction consistency of the pixel point according to the sum of the horizontal components and the sum of the vertical components of the gradient direction angles of all pixel points in the initial window of the pixel point, including: ; is the local geometric direction consistency of the pixel point, is the initial window size, , are respectively the gradient magnitude and gradient direction angle of the pixel point in the initial window of the pixel point, , are respectively the horizontal component and vertical component of the gradient direction angle of the pixel point in the initial window of the 7. A stain detection method for fresh egg cleaning according to claim 1, characterized in that, Calculating the segmentation threshold of the pixel point according to the grayscale mean value and the grayscale standard deviation of all pixel points in the target window of the pixel point, including: Rounding down the size of the target window of the pixel point to an odd integer to obtain the final window size of the pixel point; ; is the segmentation threshold for the pixel point, , are respectively the gray mean value and the gray standard deviation of all pixel points in the final window of the pixel point, and is the sensitivity coefficient.

8. A stain detection method for fresh egg cleaning according to claim 1, characterized in that Processing the grayscale image of the fresh egg according to the segmentation threshold of the pixel point, including: If the number of pixel points not higher than the segmentation threshold of the pixel point in the final window of the pixel point in the grayscale image of the fresh egg is greater than the number threshold, then the pixel point is a stain pixel point.

9. A stain detection method for fresh egg cleaning according to claim 8, characterized in that, Processing the grayscale image of the fresh egg according to the segmentation threshold of the pixel point to obtain the stain detection result of the grayscale image of the fresh egg, including: Obtaining all stain pixel points in the grayscale image of the fresh egg, and taking the connected domain of the stain pixel points as the stain in the grayscale image of the fresh egg.

10. A stain detection method for fresh egg cleaning according to claim 1, characterized in that, After obtaining the stain detection result of the grayscale image of the fresh egg, it further includes: Sending a cleaning prompt for the fresh egg corresponding to the grayscale image of the fresh egg with stains.

Citation Information

Patent Citations

  • Lung X-ray image processing method for lung fiber inhalation pathopoiesis

    CN118196123A

  • Intelligent control method and system of egg liquid spraying machine

    CN119600533A

  • Stain detection method for linen washing

    CN119810101A

  • Film material surface treatment defect detection method and system based on image recognition

    CN119887755A

  • Screen defect detection method and apparatus, and device and storage medium

    WO2025045021A1

Cited By

  • Intelligent poultry egg sorting method based on image processing

    CN120599597A

  • Intelligent egg sorting method based on image processing

    CN120599597B

  • Monitoring video enhancement method for farm

    CN120634901A