Automatic Extraction Method for Surface Crack Features of Breeding Duck Eggs Based on Image Recognition

By obtaining the width-length ratio and circle-like value of the binarization map of the duck egg, and combining the threshold method to distinguish light spots and cracks, the problem of indistinguishable light spots and cracks in the existing technology is solved, and the accurate identification of cracks on the surface of breeding duck eggs is achieved.

CN120070415BActive Publication Date: 2025-07-18BEIJING NANKOU DUCK BREEDING TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510517246.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-07-18
Estimated Expiration
2045-04-23

AI Technical Summary

Technical Problem

In the existing automatic extraction technology of crack features on the surface of breeding duck eggs, light spots and cracks are difficult to distinguish, resulting in misjudgment of identification.

Method used

The width-length ratio and circle-like value of the duck egg binarization diagram are obtained respectively based on the duck frame selection method and the circle-like value acquisition method. The width-length ratio threshold and circle-like threshold are obtained by the threshold acquisition method. The crack signal is generated based on the width-length ratio threshold, the circle-like threshold, the width-length ratio and circle-like value to distinguish light spots and cracks.

Benefits of technology

It improves the accuracy of crack recognition on the surface of breeding duck eggs, can effectively distinguish light spots and cracks, and improves the recognition effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070415B_ABST
    Figure CN120070415B_ABST
Patent Text Reader

Abstract

The present invention discloses an automatic extraction method for surface crack features of breeding duck eggs based on image recognition, which relates to the technical field of automatic extraction of surface crack features of breeding duck eggs, and includes the following steps: obtaining a light-transmitting image of the breeding duck egg by an image acquisition device, marked as the duck egg light-transmitting image; performing grayscale processing on the duck egg light-transmitting image to obtain a duck egg grayscale image; performing binarization processing on the duck egg grayscale image to obtain a duck egg binarized image; respectively obtaining the width-to-length ratio and the circularity value of the duck egg binarized image based on the duck frame selection method and the circularity value acquisition method; obtaining the width-to-length ratio threshold and the circularity threshold by using the threshold acquisition method; generating crack signals and surface crack features of the duck egg based on the width-to-length ratio threshold, the circularity threshold, the width-to-length ratio value, and the circularity value; The present invention is used to solve the problem that in the existing automatic extraction technology of surface crack features of breeding duck eggs, the light spots and cracks of the eggs themselves cannot be distinguished, resulting in misjudgment in the recognition of surface cracks of breeding duck eggs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automatic extraction of surface crack characteristics of breeding duck eggs, and specifically to an automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition. Background Art

[0002] The eggshells of breeding duck eggs are relatively fragile and prone to cracks. Cracks will provide a channel for microorganisms to invade, resulting in damage to the interior of the breeding duck eggs, and further causing the breeding duck eggs to be unable to breed normally. Therefore, it is necessary to identify the surface cracks of breeding duck eggs.

[0003] The existing crack identifications include acoustic wave identification and image identification. Image identification is based on the light transmission image of the breeding duck egg. However, due to the uneven thickness of the duck eggshell itself, for example, light spots will appear in the light transmission image of the thin part. The light spots and cracks have similar colors, making it difficult to distinguish the light spots and cracks based on color. When extracting the crack binary image, the light spots are easily regarded as cracks. For example, in the patent application with the publication number CN119359731A, a method and system for detecting surface cracks of duck eggs based on image analysis are disclosed. This solution classifies and identifies green duck eggs and white duck eggs without considering the light spots of the duck eggs themselves, resulting in misjudgment of cracks. That is, in the existing automatic extraction technology for surface crack characteristics of breeding duck eggs, the light spots and cracks of the eggs themselves are not distinguished, leading to misjudgment in the identification of surface cracks of breeding duck eggs. Summary of the Invention

[0004] The present invention aims to solve at least one of the technical problems in the existing technology to some extent. By respectively obtaining the width-to-length ratio and circularity value of the binary image of the duck egg through the duck frame selection method and the circularity value acquisition method, and using the threshold acquisition method to obtain the width-to-length ratio threshold and circularity threshold, crack signals and surface crack characteristics of the duck egg are generated based on the width-to-length ratio threshold, circularity threshold, width-to-length ratio, and circularity value, so as to solve the problem that in the existing automatic extraction technology for surface crack characteristics of breeding duck eggs, the light spots and cracks of the eggs themselves are not distinguished, resulting in misjudgment in the identification of surface cracks of breeding duck eggs.

[0005] To achieve the above object, the present application provides an automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition, including the following steps:

[0006] Obtain the light transmission image of the breeding duck egg through an image acquisition device, and mark it as the duck egg light transmission image;

[0007] Perform gray-scale processing on the duck egg light transmission image to obtain the duck egg gray-scale image;

[0008] Perform binary processing on the duck egg gray-scale image to obtain the duck egg binary image;

[0009] Respectively obtain the width-to-length ratio and circularity value of the duck egg binary image through the duck frame selection method and the circularity value acquisition method;

[0010] Obtain the aspect ratio threshold and the near-circularity threshold by using the threshold acquisition method;

[0011] Generate crack signals and duck egg surface crack characteristics based on the aspect ratio threshold, the near-circularity threshold, the aspect ratio value, and the near-circularity value.

[0012] Furthermore, performing grayscale processing on the duck egg translucent image to obtain the duck egg grayscale image includes the following sub-steps:

