An image recognition-based automatic egg grading method

By using high-resolution cameras and image preprocessing technology, combined with high-precision electronic scales, the relationship between density and freshness is established, enabling automated and precise grading of eggs. This solves the limitations of manual grading and the loopholes in sampling inspection, ensuring the accuracy of egg freshness and market fairness.

CN120021568BActive Publication Date: 2025-10-24HUBEI ZHENGRENTANG TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510026225.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-10-24
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

Existing egg grading methods rely on human experience, which cannot accurately determine freshness, and sampling inspections have loopholes and cannot fully cover product quality.

Method used

High-resolution cameras and uniform lighting equipment are used to acquire images of eggs. Image preprocessing algorithms are used to extract contour coordinates. Ellipse fitting and Haushold distance improvement algorithms are used to match the outer contour. Combined with high-precision electronic scales to measure weight, the relationship between density and freshness is established to achieve automated grading.

Benefits of technology

This system enables precise classification of egg freshness, preventing unscrupulous vendors from exploiting loopholes in the testing process to pass off inferior products as superior ones, thus ensuring the fairness of product quality and market order.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120021568B_ABST
    Figure CN120021568B_ABST
Patent Text Reader

Abstract

The application discloses an image recognition-based automatic egg grading method, belongs to the technical field of image recognition detection, and aims at solving the problem that the existing egg freshness detection cannot cover all products. The method can collect clear images through a high-resolution camera and a uniform lighting device, accurately extract discrete point coordinates of an egg contour in combination with an advanced image preprocessing algorithm, establish the relationship between the outer contour data and the horizontal diameter and the vertical diameter by adopting an optimized ellipse fitting least square method, perform outer contour matching and correction through an algorithm improved based on a Hausdorff distance, calculate a more accurate egg volume, measure the weight in combination with a high-precision electronic scale, accurately judge the egg freshness according to an accurate function relationship between the density and the freshness, and thus, the accurate division of the egg freshness grade is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image recognition detection, and particularly relates to an automatic egg grading method based on image recognition. BACKGROUND

[0002] In the production, sale and related industry chain of eggs, accurate division of egg grades is of great significance to guarantee product quality, meet market demand and realize reasonable pricing. The traditional egg grading method mainly relies on manual experience, and the appearance of eggs, such as size, shape, color and surface condition, is observed manually to grade. This manual grading method has many limitations and cannot determine the freshness of eggs.

[0003] In terms of freshness detection, the traditional method can only determine through sampling detection, which has limitations and cannot cover all products. This gives unscrupulous businessmen an opportunity. For example, they may mix a small amount of non-fresh eggs into the samples for inspection. Since consumers cannot directly determine the freshness of the eggs when purchasing, such behavior of using substandard goods damages the rights and interests of consumers and disrupts the market order. Therefore, image recognition can be used to detect eggs more comprehensively and carefully, which is expected to overcome the many drawbacks of the traditional grading method and realize the automation and precision of egg grading. SUMMARY

[0004] The purpose of the present application is to provide an automatic egg grading method based on image recognition, which solves the problem that the existing egg freshness detection in the background art cannot cover all products.

[0005] To achieve the above purpose, the present application provides the following technical scheme: an automatic egg grading method based on image recognition, comprising the following steps:

[0006] S1. Image acquisition: clear images of eggs are obtained by using a high-resolution camera and a uniform lighting device. The resolution of the camera is not less than 2000x2000 pixels, and the lighting device uses multi-angle white LED light sources to ensure that the image is free from shadow interference;

[0007] S2. Image preprocessing: the collected images are sequentially subjected to grayscale processing, filtering and noise reduction and image segmentation operations to obtain discrete point coordinates (x i ,y i ), i=1, 2, …, n of the egg contour;