[0013] Obtain the RGB value of each pixel point in the duck egg translucent image, and mark it as the duck egg RGB value;

[0014] Use the grayscale conversion formula to convert all the duck egg RGB values in the duck egg translucent image into grayscale values to obtain the duck egg grayscale image.

[0015] Furthermore, performing binarization processing on the duck egg grayscale image to obtain the duck egg binarized image includes the following sub-steps:

[0016] Obtain the grayscale value of each pixel point in the duck egg grayscale image, and mark it as the duck egg grayscale value;

[0017] Divide the grayscale values from 0 to 255 into a1 equal-interval range intervals, and mark them as the divided range intervals;

[0018] Count the frequency of the duck egg grayscale values in each divided range interval, and mark it as the divided range frequency;

[0019] Taking the duck egg grayscale value as the X-axis, the divided range frequency as the Y-axis, and the divided range interval as the histogram interval to draw a histogram, and mark it as the duck egg grayscale histogram.

[0020] Furthermore, performing binarization processing on the duck egg grayscale image to obtain the duck egg binarized image also includes the following sub-steps:

[0021] Obtain the divided range interval in the duck egg grayscale histogram where the divided range frequency is greater than the divided range frequencies on both the left and right sides, and mark it as the candidate peak interval; obtain the median of the candidate peak interval, and mark it as the candidate peak median;

[0022] Mark the candidate peak interval where the interval between two adjacent candidate peak medians is greater than the adjacent grayscale interval threshold as the selected peak interval, and select three selected peak intervals;

[0023] Sort the three selected peak intervals in ascending order according to the candidate peak median, and mark them as the first peak interval, the second peak interval, and the third peak interval respectively;

[0024] Obtain the divided range interval between the second peak interval and the third peak interval, and mark it as the intermediate preselection interval, and obtain the intermediate preselection interval with the smallest divided range frequency and mark it as the intermediate final interval;

[0025] Obtain the median of the middle final interval and mark it as the binarization threshold;

[0026] Set the duck egg gray values greater than or equal to the binarization threshold in the duck egg gray scale image to 0, and set the duck egg gray values less than the binarization threshold in the duck egg gray scale image to 255 to obtain the duck egg binarization image.

[0027] Further, obtaining the width-to-length ratio and the circularity value of the duck egg binarization image based on the duck frame selection method and the circularity value acquisition method includes the following sub-steps:

[0028] Obtain the pixel points with a gray value of 0 adjacent to the pixel points with a gray value of 255 in the duck egg binarization image and mark them as boundary pixel points;

[0029] Mark the pixel point area with a gray value of 0 in the duck egg binarization image as the initial abnormal area;

[0030] Use the frame selection method to obtain the frame selection rectangle of each initial abnormal area;

[0031] Obtain the long side and the short side of the frame selection rectangle and mark them as Jc and Jk respectively;

[0032] Calculate the width-to-length ratio as: Bck = Jk / Jc; where Bck is the width-to-length ratio;

[0033] Use the circularity value acquisition method to obtain the circularity value of each initial abnormal area.

[0034] Further, the frame selection method includes:

[0035] Establish a plane rectangular coordinate system and mark it as the frame selection coordinate system; place the duck egg binarization image in the first quadrant of the frame selection coordinate system;

[0036] Obtain the coordinates of a pixel point with the smallest abscissa in the initial abnormal area and mark it as (Xmin, Y1), obtain the coordinates of a pixel point with the largest abscissa in the initial abnormal area and mark it as (Xmax, Y2); draw a straight line parallel to the Y-axis through the point (Xmin, Y1) and mark it as the first straight line; draw a straight line parallel to the Y-axis through the point (Xmax, Y2) and mark it as the second straight line; obtain the midpoint of the point (Xmin, Y1) and the point (Xmax, Y2) and mark it as the reference midpoint;

[0037] Rotate the first straight line and the second straight line clockwise around the reference midpoint by n times of ds°, and the maximum rotation range is 180°;

[0038] After each rotation of ds°, draw two lines perpendicular to the first line through the boundary pixel points of the initial abnormal area, and mark them as the third line and the fourth line respectively. At the same time, ensure that the distance between the third line and the fourth line is the maximum value that can be drawn. The rectangle formed by the first line, the second line, the third line, and the fourth line is marked as the initial rectangle. Obtain the length and width of the initial rectangle, and multiply the length and width of the initial rectangle to calculate the area of the initial rectangle;

[0039] When the rotation ends, obtain the initial rectangle with the smallest area and mark it as the selected rectangle.

[0040] Further, the method for obtaining the circularity value includes:

[0041] Connect the midpoints of all adjacent boundary pixel points of the initial abnormal area to obtain distance line segments, and calculate the sum of all distance line segments, marked as Lz;

[0042] Obtain the number of pixel points in the initial abnormal area and mark it as Gs;

[0043] Obtain the area of each pixel point in the selected coordinate system and mark it as Sd;

[0044] Calculate the circularity value as: Zz = (4 * Π * Sd * Gs) / (Lz 2 ); where Zz is the circularity value.

[0045] Further, the method for obtaining the aspect ratio threshold and the circularity threshold using the threshold method includes the following sub-steps:

[0046] Obtain the first number of speckle transmission images containing only normal duck eggs and mark them as normal speckle images;

[0047] Obtain the aspect ratio value of each normal speckle image and mark it as the normal aspect ratio value;