[0008] S3. Storage and processing of outer contour data: store the discrete point coordinate data of the outer contour of multiple eggs, establish an algorithm formula between the outer contour data and the horizontal diameter and the vertical diameter, and process the discrete point coordinates (x i ,y i), i = 1, 2, … n, the horizontal diameter D is determined by ellipse fitting x and the vertical diameter D y , the ellipse fitting uses the least square method to minimize the sum of square distance of fitting ellipse to each discrete point, and the ellipse equation is where The ellipse parameters are solved by optimization algorithm, the relationship between the outer contour data and the horizontal diameter and the vertical diameter is obtained, the formula is verified and optimized according to a large number of sample data, and the formula is where V is the volume of the egg, C is the outer contour data, k1 and k2 are correction coefficients obtained by fitting sample data;

[0009] S4. Egg outer contour matching and correction: when the outer contour of the egg is detected, an algorithm based on the Hausdorff distance is used to calculate the distance between it and the stored outer contour data, for two discrete point sets A = {(x ai ,y ai )} and B = {(x bi ,y bi )}, the Hausdorff distance is defined as The Hausdorff distance between the detected egg outer contour and each stored outer contour is calculated, the outer contour with the smallest distance is found as the closest outer contour, and the gap Δ = H(A test ,A closest ) between them is calculated, where A test is the detected egg outer contour, and A closest is the closest stored outer contour, the correction coefficient k is determined according to the gap, the correction coefficient is obtained by fitting the experimental data in advance, and a quadratic function is used for fitting: k = aΔ 2 +bΔ+c, where a, b, and c are parameters determined by experiments;

[0010] S5. Egg weight measurement: the weight m of the egg is measured by a high-precision electronic scale, with an accuracy of ±0.1 g, and the egg needs to be placed stably on the scale during measurement;

[0011] S6. Egg volume calculation: the horizontal diameter D x and the vertical diameter D y are measured, the closest outer contour and the corresponding horizontal diameter and vertical diameter are matched, and the algorithm formula between the outer contour data and the horizontal diameter and the vertical diameter is used to calculate the volume of the egg, and the correction coefficient k is considered when calculating the volume, that is, V final = V × (1 + k);

[0012] S7. Density calculation and freshness relationship establishment: the density of the egg is obtained according to the measured weight m and the calculated volume V final , and the functional relationship between the density and the freshness is established through a large number of samples, and the linear regression method is used to accurately determine the freshness of the egg;

[0013] S8. Grade division and result output: According to the established freshness function relationship and the preset grade standard, the eggs are divided into grades, and the related data are recorded. The system automatically divides the eggs into corresponding grade packaging areas, so as to realize the automatic grading of the eggs.

[0014] Further, the gray-scale processing in the image preprocessing step adopts a weighted average method, and the formula is Gray = 0.299R + 0.587G + 0.114B, wherein R, G and B are respectively the red, green and blue channel pixel values of the color image.

[0015] Further, the filtering and noise reduction in the image preprocessing step uses Gaussian filtering, and the two-dimensional Gaussian function formula is wherein σ is a standard deviation, and the value range is 0.5-1.5.

[0016] Further, the image segmentation in the image preprocessing step uses an adaptive threshold segmentation algorithm, and the formula is T(x, y) = μ(x, y) + kσ(x, y), wherein μ(x, y) is the average gray value of the local region (x, y), σ(x, y) is the standard deviation of the local region, and k has a value range of 0.8-1.2. According to the local gray characteristics of the image, the threshold value is dynamically determined, the egg image is separated from the background, and a binary image is obtained, wherein the egg part is the foreground, the pixel value is set to 255, and the background part is 0.

[0017] Further, in the density calculation and freshness relationship establishment step, according to the measured egg weight m and the calculated volume V, the density formula is used to calculate the density of the egg.

[0018] Further, in the density calculation and freshness relationship establishment step, the specific steps of judging the freshness of the egg by using the linear regression method are as follows: let the freshness be F, and the function relationship between the freshness and the density be F = aρ + b, wherein a and b are coefficients obtained by fitting sample data, the number of samples is not less than 500, and the eggs cover different varieties and storage conditions.

[0019] Further, in the grade division and result output step, the egg grade is divided into four levels according to the full score of 100: the eggs with F≥90 are divided into super fresh, the eggs with 80≤F<90 are divided into first-class fresh, the eggs with 70≤F<80 are divided into second-class fresh, and the eggs with F<70 are not fresh or defective products.

[0020] Further, in the image acquisition step, the camera is installed 30-50 cm above the egg conveying device, and the shooting angle is perpendicular to the egg surface.

[0021] Further, in the contour data storage and processing step, the stored egg contour data covers eggs of different shapes and sizes, and is regularly updated to adapt to new egg varieties or changes in breeding conditions. When establishing the relationship between the contour data and the transverse diameter and longitudinal diameter, the irregularity of the egg contour is considered, and the method of fitting an ellipse is optimized by using a weighted fitting method.

[0022] Further, in the density calculation and freshness relationship establishment step, when establishing the function relationship between density and freshness, the freshness of the sample egg is determined by chemical analysis.

[0023] Compared with the prior art, the beneficial effects of the present application are:

[0024] The present application provides an automatic egg grading method based on image recognition. By using high-resolution cameras and uniform lighting equipment to capture clear images, combined with advanced image preprocessing algorithms, the discrete point coordinates of the egg contour can be accurately extracted. An optimized least squares ellipse fitting method is used to establish the relationship between the contour data and the transverse diameter and longitudinal diameter. Through the improved algorithm based on Hausdorff distance, the contour is matched and corrected, and a more accurate egg volume is calculated. Combined with high-precision electronic scale measurement of weight, and according to the accurate function relationship between density and freshness, the freshness of the egg can be accurately judged, so as to realize the accurate division of the freshness grade of the egg, and effectively avoid the use of detection loopholes by unscrupulous traders to pass off inferior goods as good ones. BRIEF DESCRIPTION OF DRAWINGS

[0025] Figure 1 The present application provides an automatic egg grading method based on image recognition. By using high-resolution cameras and uniform lighting equipment to capture clear images, combined with advanced image preprocessing algorithms, the discrete point coordinates of the egg contour can be accurately extracted. An optimized least squares ellipse fitting method is used to establish the relationship between the contour data and the transverse diameter and longitudinal diameter. Through the improved algorithm based on Hausdorff distance, the contour is matched and corrected, and a more accurate egg volume is calculated. Combined with high-precision electronic scale measurement of weight, and according to the accurate function relationship between density and freshness, the freshness of the egg can be accurately judged, so as to realize the accurate division of the freshness grade of the egg, and effectively avoid the use of detection loopholes by unscrupulous traders to pass off inferior goods as good ones. DETAILED DESCRIPTION

[0026] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0027] To solve the technical problem that the existing egg freshness detection cannot cover all products, such as Figure 1 As shown in the preferred technical solutions provided below:

[0028] An automatic egg grading method based on image recognition includes the following steps:

[0029] Step 1. Image Acquisition: Use a high-resolution camera and uniform lighting to obtain clear images of the eggs. The camera resolution should be at least 2000 x 2000 pixels. Use a multi-angle white LED light source to ensure that the image is free of shadows. The camera should be mounted 30-50 cm above the egg conveyor, with the camera angle perpendicular to the egg surface.

[0030] Step 2. Image preprocessing: The collected images are processed in grayscale, filtered for noise reduction, and image segmentation to obtain the discrete point coordinates of the egg outline (x i ,y i ), i=1,2,…,n; Grayscale is converted using the weighted average method, the formula is Gray=0.299R+0.587G+0.114B, where R, G, and B are the red, green, and blue channel pixel values ​​of the color image respectively. By reasonably allocating the RGB channel weights, the color image is converted into a grayscale image, effectively reducing the amount of image data while retaining the image's brightness information for easy subsequent processing; Gaussian filtering is used for filtering and noise reduction, and its two-dimensional Gaussian function formula is Where σ is the standard deviation, ranging from 0.5 to 1.5. By taking a weighted sum of each pixel in the image and its neighboring pixels, the image can be effectively smoothed, noise interference can be removed, and the edge and detail information of the egg image can be retained. Image segmentation uses an adaptive threshold segmentation algorithm with the formula T(x,y)=μ(x,y)+kσ(x,y), where μ(x,y) is the average grayscale value of the local area (x,y), σ(x,y) is the standard deviation of the local area, and k ranges from 0.8 to 1.2. The threshold is dynamically determined based on the local grayscale characteristics of the image to separate the egg image from the background, resulting in a binary image, where the egg part is the foreground with a pixel value of 255 and the background part is 0.