[0048] Obtain the circularity value of each normal speckle image and mark it as the normal circularity value;

[0049] Use the threshold method to obtain the aspect ratio threshold of the normal aspect ratio value;

[0050] Use the threshold method to obtain the circularity threshold of the normal circularity value.

[0051] Further, the threshold method also includes:

[0052] Obtain the normal aspect ratio value range, divide the normal aspect ratio value range into a2 equal interval range intervals, and mark them as aspect ratio division intervals;

[0053] Count the frequency of each aspect ratio division interval and mark it as the aspect ratio division frequency;

[0054] Taking the normal width-to-length ratio as the X-axis, the frequency of the width-to-length ratio division as the Y-axis, and the interval of the width-to-length ratio division as the histogram interval, draw a histogram, marked as the width-to-length ratio histogram;

[0055] Obtain the sum of the frequencies of all width-to-length ratio divisions, marked as Lck;

[0056] Calculate the threshold of the abnormal width-to-length ratio frequency as: Py = u * Lck / a2; where Py is the threshold of the abnormal width-to-length ratio frequency and u is the abnormal occupancy ratio;

[0057] Mark the frequency of the width-to-length ratio division less than or equal to the threshold of the abnormal width-to-length ratio frequency as the abnormal width-to-length ratio frequency;

[0058] Judge whether the frequency of the width-to-length ratio division in the rightmost width-to-length ratio division interval of the width-to-length ratio histogram is the abnormal width-to-length ratio frequency. If so, delete the rightmost width-to-length ratio division interval and the corresponding frequency of the width-to-length ratio division in the width-to-length ratio histogram, and then repeat the above operation until it is not; mark the width-to-length ratio histogram after stopping as the filtered width-to-length ratio histogram;

[0059] Obtain the maximum value of the abscissa of the width-to-length ratio division interval in the filtered width-to-length ratio histogram, marked as the width-to-length ratio threshold.

[0060] Furthermore, generating crack signals and duck egg surface crack characteristics based on the width-to-length ratio threshold, circularity threshold, width-to-length ratio value, and circularity value includes the following sub-steps:

[0061] If the width-to-length ratio value is less than the width-to-length ratio threshold and the circularity value is less than the circularity threshold, mark the initial abnormal area as the crack area;

[0062] If the width-to-length ratio value is greater than or equal to the width-to-length ratio threshold or the circularity value is greater than or equal to the circularity threshold, determine that the initial abnormal area is marked as the spot area;

[0063] If the finally obtained area is the crack area, emit a crack signal and output the crack area as the duck egg surface crack characteristic.

[0064] Advantages of the present invention: The present invention obtains the width-to-length ratio value and circularity value of the binary image of the duck egg through the duck frame selection method and circularity value acquisition method respectively, obtains the width-to-length ratio threshold and circularity threshold through the threshold acquisition method, and generates crack signals and duck egg surface crack characteristics based on the width-to-length ratio threshold, circularity threshold, width-to-length ratio value, and circularity value. The advantage is that it can distinguish the image features of light spots and cracks, improve the accuracy of identifying cracks;

[0065] The present invention respectively obtains the width-to-length ratio and the circularity value of the binary image of duck eggs through the duck frame selection method and the circularity value acquisition method. The advantage is that although the crack and the light spot have similar colors after passing through light, their image shapes are different. For example, the light spot is close to a circle, while the crack is in a long shape. Therefore, the width-to-length ratio and the circularity value are set to comprehensively judge and distinguish the crack and the light spot, improving the accuracy of identifying the crack. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 is a flowchart of the steps of the method of the present invention;

[0067] Figure 2 is a schematic diagram of the binary threshold of the present invention;

[0068] Figure 3 is a schematic diagram of the first straight line, the second straight line, the third straight line and the fourth straight line of the present invention;

[0069] Figure 4 is a schematic diagram of the rotation of the first straight line, the second straight line, the third straight line and the fourth straight line of the present invention;

[0070] Figure 5 is a schematic diagram of the framed rectangle of the present invention;

[0071] Figure 6 is a schematic diagram of the width-to-length ratio histogram of the present invention;

[0072] Figure 7 is a schematic diagram of the screened width-to-length ratio histogram of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0073] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0074] Example 1, please refer to Figure 1 As shown, the present application provides an automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition, including the following steps:

[0075] Step S1, obtaining a light-passing image of the breeding duck egg based on an image acquisition device, and marking it as the light-passing image of the duck egg;

[0076] Step S2, performing gray-scale processing on the light-passing image of the duck egg to obtain a gray-scale image of the duck egg; Step S2 further includes the following sub-steps:

[0077] Step S201: Obtain the RGB values of each pixel in the light-transmitting image of the duck egg, and mark them as the duck egg RGB values.

[0078] Step S202: Use the grayscale conversion formula to convert all the duck egg RGB values in the light-transmitting image of the duck egg into grayscale values to obtain the duck egg grayscale image.

[0079] In practical applications, the grayscale conversion formula is Hyd = (R + G + B) / 3, where Hyd is the grayscale value, and R, G, and B are the three channel values of the duck egg RGB values. For example, if R, G, and B of a duck egg RGB value are 139, 128, and 0 respectively, then the grayscale value is Hyd = (139 + 128 + 0) / 3 = 134, and the calculation result is rounded to an integer.

[0080] Step S3: Perform binarization processing on the duck egg grayscale image to obtain the duck egg binarized image. Step S3 also includes the following sub-steps:

[0081] Step S301: Obtain the grayscale value of each pixel in the duck egg grayscale image, and mark it as the duck egg grayscale value.

[0082] Step S302: Divide the grayscale values from 0 to 255 into a1 equal-interval range intervals, and mark them as the divided range intervals.

[0083] Step S303: Count the frequency of the duck egg grayscale values in each divided range interval, and mark it as the divided range frequency.

[0084] Step S304: Draw a histogram with the duck egg grayscale value as the X-axis, the divided range frequency as the Y-axis, and the divided range interval as the histogram interval, and mark it as the duck egg grayscale histogram.

[0085] Step S305: Obtain the divided range interval in the duck egg grayscale histogram where the divided range frequency is greater than the divided range frequencies on both the left and right sides, and mark it as the candidate peak interval; obtain the median of the candidate peak interval, and mark it as the candidate peak median.

[0086] Step S306: Mark the candidate peak interval where the interval between two adjacent candidate peak medians is greater than the adjacent grayscale interval threshold as the selected peak interval, and select three selected peak intervals. The adjacent grayscale interval threshold is set based on the size of a1. If a1 is too large, the peak fluctuation is more obvious. For example, multiple peaks will be generated in the background, so some need to be excluded. Since a1 obtained this time is 8 and the data is small, it can be set to 0, and the peak fluctuation is more obvious. Because the light-transmitting image of the duck egg contains the background, the duck egg part, and the crack and light spot part, and the colors of these three are different, approaching black, light yellow, and bright yellow respectively, and mainly contain these three distributions, so there will be three selected peak intervals.

[0087] Step S307: Sort the three filtered peak intervals in ascending order according to the median values of the candidate peaks, and label them as the first peak interval, the second peak interval, and the third peak interval respectively;

[0088] Step S308: Obtain the division range interval between the second peak interval and the third peak interval, label it as the intermediate preselection interval, and obtain the intermediate preselection interval with the smallest division range frequency and label it as the intermediate final interval;

[0089] Step S309: Obtain the median value of the intermediate final interval and label it as the binarization threshold;

[0090] Step S310: Set the duck egg gray values greater than or equal to the binarization threshold in the duck egg gray scale image to 0, and set the duck egg gray values less than the binarization threshold in the duck egg gray scale image to 255 to obtain the duck egg binarization image;

[0091] In practical applications, please refer to Figure 2 As shown, divide the gray values from 0 to 255 into 8 division range intervals. The first peak interval, the second peak interval, and the third peak interval are 0 to 31, 159 to 191, and 223 to 255 respectively. The binarization threshold is (191 + 223) / 2 = 207. Set the duck egg gray values greater than or equal to 207 in the duck egg gray scale image to 0, and set the duck egg gray values less than 207 in the duck egg gray scale image to 255 to obtain the duck egg binarization image.

[0092] Step S4: Obtain the width-to-length ratio and the circularity value of the duck egg binarization image based on the duck frame selection method and the circularity value acquisition method respectively; Step S4 also includes the following sub-steps:

[0093] Step S401: Obtain the pixel points with a gray value of 0 adjacent to the pixel points with a gray value of 255 in the duck egg binarization image, and label them as boundary pixel points;

[0094] Step S402: Label the pixel point area with a gray value of 0 in the duck egg binarization image as the initial abnormal area;

[0095] Step S403: Use the frame selection method to obtain the frame selection rectangle of each initial abnormal area; Step S403 also includes the following sub-steps:

[0096] Step S40301: Establish a plane rectangular coordinate system and label it as the frame selection coordinate system; Place the duck egg binarization image in the first quadrant of the frame selection coordinate system; When placing the duck egg binarization image, scale the duck egg binarization image so that the actual size of the breeding duck egg is the same as the size of the plane rectangular coordinate system for easy comparison;

[0097] Step S40302: Obtain the coordinates of a pixel point with the minimum abscissa in the initial abnormal area, marked as (Xmin, Y1), and obtain the coordinates of a pixel point with the maximum abscissa in the initial abnormal area, marked as (Xmax, Y2); draw a straight line parallel to the Y-axis through the point (Xmin, Y1), marked as the first straight line; draw a straight line parallel to the Y-axis through the point (Xmax, Y2), marked as the second straight line; obtain the midpoint of the point (Xmin, Y1) and the point (Xmax, Y2), marked as the reference midpoint.

[0098] Step S40303: Rotate the first straight line and the second straight line clockwise n times by ds° with the reference midpoint as the rotation point, and the maximum rotation range is 180°.

[0099] Step S40304: After each rotation of ds°, draw two straight lines perpendicular to the first straight line through the boundary pixel points of the initial abnormal area, respectively marked as the third straight line and the fourth straight line, and at the same time satisfy that the distance between the third straight line and the fourth straight line is the maximum value that can be drawn. The rectangle formed by the first straight line, the second straight line, the third straight line, and the fourth straight line is marked as the initial rectangle. Obtain the length and width of the initial rectangle, and multiply the length and width of the initial rectangle to calculate the area of the initial rectangle.

[0100] Step S40305: When the rotation ends, obtain the initial rectangle with the minimum area, marked as the selected rectangle.