[0031] Step 3. Storage and processing of outer contour data: Store the coordinate data of discrete points of the outer contour of multiple eggs, establish the algorithm formula between the outer contour data and the horizontal diameter and vertical diameter, and calculate the coordinates of the discrete points of the outer contour of the egg (x i ,y i ), i=1,2,…n, and the transverse diameter D is determined by ellipse fitting x and longitudinal diameter D y , the ellipse fitting adopts the least square method to minimize the sum of the squares of the distances from the fitted ellipse to each discrete point. The ellipse equation is in The ellipse parameters are solved by the optimization algorithm to obtain the relationship between the outer contour data and the horizontal diameter and vertical diameter. The formula is verified and optimized based on a large amount of sample data. The formula is: Where V is the volume of the egg, C is the outer contour data, k1 and k2 are correction coefficients fitted by sample data, the stored egg outer contour data covers eggs of different shapes and sizes, and is updated regularly to adapt to new egg varieties or changes in breeding conditions. When establishing the relationship between the outer contour data and the transverse diameter and longitudinal diameter, the irregularity of the egg contour is considered, and the method of fitting an ellipse is optimized by using a weighted fitting method;

[0032] Step four. Egg outer contour matching and correction: After detecting the outer contour of the egg, the Hausdorff distance improved algorithm is used to calculate the distance between the detected outer contour and the stored outer contour data. For two discrete point sets A = {(x ai ,y ai )} and B = {(x bi ,y bi )} of the egg outer contour, the Hausdorff distance is defined as The Hausdorff distance between the detected egg outer contour and each stored outer contour is calculated, and the outer contour with the smallest distance is found as the closest outer contour. The difference Δ = H(A test ,A closest ) between the two is calculated, where A test is the detected egg outer contour and A closest is the closest stored outer contour. The correction coefficient k is determined according to the difference, which is fitted by experimental data in advance. A quadratic function is used to fit: k = aΔ 2 +bΔ+c, where a, b, and c are parameters determined by experiments;

[0033] Step five. Egg weight measurement: The high-precision electronic scale is used to measure the weight of the egg m, with an accuracy of ±0.1 g. The egg needs to be placed steadily on the scale during measurement;

[0034] Step six. Egg volume calculation: The transverse diameter D x and longitudinal diameter D y of the egg are measured. According to the closest outer contour matched and the corresponding transverse diameter and longitudinal diameter, the volume of the egg is calculated by combining the algorithm formula between the outer contour data and the transverse diameter and longitudinal diameter. The correction coefficient k is considered when calculating the volume, i.e. V final = V × (1 + k);

[0035] Step seven. Density calculation and freshness relationship establishment: According to the measured weight m and calculated volume V final , the density of the egg is calculated A functional relationship between density and freshness is established using a large number of samples. Linear regression is used to accurately determine egg freshness. Chemical analysis is then used to comprehensively determine the freshness of the sampled eggs to improve the accuracy of freshness assessment. The specific steps for determining egg freshness are as follows: Let freshness be F, and the functional relationship between freshness and density be F = aρ + b, where a and b are coefficients obtained by fitting the sample data. The sample size is no less than 500, covering eggs of different varieties and storage conditions.

[0036] Step 8. Grading and result output: Based on the established freshness function relationship and the preset grading standards, the eggs are graded and the relevant data is recorded. The system automatically diverts the eggs to the corresponding grade packaging area to achieve automatic grading of eggs. The egg grades are calculated based on a full score of 100 and divided into four levels: eggs with F≥90 are classified as extra fresh, 80≤F<90 are classified as first-grade fresh, 70≤F<80 are classified as second-grade fresh, and F<70 are not fresh or defective.

[0037] Specifically, a high-resolution camera, combined with a multi-angle white LED light source, captures clear, shadow-free images of eggs. The captured images undergo grayscale conversion, filtering, noise reduction, and image segmentation preprocessing to accurately extract the coordinates of discrete points within the egg's outline. The stored data for multiple egg contours is used to establish an algorithm formula related to the horizontal and vertical diameters. Ellipse fitting is then used to determine the egg's shape characteristics. When inspecting new eggs, an algorithm based on the Householder distance is used to compare their contours with the stored data, finding the closest contour and calculating the difference. This correction factor is then used to optimize volume calculations. Simultaneously, a high-precision electronic scale measures the egg's weight. Combined with the calculated volume, the egg's density is calculated using a density formula. The egg's freshness is then determined based on a functional relationship between density and freshness established using a large number of samples. Finally, the system automatically sorts the eggs into the appropriate packaging areas, achieving automated grading.

[0038] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.

[0039] The above merely describes preferred specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art, according to the technical scheme and inventive concept of the present application, can make equivalent replacements or changes within the technical scope disclosed by the present application, which should be covered within the protection scope of the present application.

Claims

1. An automated egg grading method based on image recognition, characterized by, The method comprises the following steps: S1. Image acquisition: clear images of eggs are obtained by using a high-resolution camera and a uniform lighting device, the resolution of the camera is not less than 2000*2000 pixels, and the lighting device adopts a multi-angle white LED light source to ensure that the image is free from shadow interference; S2. Image preprocessing: The collected images are sequentially subjected to grayscale processing, filtering and noise reduction, and image segmentation operations to obtain discrete point coordinates (x i ,y i ), i = 1, 2, …, n of the egg contour; S3. The outer contour data storage and processing: store the discrete point coordinate data of the outer contour of the plurality of eggs, establish the algorithm formula between the outer contour data and the transverse diameter and the longitudinal diameter, for the discrete point coordinate (x i ,y i ) of the outer contour of the egg, i = 1, 2, … n, determine the transverse diameter D x and the longitudinal diameter D y through the ellipse fitting, the ellipse fitting adopts the least square method, the distance square sum of the fitting ellipse to each discrete point is minimum, the ellipse equation is wherein the ellipse parameters are solved through the optimization algorithm, the relationship between the outer contour data and the transverse diameter and the longitudinal diameter is obtained, the formula is verified and optimized according to a large amount of sample data, the formula is wherein V is the volume of the egg, C is the outer contour data, k1 and k2 are correction coefficients obtained through the sample data fitting; S4. Egg outer contour matching and correction: After detecting the outer contour of the egg, the Hausdorff distance based algorithm is used to calculate the distance between the detected outer contour and the stored outer contour data. For two discrete point sets of egg outer contour A = {(x ai ,y ai )} and B = {(x bi ,y bi )}, the Hausdorff distance is defined as The Hausdorff distance between the detected egg outer contour and each stored outer contour is calculated, the outer contour with the smallest distance is found as the closest outer contour, the difference Δ = H(A test ,A closest ) between the two is calculated, where A test is the detected egg outer contour, A closest is the closest stored outer contour, the correction coefficient k is determined according to the difference, the correction coefficient is obtained by fitting the experimental data in advance, a quadratic function is used for fitting: k = aΔ 2 +bΔ+c, where a, b, c are parameters determined by experiment; S5. Egg weight measurement: the weight m of the egg is measured by using a high-precision electronic scale, the accuracy is ±0.1 g, and the egg needs to be placed stably on the scale during measurement; S6. Egg volume calculation: measure the cross diameter D of the egg x and the longitudinal diameter D y According to the closest outer contour matched and the corresponding cross diameter and longitudinal diameter, the volume of the egg is calculated by combining the algorithm formula between the outer contour data and the cross diameter and longitudinal diameter. When calculating, the correction coefficient k is considered to correct the volume, that is, V final = V x (1 + k); S7. Density calculation and freshness relationship establishment: according to the measured weight m and the calculated volume V final The density of the egg is obtained, the function relationship between the density and the freshness is established through a large number of samples, and the linear regression method is used to accurately determine the freshness of the egg. S8. Grade division and result output: according to the established freshness function relationship and the preset grade standard, the eggs are divided into grades, the related data are recorded, the system automatically divides the eggs into corresponding grade packaging areas, and the automatic grading of the eggs is realized.