[0101] In practical applications, please refer to Figure 3 、 Figure 4 and Figure 5 As shown, the coordinates of a pixel point with the minimum abscissa in the initial abnormal area are obtained as (1.32, 1.51), and the coordinates of a pixel point with the maximum abscissa in the initial abnormal area are obtained and marked as (2.46, 1.98); draw the first straight line parallel to the Y-axis through the point (1.32, 1.51); draw the second straight line parallel to the Y-axis through the point (2.46, 1.98); obtain the midpoint of the point (1.32, 1.51) and the point (2.46, 1.98) as (1.89, 1.745), then the reference midpoint is (1.89, 1.745). Rotate the first straight line and the second straight line clockwise 6 times by 30° with the reference midpoint as the rotation point. After each rotation of 30°, obtain an initial rectangle, for example Figure 5 as shown;

[0102] Step S404: Obtain the long side and the short side of the selected rectangle, respectively marked as Jc and Jk.

[0103] Step S405: Calculate the width-to-length ratio as: Bck = Jk / Jc; where Bck is the width-to-length ratio. Since cracks are usually slender and light spots are usually close to circular, the width-to-length ratio of cracks is larger and the width-to-length ratio of light spots is smaller.

[0104] Step S406: Obtain the circularity value of each initial abnormal region by using the circularity value obtaining method; Step S406 further includes the following sub-steps:

[0105] Step S40601: Connect the midpoints of all adjacent boundary pixel points of the initial abnormal region to obtain distance line segments, calculate the sum of all distance line segments, and mark it as Lz.

[0106] Step S40602: Obtain the number of pixel points within the initial abnormal region, and mark it as Gs.

[0107] Step S40603: Obtain the area of each pixel point in the selected coordinate system, and mark it as Sd.

[0108] Step S40604: Calculate the circularity value as: Zz = (4 * Π * Sd * Gs) / (Lz 2 ); where Zz is the circularity value; for some cracks with branches, the width-to-length ratio of the cracks may be close to that of the light spots, reducing the discrimination accuracy of the model. Therefore, it is necessary to determine whether the initial abnormal region is close to a circle. Therefore, according to the circularity value, in the circularity calculation formula, Sd * Gs represents the area of the initial abnormal region, and Lz represents the perimeter of the initial abnormal region. If the initial abnormal region is a circle, the circularity value is 1. The closer it is to a circle, the closer the circularity value is to 1. Therefore, the circularity value can be used to determine whether it is close to a circle, and then determine whether it is a spot or a crack.

[0109] In practical applications, please refer to Figure 5 As shown, the long side and the short side of the selected rectangle are 1.17 cm and 0.15 cm respectively. Keep two decimal places for the long side and the short side of the selected rectangle. Calculate the width-to-length ratio as: Bck = 0.15 / 1.17 = 0.13. Keep two decimal places for the calculation result. Connect the midpoints of all adjacent boundary pixel points of the initial abnormal region to obtain distance line segments, and the sum of all distance line segments is 2.98 cm. Obtain the number of pixel points within the initial abnormal region as 2304. Obtain the area of each pixel point in the selected coordinate system as 3 * 10 -5 cm 2 , and calculate the circularity value as: Zz = (4 * Π * 2304 * 3 * 10 -5 ) / (2.98 2 ) = 0.10. Keep two decimal places for the calculation result.

[0110] Step S5: Obtain the width-to-length ratio threshold and the circularity threshold by using the threshold obtaining method; Step S5 further includes the following sub-steps:

[0111] Step S501: Obtain the first quantity of spot light transmission images containing only normal breeding duck eggs, and mark it as the normal spot image.

[0112] Step S502: Obtain the width-to-length ratio of each normal speckle pattern, and mark it as the normal width-to-length ratio;

[0113] Step S503: Obtain the circularity value of each normal speckle pattern, and mark it as the normal circularity value;

[0114] Step S504: Use the threshold acquisition method to obtain the width-to-length ratio threshold of the normal width-to-length ratio; Step S504 also includes the following sub-steps:

[0115] Step S50401: The threshold acquisition method for obtaining the width-to-length ratio threshold includes: obtaining the range of the normal width-to-length ratio, dividing the range of the normal width-to-length ratio into a2 equal-interval range intervals, and marking them as width-to-length ratio division intervals;

[0116] Step S50402: Count the frequency of each width-to-length ratio division interval, and mark it as the width-to-length ratio division frequency;

[0117] Step S50403: Draw a histogram with the normal width-to-length ratio as the X-axis, the width-to-length ratio division frequency as the Y-axis, and the width-to-length ratio division interval as the histogram interval, and mark it as the width-to-length ratio histogram;

[0118] Step S50404: Obtain the sum of all width-to-length ratio division frequencies, and mark it as Lck;

[0119] Step S50405: Calculate the abnormal width-to-length ratio frequency threshold as: Py = u * Lck / a2; where Py is the abnormal width-to-length ratio frequency threshold and u is the abnormal occupancy ratio; the abnormal width-to-length ratio frequency threshold is used to screen out data with a relatively small frequency of occurrence. For example, if the abnormal occupancy ratio is set to 1%, defects less than 1% are usually ignored during data analysis. In the high-precision field, defects with a defect rate less than 0.1% are usually ignored. Since there are many noise points in image processing, it is not advisable to set it too small. For example, the abnormal occupancy ratio is set to 1%;

[0120] Step S50406: Mark the width-to-length ratio division frequencies less than or equal to the abnormal width-to-length ratio frequency threshold as abnormal width-to-length ratio frequencies;

[0121] Step S50407: Determine whether the width-to-length ratio division frequency in the rightmost width-to-length ratio division interval of the width-to-length ratio histogram is an abnormal width-to-length ratio frequency. If so, delete the rightmost width-to-length ratio division interval and the corresponding width-to-length ratio division frequency in the width-to-length ratio histogram, and then repeat the above operation until it is not; Mark the width-to-length ratio histogram after stopping as the screened width-to-length ratio histogram;

[0122] Step S50408: Obtain the maximum value of the abscissa of the width-to-length ratio division interval in the screened width-to-length ratio histogram, and mark it as the width-to-length ratio threshold;

[0123] In practical applications, please refer to Figure 6 and Figure 7 As shown, obtain the normal width-to-length ratio range of 0.5 to 1.0, divide the normal width-to-length ratio range into 5 equal-interval range intervals, obtain the total sum of 180 for the frequency of all width-to-length ratio divisions, calculate the abnormal width-to-length ratio frequency threshold as: Py = 1% * 180 / 5 = 3.6, mark the width-to-length ratio division frequency less than or equal to 3.6 as the abnormal width-to-length ratio frequency. For example, if the frequency of the width-to-length ratio division interval from 0.5 to 0.6 is 2, then 2 is the abnormal width-to-length ratio frequency. Obtain the maximum value 0.60 of the abscissa of the width-to-length ratio division interval in the filtered width-to-length ratio histogram, that is, the width-to-length ratio threshold 0.60;

[0124] Step S505, use the threshold acquisition method to obtain the circularity threshold of the normal class; Step S505 further includes the following sub-steps:

[0125] Step S50501, the threshold acquisition method for obtaining the circularity threshold includes: obtain the normal circularity value range, divide the normal wide circularity range into a2 equal-interval range intervals, and mark them as circularity division intervals;

[0126] Step S50502, count the frequency of each circularity division interval and mark it as the circularity division frequency;

[0127] Step S50503, draw a histogram with the normal circularity value as the X-axis, the circularity division frequency as the Y-axis, and the circularity division interval as the histogram interval, and mark it as the circularity ratio histogram;

[0128] Step S50504, obtain the total sum of all circularity division frequencies and mark it as Lly;

[0129] Step S50505, calculate the abnormal circularity frequency threshold as: Plz = u * Lly / a2; where Plz is the abnormal circularity frequency threshold and u is the abnormal occupancy ratio;

[0130] Step S50506, mark the circularity division frequency less than or equal to the abnormal circularity frequency threshold as the abnormal circularity frequency;

[0131] Step S50507, determine whether the circularity division frequency of the rightmost circularity division interval in the circularity histogram is the abnormal circularity frequency. If so, delete the rightmost circularity ratio division interval and the corresponding circularity division frequency in the circularity histogram, and then repeat the above operation until it is not; mark the circularity histogram after stopping as the filtered circularity histogram;

[0132] Step S50508, obtain the maximum value of the abscissa of the circularity division interval in the filtered circularity histogram and mark it as the circularity threshold;

[0133] In practical applications, for example, the circularity threshold obtained by the aspect ratio threshold acquisition method is 0.72.

[0134] Step S6, generate a crack signal and the surface crack characteristics of the duck egg based on the aspect ratio threshold, the circularity threshold, the aspect ratio value, and the circularity value; Step S6 further includes the following sub-steps:

[0135] Step S601, if the aspect ratio value is less than the aspect ratio threshold and the circularity value is less than the circularity threshold, mark the initial abnormal area as a crack area;

[0136] Step S602, if the aspect ratio value is greater than or equal to the aspect ratio threshold or the circularity value is greater than or equal to the circularity threshold, determine that the initial abnormal area is marked as a spot area;

[0137] Step S603, if the crack area is finally obtained, send out a crack signal and output the crack area as the surface crack characteristics of the duck egg;

[0138] In practical applications, the aspect ratio threshold, the circularity threshold, the aspect ratio value, and the circularity value are 0.60, 0.72, 0.13, and 0.10 respectively. If 0.10 is less than 0.60 and 0.10 is less than 0.72, mark the initial abnormal area as a crack area, send out a crack signal, and output the crack area as the surface crack characteristics of the duck egg; because cracks are usually slender, while light spots are close to circular, so the aspect ratio value of cracks is larger, and the aspect ratio value of light spots is smaller. The closer to circular, the closer the circularity value is to 1. Therefore, the circularity value can be used to judge whether it is close to circular. When the circularity value is small, it is a crack. Therefore, the aspect ratio value and the circularity value can be combined to judge whether it is a crack or a light spot.

[0139] Embodiment 2, the present application also provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, the steps in the automatic extraction method for the surface crack characteristics of breeding duck eggs based on image recognition are run to achieve the following functions: obtain the light transmission image of the breeding duck egg based on the image acquisition device and mark it as the duck egg light transmission image; perform grayscale processing on the duck egg light transmission image to obtain the duck egg grayscale image; perform binarization processing on the duck egg grayscale image to obtain the duck egg binarized image; respectively obtain the aspect ratio value and the circularity value of the duck egg binarized image based on the duck frame selection method and the circularity value acquisition method; use the threshold acquisition method to obtain the aspect ratio threshold and the circularity threshold; generate a crack signal and the surface crack characteristics of the duck egg based on the aspect ratio threshold, the circularity threshold, the aspect ratio value, and the circularity value.