2. The automated egg grading method based on image recognition as claimed in claim 1, wherein: In the image preprocessing step, the gray-scale processing adopts a weighted average method, and the formula is Gray=0.299R+0.587G+0.114B, wherein R, G and B are respectively the red, green and blue channel pixel values of the color image.

3. The automated egg grading method based on image recognition as claimed in claim 1, wherein: The filtering denoising in the image preprocessing step uses Gaussian filtering, and the two-dimensional Gaussian function formula is wherein σ is a standard deviation, and the value range is 0.5-1.

5.

4. The automated egg grading method based on image recognition as claimed in claim 1, wherein: In the image preprocessing step, the image segmentation uses an adaptive threshold segmentation algorithm, and the formula is T(x,y)=μ(x,y)+kσ(x,y), wherein μ(x,y) is the average gray value of the local region (x,y), σ(x,y) is the standard deviation of the local region, k is in the range of 0.8-1.2, the threshold value is dynamically determined according to the local gray characteristics of the image, the egg image is separated from the background, and a binary image is obtained, wherein the egg part is the foreground, the pixel value is set to 255, and the background part is 0.

5. The automated egg grading method based on image recognition as claimed in claim 1, wherein: In the density calculation and freshness relationship establishment step, according to the measured weight m of the egg and the calculated volume V, the density formula The density of the egg is calculated.

6. The automated egg grading method based on image recognition as claimed in claim 1, wherein, In the density calculation and freshness relationship establishment step, the specific steps of judging the freshness of the egg by using the linear regression method are as follows: the freshness is F, the function relationship between the freshness and the density is F=aρ+b, wherein a and b are coefficients obtained by fitting sample data, the number of samples is not less than 500, and the eggs of different varieties and storage conditions are covered.

7. The automated egg grading method based on image recognition as claimed in claim 6, wherein, In the grade division and result output step, the egg grade is divided into four levels according to a full score of 100, that is, eggs with F≥90 are classified as super-fresh, eggs with 80≤F<90 are classified as first-class fresh, eggs with 70≤F<80 are classified as second-class fresh, and eggs with F<70 are classified as not fresh or substandard.

8. The automated egg grading method based on image recognition as claimed in claim 1, wherein: In the image acquisition step, the camera is installed 30-50 cm above the egg conveying device, and the shooting angle is perpendicular to the surface of the egg.

9. The automated egg grading method based on image recognition as claimed in claim 1, wherein: In the outer contour data storage and processing step, the stored egg outer contour data covers eggs of different shapes and sizes, and is updated regularly to adapt to new egg varieties or changes in breeding conditions, when the relationship between the outer contour data and the transverse diameter and the longitudinal diameter is established, the irregularity of the egg contour is considered, and the fitting ellipse method is optimized by using a weighted fitting method.

10. The automated egg grading method based on image recognition as claimed in claim 9, wherein: In the density calculation and freshness relationship establishment step, when the function relationship between the density and the freshness is established, the freshness of the sample egg is determined by using a chemical analysis method.

Citation Information

Patent Citations

  • Machine vision technology based method for rapidly detecting egg freshness

    CN102147402A

  • Method for processing plane figure image

    CN105787995A