[0140] In addition, when the logical instructions in the above-mentioned memory are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0141] Embodiment 3. This application also provides a computer program product. The computer program product includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the automatic extraction method for surface crack features of breeding duck eggs based on image recognition provided by the above-mentioned various methods. The method includes: obtaining a light-transmitting image of a breeding duck egg through an image acquisition device and marking it as a duck egg light-transmitting image; performing grayscale processing on the duck egg light-transmitting image to obtain a duck egg grayscale image; performing binarization processing on the duck egg grayscale image to obtain a duck egg binarized image; respectively obtaining the width-to-length ratio and the circularity value of the duck egg binarized image based on the duck frame selection method and the circularity value acquisition method; using the threshold acquisition method to obtain the width-to-length ratio threshold and the circularity threshold; generating a crack signal and the surface crack features of the duck egg based on the width-to-length ratio threshold, the circularity threshold, the width-to-length ratio value, and the circularity value.

[0142] Embodiment 4. This application also provides a computer-readable storage medium. This application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, it runs the steps in the automatic extraction method for surface crack features of breeding duck eggs based on image recognition as described above to achieve the following functions: obtaining a light-transmitting image of a breeding duck egg through an image acquisition device and marking it as a duck egg light-transmitting image; performing grayscale processing on the duck egg light-transmitting image to obtain a duck egg grayscale image; performing binarization processing on the duck egg grayscale image to obtain a duck egg binarized image; respectively obtaining the width-to-length ratio and the circularity value of the duck egg binarized image based on the duck frame selection method and the circularity value acquisition method; using the threshold acquisition method to obtain the width-to-length ratio threshold and the circularity threshold; generating a crack signal and the surface crack features of the duck egg based on the width-to-length ratio threshold, the circularity threshold, the width-to-length ratio value, and the circularity value.

[0143] Through the description of the above embodiments, the embodiments of the present invention can be provided as a method, a system or a computer program product. Based on such an understanding, the above technical solution, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0144] In the embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. The above-described embodiments are merely illustrative. For example, the division of modules or units is only a logical function division, and there can be other division methods in actual implementation. For another example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of systems, modules and units can be electrical, mechanical or other forms.

[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An automatic extraction method for surface crack features of breeding duck eggs based on image recognition, characterized in that, The steps are as follows: Based on an image acquisition device, obtain a light-transmitting image of a breeding duck egg, marked as the duck egg light-transmitting image; Perform grayscale processing on the duck egg light-transmitting image to obtain a duck egg grayscale image; Perform binarization processing on the duck egg grayscale image to obtain a duck egg binarized image; Based on the box selection method and the circularity value acquisition method, respectively obtain the width-to-length ratio and the circularity value of the duck egg binarized image; Use the threshold acquisition method to obtain the width-to-length ratio threshold and the circularity threshold; Generate a crack signal and the surface crack characteristics of the duck egg based on the width-to-length ratio threshold, the circularity threshold, the width-to-length ratio, and the circularity value; Among them, respectively obtaining the width-to-length ratio and the circularity value of the duck egg binarized image based on the box selection method and the circularity value acquisition method includes the following sub-steps: Obtain the pixel points with a grayscale value of 0 adjacent to the pixel points with a grayscale value of 255 in the duck egg binarized image, marked as boundary pixel points; Mark the pixel point area with a grayscale value of 0 in the duck egg binarized image as the initial abnormal area; Use the box selection method to obtain the box selection rectangle of each initial abnormal area; Obtain the long side and the short side of the box selection rectangle, marked as Jc and Jk respectively; Calculate the width-to-length ratio as: Bck = Jk / Jc; where Bck is the width-to-length ratio; Use the circularity value acquisition method to obtain the circularity value of each initial abnormal area; Among them, the box selection method includes: Establish a plane rectangular coordinate system, marked as the box selection coordinate system; place the duck egg binarized image in the first quadrant of the box selection coordinate system; Obtain the coordinates of a pixel point with the smallest abscissa in the initial abnormal area, marked as (Xmin, Y1), and obtain the coordinates of a pixel point with the largest abscissa in the initial abnormal area, marked as (Xmax, Y2); draw a straight line parallel to the Y-axis through the point (Xmin, Y1), marked as the first straight line; draw a straight line parallel to the Y-axis through the point (Xmax, Y2), marked as the second straight line; obtain the midpoint of the point (Xmin, Y1) and the point (Xmax, Y2), marked as the reference midpoint; Rotate the first straight line and the second straight line clockwise n times by ds° with the reference midpoint as the rotation point, and the maximum rotation range is 180°; After each rotation of ds°, draw two straight lines perpendicular to the first straight line through the boundary pixel points of the initial abnormal area, marked as the third straight line and the fourth straight line respectively, and at the same time satisfy that the distance between the third straight line and the fourth straight line is the maximum value that can be drawn. The rectangle formed by the first straight line, the second straight line, the third straight line, and the fourth straight line is marked as the initial rectangle. Obtain the length and width of the initial rectangle, and multiply the length and width of the initial rectangle to calculate the area of the initial rectangle; When the rotation ends, obtain the initial rectangle with the smallest area, marked as the box selection rectangle; Among them, the circularity value acquisition method includes: Connect the midpoints of all adjacent boundary pixel points in the initial abnormal area to obtain distance line segments, and obtain the sum of all distance line segments, marked as Lz; Obtain the number of pixel points in the initial abnormal area, marked as Gs; Obtain the area of each pixel point in the box selection coordinate system, marked as Sd; The value of the quasi-circular shape is calculated as: Zz = (4 * Π * Sd * Gs) / (Lz 2 ); where Zz is the value of the quasi-circular shape.

2. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 1, characterized in that Performing grayscale processing on the duck egg light-transmitting image to obtain a duck egg grayscale image includes the following sub-steps: Obtain the RGB value of each pixel point in the duck egg light-transmitting image, marked as the duck egg RGB value; Use the grayscale conversion formula to convert the RGB values of all duck eggs in the duck egg translucent image into grayscale values to obtain the duck egg grayscale image.

3. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 2, wherein The binarization process of the duck egg grayscale image to obtain the duck egg binarized image includes the following sub-steps: Obtain the grayscale value of each pixel point in the duck egg grayscale image, marked as the duck egg grayscale value; Divide the grayscale values from 0 to 255 into a1 equal-interval range intervals, marked as the divided range intervals; Count the frequency of the duck egg grayscale values in each divided range interval, marked as the divided range frequency; Taking the duck egg grayscale value as the X-axis, the divided range frequency as the Y-axis, and the divided range interval as the histogram interval, draw a histogram, marked as the duck egg grayscale histogram.

4. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 3, characterized in that, The binarization process of the duck egg grayscale image to obtain the duck egg binarized image also includes the following sub-steps: Obtain the divided range interval in the duck egg grayscale histogram where the divided range frequency is greater than the divided range frequencies on both the left and right sides, marked as the candidate peak interval; obtain the median of the candidate peak interval, marked as the candidate peak median; Mark the candidate peak interval where the interval between two adjacent candidate peak medians is greater than the adjacent grayscale interval threshold as the screened peak interval, and select three screened peak intervals; Sort the three screened peak intervals in ascending order according to the candidate peak median, and mark them as the first peak interval, the second peak interval, and the third peak interval respectively; Obtain the divided range interval between the second peak interval and the third peak interval, marked as the intermediate preselection interval, and obtain the intermediate preselection interval with the smallest divided range frequency, marked as the intermediate final interval; Obtain the median of the intermediate final interval, marked as the binarization threshold; Set the duck egg grayscale values in the duck egg grayscale image greater than or equal to the binarization threshold to 0, and set the duck egg grayscale values in the duck egg grayscale image less than the binarization threshold to 255 to obtain the duck egg binarized image.

5. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 4, characterized in that, The method for obtaining the aspect ratio threshold and the circularity threshold using the threshold includes the following sub-steps: Obtain the first number of spot translucent images containing only normal duck eggs, marked as the normal spot images; Obtain the aspect ratio value of each normal spot image, marked as the normal aspect ratio value; Obtain the circularity value of each normal spot image, marked as the normal circularity value; Use the threshold obtaining method to obtain the aspect ratio threshold of the normal aspect ratio value; Use the threshold obtaining method to obtain the circularity threshold of the normal circularity value.

6. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 5, wherein The threshold obtaining method includes: Obtain the normal aspect ratio range, divide the normal aspect ratio range into a2 equal-interval range intervals, marked as the aspect ratio divided intervals; Count the frequency of each aspect ratio divided interval, marked as the aspect ratio divided frequency; Taking the normal aspect ratio value as the X-axis, the aspect ratio divided frequency as the Y-axis, and the aspect ratio divided interval as the histogram interval, draw a histogram, marked as the aspect ratio histogram; Obtain the sum of all aspect ratio divided frequencies, marked as Lck; Calculate the abnormal aspect ratio frequency threshold as: Py = u * Lck / a2; where Py is the abnormal aspect ratio frequency threshold and u is the abnormal occupancy ratio; Mark the aspect ratio divided frequency less than or equal to the abnormal aspect ratio frequency threshold as the abnormal aspect ratio frequency; Determine whether the width-to-length ratio division frequency in the rightmost width-to-length ratio division interval of the width-to-length ratio histogram is an abnormal width-to-length ratio frequency. If so, delete the rightmost width-to-length ratio division interval and the corresponding width-to-length ratio division frequency in the width-to-length ratio histogram, and then repeat the above operation until it is not. Mark the width-to-length ratio histogram after stopping as the screened width-to-length ratio histogram; Obtain the maximum value of the abscissa of the width-to-length ratio division interval in the screened width-to-length ratio histogram, and mark it as the width-to-length ratio threshold.

7. The automatic extraction method for surface crack characteristics of breeding duck eggs based on image recognition according to claim 6, characterized in that, Generating crack signals and duck egg surface crack characteristics based on the width-to-length ratio threshold, circularity threshold, width-to-length ratio value, and circularity value includes the following sub-steps: If the width-to-length ratio value is less than the width-to-length ratio threshold and the circularity value is less than the circularity threshold, mark the initial abnormal area as a crack area; If the width-to-length ratio value is greater than or equal to the width-to-length ratio threshold or the circularity value is greater than or equal to the circularity threshold, determine that the initial abnormal area is marked as a spot area; If the finally obtained area is a crack area, send out a crack signal and output the crack area as the duck egg surface crack characteristic.

Citation Information

Patent Citations

  • Duck egg surface crack detection method and system based on image analysis

    CN119359731A

  • A visual detection method for fine cracks on the surface of an egg shell

    CN108986055A

  • A nondestructive testing and automatic grading method for poultry egg surface cracks

    CN109685786A