A Precision Microsphere Diameter Detection Method Based on Hybrid Geometric Features
By employing a hybrid geometric feature detection method and combining multiple algorithms to calculate the precision microsphere diameter, the problems of long detection time, low accuracy, and easy damage in existing technologies have been solved, achieving high-precision, fast, and non-destructive microsphere diameter detection.
Patent Information
- Application Number
- CN202510320566.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-03-18
AI Technical Summary
Existing technologies for detecting the diameter of precision microspheres suffer from problems such as long processing time, low accuracy, and easy damage to the microspheres, especially for precision microspheres with a diameter of less than 0.9 mm.
A detection method based on hybrid geometric features is adopted, including image processing, diameter calculation, and averaging of multiple measurements. The method combines least squares circle fitting, minimum bounding rectangle algorithm, and maximum inscribed circle method with sparrow optimization algorithm. Through edge detection and morphological processing, it automatically adapts to different microsphere postures and calculates the diameter of precision microspheres.
It improves detection accuracy and reliability, reduces errors in the image acquisition process, avoids damage to microspheres, and shortens the detection time to 1-2 minutes.
Smart Images

Figure CN119863505B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of precision microsphere diameter detection technology, and specifically to a precision microsphere diameter detection method based on hybrid geometric features. Background Technology
[0002] Precision microspheres are core components in high-precision mechanical parts, widely used in aerospace and precision machine tools. The dimensional accuracy of these microspheres not only affects their fit within products but also directly impacts the precision of mechanical assembly, product lifespan, and system stability. In the production of high-precision mechanical parts, the ability to quickly and accurately detect the dimensions of precision microspheres has become a crucial factor limiting improvements in processing technology and production efficiency.
[0003] After processing, precision microspheres need to be measured. Due to their small size and light weight, conventional contact measurements, such as AFM and micrometers, are time-consuming and can easily damage the surface of the microspheres. Damaged microspheres cannot be used in subsequent processes.
[0004] Regarding methods for measuring the diameter of a circle, Chinese invention patent application CN202011230587.7 discloses an automatic device and method for measuring the diameter of a solder ball. A solder ball is placed on the upper surface of an optical glass, a telecentric parallel light source is positioned at the lower part of the optical glass, and an industrial camera with a telecentric lens is positioned directly above the optical glass. During measurement, the solder ball is placed on the optical glass; the telecentric lens acquires image information of the solder ball; the industrial camera transmits the image information to a computer; based on the obtained projected images of the solder balls, the diameter of each solder ball is determined by measuring the total number of pixels in the projected image, and an average value is calculated. However, this method suffers from limitations in accuracy. When the surface of the solder ball has minor defects or irregular shapes, the projected image cannot accurately reflect the actual diameter of the sphere, thus affecting the measurement accuracy.
[0005] Chinese invention patent application CN201810539768.4 provides a method for measuring the diameter of microspheres based on Photoshop software, including the following steps: a. Taking microsphere photographs: The microspheres to be measured are evenly dispersed and then magnified and photographed under a microscope equipped with a mesh eyepiece ruler to obtain microsphere photographs; b. Counting microspheres: The microsphere photographs are opened using Photoshop software, and the number of microspheres in the photographs is marked in counting mode; c. Setting the measurement scale: The pixel length per unit length of the mesh eyepiece ruler in the microsphere photographs is measured in Photoshop software; the pixel length value is entered into the blank space of "Pixel Length" under the "Set Measurement Scale" item in Photoshop software; the unit length value is entered into the blank space of "Logical Length" under the "Set Measurement Scale" item in Photoshop software; then Photoshop software automatically calculates the measurement scale; d. Measurement: After setting the measurement scale, the diameter of the microspheres with the marked number of microspheres is measured in Photoshop software. This invention has the characteristics of fast and simple measurement method, low equipment requirements, and accurate measurement. This patent utilizes Photoshop software for microsphere measurement. While it enables batch testing, the manual marking of microspheres, inputting measurement ratios, and sequentially measuring the diameter of each microsphere is cumbersome and error-prone, thus limiting measurement accuracy. Furthermore, the invention relies on manual operations such as mouse dragging for diameter measurement, which introduces human error and further restricts accuracy. Additionally, Photoshop is an image editing software, not a professional metrology tool, lacking sufficient sub-pixel precision support and failing to consider image distortion and correction. Therefore, for the precision microsphere diameter detection required in this invention, this method cannot obtain accurate diameter data. Summary of the Invention
[0006] The purpose of this invention is to provide a precision microsphere diameter detection method based on hybrid geometric features, in order to solve the problems mentioned in the background art of using existing methods to detect the size of precision microspheres with small diameters (e.g., within 0.9 mm), which are time-consuming, have low accuracy, and are prone to damaging the precision microspheres.
[0007] To achieve the above objectives, this invention provides a method for detecting the diameter of a precision microsphere based on hybrid geometric features. The method includes the following steps: 1) Image processing: specifically, acquiring a color microscopic image of the precision microsphere, converting it into a grayscale image, using the maximum inter-class variance method to perform threshold segmentation on the grayscale image to obtain a binary image, performing morphological processing for the first time to extract scale region features and locate the scale, performing pixel calibration on the scale size, performing morphological processing again, and inverting the image to obtain a target feature image with the background removed; 2) Diameter calculation: calculating the diameter of the circle using three methods: least squares circle fitting, minimum bounding rectangle algorithm, and maximum inscribed circle method, and taking the average of the diameters calculated by these three methods as the diameter of the precision microsphere; 3) Unit conversion: converting the diameter of the precision microsphere in step 2) from pixels to actual length units to obtain the true diameter of the precision microsphere; 4) Taking the average of multiple measurements: measuring the precision microsphere three or more times in different directions, and finally taking the average value as the final value of the precision microsphere diameter detection.
[0008] In this invention, the conversion unit in step 3) includes converting the diameter of the precision microsphere, which is measured in pixels, to actual length units such as mm or μm.
[0009] In one specific implementation, in step 1), the first morphological processing includes pixel filtering and hole filling, and the second morphological processing includes pixel filtering; in step 3), the true precision microsphere diameter is obtained by using the scale calibration parameters obtained by pixel calibration of the scale size in step 1).
[0010] In one specific implementation, step 2) specifically includes: after image localization of the target feature image described in step 1), calculating the diameter of the circle using steps 2a, 2b, and 2c respectively, and then taking the average value as the diameter of the precision microsphere; 2a, calculating the diameter of the circle using least squares circle fitting; specifically, first performing edge detection using the Canny edge detection operator, i.e., edge extraction, then fitting the circle equation according to the least squares method, and then calculating the diameter of the circle; 2b, calculating the diameter of the circle using the minimum bounding rectangle algorithm; specifically, using the center of the minimum bounding rectangle as the center of the circle, and using the average vertical distance from the center of the circle to different side lengths of the rectangle as the radius to calculate the diameter of the circle; 2c, calculating the diameter of the circle using the maximum inscribed circle method; specifically, by traversing all coordinates of the contour, using the sparrow optimization algorithm to find the diameter of the maximum inscribed circle.
[0011] In one specific implementation, in step 2), for calculating the diameter of the circle using least squares circle fitting, the edge detection uses the Canny edge detection algorithm. This involves Gaussian smoothing and denoising the image, calculating the partial derivative of the smoothed image, performing non-maximum suppression, and then performing double threshold detection and edge connection. The algorithm uses a Gaussian convolution kernel mask to perform convolution calculations on the image, and the formula can be expressed as:
[0012]
[0013] in, G(i, j, δ) This represents the Gaussian smoothing filter function. δ Let be the variance of the Gaussian filter function. f(i, j) The grayscale value is the value in the image, and ⊗ represents the convolution operator. s(i, j) For the smoothed image, i and j These represent the row and column pixel coordinates of the image, respectively.
[0014] Using first-order finite difference along the vertical and horizontal directions, calculate the gradient magnitude and direction of the pixel, where the gradient magnitude is |▽ f(x, y) | represents the rate of change of the image at that point, where ▽ is the partial derivative with respect to the vector. x and y Representing the rectangular coordinate system x shaft and y Axial direction, f(x, y) The grayscale value in the image, ▽ x f For the function f of x Taking the partial derivative of the direction, ▽ y f For the function f of y Take the partial derivative of the direction; gradient direction θ The direction of the edge is indicated; the gradient magnitude and gradient direction are represented as follows:
[0015]
[0016] The least squares method is an optimization technique that optimizes the fitting parameters by minimizing the sum of squared errors. It obtains the coordinates of several points on the edge through edge fitting, and then uses the least squares method to solve for the equation of the edge circle. Let the center of the circle be... O for (a, b) , radius is r Given a set of edge points (x k ,y k ), k=1,2,3,…,m ,in, k For a certain edge point,m The total number of edge points; edge points k The x-coordinate is x k The vertical axis is y k ;
[0017] According to the general equation of a circle:
[0018]
[0019] The error function is obtained as follows:
[0020]
[0021] make A = -2a, B = -2b, C = a 2 +b 2 -r 2 ;
[0022] The objective function can be simplified to:
[0023]
[0024] parameter A, B, C satisfy Loss To obtain the minimum value, therefore, for the parameters respectively A, B, C Find the partial derivative:
[0025]
[0026] It can be obtained FA , GA , HA , IA , JA ,in FA , GA , HA , IA , JA This represents the definition of the right-hand side of the equations in formulas 11 to 15:
[0027]
[0028] We can further obtain:
[0029]
[0030] The coordinates of the center and radius of the fitted circle are as follows:
[0031]
[0032] The diameter of the circle fitted by the least squares method is:
[0033] .
[0034] In one specific implementation, step 2) of calculating the diameter of the circle using the minimum bounding rectangle algorithm includes: locating the center of the precision microsphere using the minimum bounding rectangle algorithm, and calculating the perpendicular distance from the center to different sides of the rectangle; the minimum bounding rectangle calculation includes determining the convex shell boundary value according to the convex shell boundary rotation algorithm, rotating the convex shell boundary, and calculating the minimum bounding rectangle.
[0035] convex shell boundary X Maximum value in the axial direction and Y The minimum value along the axis is used as the initial minimum bounding rectangle for boundary rotation, and the area of the initial minimum bounding rectangle, as well as the maximum and minimum coordinates on the boundary, are recorded; the relative position of each boundary line segment on the convex hull boundary is determined. X Angle in direction α i Rotate each boundary segment on the convex hull boundary counterclockwise and calculate the relative rotation of each boundary segment. X The angle between directions, i.e., the rotation angle. θ i The calculation formula is:
[0036]
[0037] in, θ i The first convex shell boundary i The rotation angle of a line segment, x i ,y i The first and second parts of the convex shell boundary are respectively i The x and y coordinates of the point x i+1 ,y i+1 The first and second parts of the convex shell boundary are respectively i+1 The x and y coordinates of the point; the boundary of the convex hull according to the rotation angle θ 1 θ 2 θ 3 、…、 θ i The points are rotated sequentially around the origin in a clockwise direction. The rotation transformation formula for points in the same coordinate system is derived as follows:
[0038]
[0039] in, x i’ 、yi’ The first on the boundary of the convex shell i The x and y coordinates of each point after rotation Represents the radius in polar coordinates; T This is the symbol for the transpose matrix;
[0040] The rotated convex shell boundary X Maximum value in the axial direction and Y The minimum value along the axis is used as the bounding rectangle after boundary rotation. The area of the rotated bounding rectangle is calculated and compared with the area of the initial minimum bounding rectangle. The coordinates of the four vertices and the rotation angle of the bounding rectangle with the minimum area are retained, and the bounding rectangle with the minimum area is displayed in the image. Then, the convex hull boundary with the bounding rectangle is rotated back by the same rotation angle. The formula for the reverse coordinates is:
[0041]
[0042] in, x i’’ 、y i’’ The first on the boundary of the convex shell i The x and y coordinates of each point after inverse rotation;
[0043] The convex shell boundary rotates at an angle θ 1 θ 2 θ 3 、…、θ i The rotation is repeated in sequence. If the area of the resulting bounding rectangle is smaller than the area of the previous bounding rectangle, the area, coordinates of its four vertices, and the rotation angle are retained until all boundaries are rotated. The rectangle with the smallest area is the minimum bounding rectangle, and its four vertices are connected sequentially. The coordinates of the four vertices are... A 1 (x 1 ,y 1 )、B 1 (x 2 ,y 2 )、C 1 (x 3 ,y 3 )、D 1 (x 4 ,y4 ) ;
[0044] The center point of the rectangle is the center of the circle.
[0045]
[0046] Distance from the center of the circle to different sides of the rectangle L 1 and L 2 They are respectively:
[0047]
[0048] in, k 1 It is the slope of side 1 of the smallest circumscribed rectangle. k 2 It is the slope of side 2 of the smallest circumscribed rectangle;
[0049] Therefore, the diameter of the precision microsphere calculated using the minimum circumscribed rectangle method is:
[0050] .
[0051] In one specific implementation, step 2) calculates the diameter of the circle using the maximum inscribed circle method. The circle calculated using this method must simultaneously satisfy the following conditions: all points on the precision microsphere profile are located on or outside the circle, and the circle has a maximum radius. Since some precision microspheres are not perfectly circular at the microscopic level, multiple maximum inscribed circles may exist during the process of solving for the maximum inscribed circle, resulting in no unique solution. For the obtained pixel coordinates of the profile... I(x, y) Image pixel coordinates C(i, j) Calculate the point set C The complete Euclidean distance transformation point set { D ij}, which can be represented as:
[0052]
[0053] In this context, curly braces represent sets; && represents union, which means "and". The union symbol indicates that both the preceding and following conditions must be satisfied. C It is a set of image pixel coordinates. i and j It is a set C The x and y coordinates of the points in the middle; W Refers to the precision microsphere profile point set (x, y) , x and y It is a set W The x and y coordinates of the points in the middle;
[0054] Based on the property of the largest inscribed circle, the center of the largest inscribed circle lies within the region enclosed by the precision microsphere profile, and the minimum distance from the center to all points on the profile reaches a maximum. The point set { is then calculated.} Dij The maximum value in { is used to determine the radius of the largest inscribed circle} d n The formula is:
[0055]
[0056] in,{ Dij There may be multiple identical maxima in the}, but the pixel coordinates corresponding to the maxima are not the same. To reduce computation time, the one closest to the contour is selected. d 1 Centered on the starting coordinates O(a, b) To prevent incomplete cleaning of the precision microsphere surface, which could result in a small number of impurity points at the edges of the acquired images, and because these impurities cannot be directly processed using morphological methods, the general method for calculating the maximum inscribed circle has certain limitations and requires further improvement in its calculation accuracy. This study optimizes the algorithm using a sparrow algorithm to find the most suitable circle for the precision microsphere profile, while simultaneously overcoming the problem of non-circular features in the microsphere profile. O(a, b) Establish a ring-shaped region centered at a point with an inner radius of | d |, outer radius is| d |+ δ ,in, δ It's an empirical value. By adjusting the thickness of the ring, to ensure that the ring fully covers the contour, generally to ensure that the ring and the contour height coincide, δ The value is taken from 1.2 to 1.8; within the annular region, contour points are selected as candidate data points, and the set of contour points is denoted as { P i}, all contour points within this annular region P i These are the candidate data points { Q i};
[0057] The process of optimizing the search using the sparrow algorithm involves finding the optimal candidate data points. Each individual sparrow represents a set of candidate points, and the position of each sparrow is updated based on its fitness function. Fitness It can be represented as:
[0058]
[0059] in, R Indicates the radius of the largest inscribed circle. PThe penalty term represents the degree of deviation between the candidate point set and the circle. The smaller the penalty term, the smaller the deviation of the candidate points from the circle, and the better the circle covers the contour points.
[0060] For each contour point I(x, y) Calculate its distance to the current center of the circle. O(a, b) distance d i :
[0061]
[0062] Calculate contour points I The difference Δd between the distance to the center of the circle and the radius of the largest inscribed circle:
[0063]
[0064] Penalty items P It can be represented as:
[0065]
[0066] in, m This represents the total number of contour points, i.e., the total number of edge points;
[0067] The Sparrow Algorithm searches for the optimal center position and the most suitable set of candidate points by simulating the foraging behavior of a group, based on the candidate points on the contour { Q i}Establish Voronoi picture, Voronoi The graph divides the space into multiple regions, each corresponding to a candidate point. Q i The distance of all points in this area Q i Recently; calculation Voronoi The distance from each vertex to the candidate point Voronoi A vertex is a potential center of a circle; therefore, calculate each Voronoi The maximum distance from a vertex to a candidate point is the radius of the largest inscribed circle. max { VD i}, its corresponding Voronoi The vertex is the center of the largest inscribed circle;
[0068] The diameter of the largest inscribed circle is:
[0069] .
[0070] In this invention, the diameter of the precision microspheres detected at the end of the final step 2) is:
[0071] .
[0072] Compared with the prior art, the present invention has the following beneficial effects:
[0073] 1) The precision microsphere diameter detection method based on hybrid geometric features of this invention utilizes a combination of detection methods based on multiple geometric features, including edge detection and least squares circle fitting, minimum circumscribed rectangle, and maximum inscribed circle. By calculating the diameter of the precision microsphere from different angles, it can effectively reduce errors caused by blurred or unclear edges during image acquisition. Compared with existing single circle fitting methods, this invention can comprehensively utilize different geometric features of the precision microsphere to obtain more accurate microsphere diameter measurement results, improving the reliability and accuracy of detection.
[0074] 2) The precision microsphere diameter detection method based on hybrid geometric features of this invention can automatically adapt to different microsphere postures without requiring image rotation or translation correction. Traditional circle fitting methods often require additional image transformations when dealing with microspheres that are irregularly rotated or asymmetrical, which not only increases computational complexity but may also lead to measurement errors. This invention, by employing hybrid geometric features, can automatically track and calculate the diameter of the microsphere without image correction, exhibiting greater adaptability.
[0075] 3) The precision microsphere diameter detection method based on hybrid geometric features of this invention combines the sparrow optimization algorithm with the maximum inscribed circle method, enabling more accurate processing of microspheres of different sizes and shapes. Traditional methods often exhibit significant errors when processing microspheres with irregular shapes or slight deformations. However, by introducing the optimization algorithm, the optimal solution can be automatically selected when multiple candidate circles exist, and the microsphere diameter can be accurately calculated. This method has good adaptability to microspheres of different sizes and surface features, and can be widely applied to precision microsphere size detection in various fields.
[0076] Compared to existing technologies, the diameter data obtained by a micrometer for measuring precision microspheres can generally be considered the true and accurate diameter data of the microspheres. However, when using a micrometer, the micrometer needs to be pressed against the microsphere, which is prone to improper operation during the measurement process, leading to damage or surface injury to the microspheres. This renders the microspheres unusable in subsequent product applications. Furthermore, measuring each microsphere with a micrometer takes approximately 3-5 minutes, making the inspection time-consuming. AFM measurement is a contact probe measurement method, which is also prone to improper operation during the measurement process, leading to scratches on the surface of the microspheres and rendering them unusable. AFM measurement of each microsphere also takes several hours, making the inspection very time-consuming. In contrast, the method described in this invention provides highly accurate diameter measurement of precision microspheres (its measurement error fully meets requirements), does not require contact measurement, does not cause any damage to the microspheres, and only requires 1-2 minutes to measure each microsphere. Attached Figure Description
[0077] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the accompanying drawings.
[0078] The accompanying drawings are provided to further illustrate the embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention.
[0079] Figure 1 This is a flowchart of a precision microsphere diameter detection method based on hybrid geometric features.
[0080] Figure 2 These are images captured under a precision microsphere microscope used in experiments.
[0081] Figure 3 It is a grayscale image of a precision microsphere.
[0082] Figure 4 It is a binary image of a precision microsphere.
[0083] Figure 5 It is an image extracted from the scale features of a precision microsphere.
[0084] Figure 6 This is the image after removing the precision microsphere scale.
[0085] Figure 7 This is the result image obtained after inverting the image.
[0086] Figure 8 This is the result of precise microsphere circular reconstruction based on the least squares method of edge detection.
[0087] Figure 9This is the result of precise microsphere circle reconstruction based on the minimum bounding rectangle algorithm.
[0088] Figure 10 It is based on the precision microsphere circular reconstruction result of the largest inscribed circle.
[0089] Figure 11 It is a curve comparing the results of measuring different balls with a contact micrometer and the detection results of the algorithm. Detailed Implementation
[0090] The present invention will now be described in detail with reference to the embodiments shown in the accompanying drawings. However, it should be noted that these embodiments are not intended to limit the present invention. Equivalent transformations or substitutions in function, method, or structure made by those skilled in the art based on these embodiments are all within the scope of protection of the present invention.
[0091] This invention performs diameter testing on standard spheres with a diameter of less than 0.9 mm used in the aerospace field. For example, the diameter requirement of the precision microsphere described in this embodiment is 0.85 mm. Before precision machining, the diameter of the microsphere is greater than 0.9 mm. After precision machining, it is necessary to measure whether the diameter of the precision microsphere has met the standard. Therefore, the diameter needs to be tested. If the diameter has not yet met the standard, further precision machining is required.
[0092] Figure 1 A flowchart illustrating a precision microsphere diameter detection method based on hybrid geometric features is presented. The core process of this method includes the following steps: acquiring images of the precision microspheres using a microscope; image preprocessing including grayscale conversion, binarization, morphological processing, and scale region extraction; processing using edge detection algorithms and least squares circle fitting, minimum bounding rectangle algorithm, and maximum inscribed circle algorithm; and optimizing the maximum inscribed circle using a sparrow optimization algorithm to ensure the accuracy of the optimal solution. The edge detection algorithm and the least squares circle fitting steps include first performing edge detection, then using the least squares circle fitting equation, and finally outputting the diameter and center coordinates calculated by this method. In the minimum bounding rectangle algorithm, features are first extracted from the minimum bounding rectangle, then the center is located and the perpendicular distances from the center to different sides of the minimum bounding rectangle are calculated. Then, the average value of different distances is calculated, and the calibration result is output as the circle diameter calculated by this method. In the maximum inscribed circle method, a complete Euclidean distance transformation is first implemented, then the sparrow algorithm is used to optimize the search for the optimal candidate data points, and then the Voronoi distance from each vertex to the candidate point is calculated. The maximum value is taken as the maximum inscribed circle radius.
[0093] Figure 2 As shown, images of precision microspheres were acquired using an optical microscope. The images acquired under the microscope clearly show the outline of the microspheres. To ensure image quality, a high-resolution camera and a telecentric lens were used in the experiment to avoid image distortion and aberration.
[0094] Figures 2-4 and Figures 8-10 All 100μm values are scale bars.
[0095] Figure 3 This is a grayscale image of precision microspheres, designed to convert color images to grayscale, simplifying subsequent processing. The edge information of the microspheres is more clearly visible in the image.
[0096] Figure 4 It is a binary image of a precision microsphere. The grayscale image is binarized by adaptively calculating the threshold using the maximum inter-class variance method.
[0097] Figure 5 This paper demonstrates the process of extracting scale features from a precision microsphere image. The scale region is extracted from the image, and the size calibration can be converted to the actual microsphere diameter. This figure corresponds to the step 1) of "initially performing morphological processing to extract scale region features and locate the scale." In this invention, the initial morphological processing includes pixel filtering and hole filling, specifically, for example... Figures 4 to 5 The image shows the filtering out of the low-resolution "100μm" text and the filling of the hole in the center of the sphere. Figure 5 The 100μm text has been "pixel filtered out," leaving only the horizontal line that originally corresponded to the 100μm text.
[0098] Figure 6 As shown, after extracting the scale region, it is necessary to remove the scale region from the image to avoid interference from the microsphere size calculation. The image after removing the scale facilitates centralized processing of the microsphere region. This figure corresponds to the step 1) of "performing pixel calibration of the scale size and then performing morphological processing again." In this invention, the morphological processing again includes pixel filtering, specifically as follows... Figures 5 to 6 The ruler symbol shown is used to filter out low-resolution pixels.
[0099] Figure 7 To invert the image, the white and black regions in the binary image are swapped, making the microsphere outline more prominent.
[0100] Figure 6 and Figure 7 The text "including the '100μm' markings and the corresponding horizontal line" has been "pixel filtered out," therefore Figure 6 and Figure 7 The scale content is not displayed.
[0101] Figure 8 This is a circle reconstruction result based on the least squares method using edge detection. The microsphere contour is extracted using an edge detection algorithm, and then the least squares method is applied to fit the circular contour to obtain the center and radius information of the circle, thereby calculating the diameter of the microsphere.
[0102] Figure 9 This is the result of circle reconstruction based on the minimum bounding rectangle algorithm. The minimum bounding rectangle algorithm is used to obtain the bounding rectangle of a precision microsphere, and this method has good adaptability to microspheres with slightly flat or irregular shapes.
[0103] Figure 10 This image shows the circle reconstruction result based on the maximum inscribed circle method. The maximum inscribed circle method finds an inscribed circle with the largest diameter within the contour of the microsphere and uses this circle's diameter as the microsphere diameter obtained by the method. To improve the accuracy of the maximum inscribed circle method, a sparrow optimization algorithm is used to optimize the maximum inscribed circle. This optimization algorithm can select the optimal maximum inscribed circle from multiple candidate solutions, thereby improving computational accuracy and avoiding errors caused by initial conditions or noise.
[0104] Finally, by comprehensively utilizing the diameter values calculated by the least squares circle fitting method of edge detection, the minimum circumscribed rectangle method, and the maximum inscribed circle method, the average of the three methods is obtained to obtain the diameter detection result of the precision microsphere.
[0105] Figure 11 Table 1 shows a comparison curve of the detection results using a contact micrometer on different spheres and the results of this invention. Figure 11 Table 1 shows the results of precision microsphere diameter measurements on different spheres (sphere 1 to sphere 4) using the contact micrometer method (i.e., experimental sphere) and the method described in this invention (i.e., algorithmic sphere).
[0106] Table 1. Diameter detection results of the algorithmic sphere and the experimental sphere.
[0107]
[0108] This invention also employs mean square error. MSE Mean absolute ratio error MAPE The indicators quantitatively evaluate the results in Table 1, and the results are shown in Table 2. Table 2 presents the evaluation indicators and result data for the algorithm measurement results and experimental results for four different balls. Ball 1 in Table 2 corresponds to Algorithm Ball 1 and Experimental Ball 1 in Table 1, Ball 2 in Table 2 corresponds to Algorithm Ball 2 and Experimental Ball 2 in Table 1, and so on.
[0109]
[0110] In the formula, n For the sample size, f(x i ) The measured value is from the algorithm. y i These are experimental measurements.
[0111] Table 2 shows the algorithm measurement results and experimental results for four different balls. MSE and MAPE evaluate
[0112]
[0113] from Figure 11 As can be seen from the results in Tables 1 and 2, the diameter detection results obtained by using the hybrid geometric feature method of the present invention are consistent with those obtained by the traditional contact micrometer, and the detection error is small, indicating that the method of the present invention has high accuracy.
[0114] In summary, this invention discloses a precision microsphere diameter detection method based on hybrid geometric features, including image processing, diameter calculation, unit conversion, and averaging of multiple measurements. In the image processing step, the acquired precision microsphere image undergoes grayscale processing, image segmentation using the maximum inter-class variance method, morphological processing, extraction of the scale region, calculation of scale pixel values, further morphological processing, and image inversion to obtain the target feature image. In the diameter calculation step, the target region is processed using edge detection least squares circle fitting, the minimum bounding rectangle method, and the maximum inscribed circle method to calculate the circle diameter. This invention uses three different methods to calculate the diameter of the precision microsphere, eliminating errors caused by unclear edge pixels during image acquisition. The method described in this invention does not require image rotation or movement correction and can automatically track the image acquisition position for adaptive diameter calculation. This precision microsphere diameter detection method can detect the diameter of precision microspheres of different sizes with high accuracy and efficiency.
[0115] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A precision microsphere diameter detection method based on hybrid geometric features, characterized in that, The method includes the following steps: 1) Image processing: Specifically, it includes acquiring color microscopic images of precision microspheres, converting them into grayscale images, using the maximum inter-class variance method to threshold segment the grayscale images to obtain binary images, performing morphological processing for the first time to extract scale region features and locate the scale, calibrating the scale size by pixels, performing morphological processing again, and inverting the image to obtain the target feature image with the background removed. 2) Diameter calculation: The diameter of the circle is calculated using three methods: least squares circle fitting, minimum circumscribed rectangle algorithm, and maximum inscribed circle method. The average of the diameters calculated by these three methods is taken as the diameter of the precision microsphere. Step 2) specifically includes: 2a) Calculating the diameter of the circle using the least squares circle fitting method; specifically, this involves first performing edge detection using the Canny edge detection operator, i.e., edge extraction, then fitting the circle equation using the least squares method, and finally calculating the diameter of the circle; 2b) Calculating the diameter of the circle using the minimum bounding rectangle algorithm; specifically, using the center of the minimum bounding rectangle as the center of the circle, and the average perpendicular distance from the center to different side lengths of the rectangle as the radius to calculate the diameter of the circle; 2c) Calculating the diameter of the circle using the maximum inscribed circle method; specifically, by traversing all coordinates of the contour, using the sparrow optimization algorithm to find the diameter of the maximum inscribed circle. Step 1) enables automatic tracking of the image acquisition position, and step 2) performs adaptive diameter calculation. 3) Unit conversion: Convert the diameter of the precision microsphere in step 2) from pixels to the actual length unit to obtain the true diameter of the precision microsphere; wherein, the true diameter of the precision microsphere is obtained by using the scale calibration parameters obtained by pixel calibration of the scale size in step 1). 4) Take the average value after multiple measurements: Measure the precision microspheres three or more times in different directions, and take the average value as the final value for the diameter detection of the precision microspheres; Step 2c specifically includes the following process: The circle calculated using the maximum inscribed circle method must simultaneously satisfy the following conditions: all points on the contour of the precision microsphere lie on or outside the circle, and the circle has a maximum radius. Since some precision microspheres are not perfectly circular at the microscopic level, multiple maximum inscribed circles may exist during the solution process, resulting in no unique solution. For the obtained contour pixel coordinates I(x, y) and image pixel coordinates C(i, j), the complete Euclidean distance transformation point set {D} of the point set C is calculated. ij }, which is represented as: In this context, curly braces represent sets; && represents union, meaning "and," and the union symbol indicates that both the preceding and following conditions must be satisfied; C is the set of image pixel coordinates, and i and j are the x and y coordinates of points in set C; W refers to the set of precision microsphere contour points (x, y), where x and y are the x and y coordinates of points in set W. Based on the properties of the maximum inscribed circle, the center of the maximum inscribed circle lies within the region enclosed by the precision microsphere profile, and the minimum distance from the center to all points on the profile reaches a maximum. The radius {d} of the maximum inscribed circle is determined by calculating the maximum value in the point set {Dij}. n The formula is: Among them, {Dij} may contain multiple identical maxima, but the corresponding pixel coordinates of the maxima are not the same. To reduce computation time, the starting coordinates closest to the contour d1 are taken as the center O(a, b). The sparrow algorithm is used for optimization to find the circle most suitable for the precision microsphere contour, while overcoming the non-circular feature problem of the microsphere contour. An annular region is established with O(a, b) as the center, with an inner radius of |d| and an outer radius of |d|+δ, where δ is an empirical value. By adjusting the thickness of the annular ring, to ensure that the ring fully covers the contour, generally to ensure that the ring and the contour height coincide, the δ value is taken as a number between 1.2 and 1.
8. Contour points are selected as candidate data points within the annular region. Let the set of contour points be {P}. i }, all contour points P within this annular region i That is, the candidate data point {Q} i }; The process of optimizing the search using the sparrow algorithm is to find the optimal candidate data points. Each sparrow represents a set of candidate points, and the position of each sparrow is updated according to its fitness. The fitness function is expressed as: Where R represents the radius of the maximum inscribed circle, and P is a penalty term, which represents the degree of deviation between the candidate point set and the circle. The smaller the penalty term, the smaller the deviation of the candidate points from the circle, and the better the circle covers the contour points. For each contour point I(x, y), calculate its distance d to the current circle center O(a, b). i : Calculate the difference Δd between the distance from profile point I to the center of the circle and the radius of the largest inscribed circle: The penalty term P is represented as: Where m is the total number of contour points, i.e. the total number of edge points; The Sparrow Algorithm searches for the optimal center position and the most suitable set of candidate points by simulating the foraging behavior of a group, based on the candidate points {Q} on the contour. i Construct a Voronoi diagram, which divides the space into multiple regions, each corresponding to a candidate point Q. i All points in this region are at a distance of Q. i Recently, we calculated the distances from Voronoi vertices to candidate points. Each Voronoi vertex is a potential center of a circle. Therefore, we calculated the distance from each Voronoi vertex to a candidate point and took the maximum value, which is the maximum inscribed circle radius max{VD}. i }, and its corresponding Voronoi vertex is the center of the largest inscribed circle; The diameter of the largest inscribed circle is: 。 2. The precision microsphere diameter detection method according to claim 1, characterized in that, In step 1), the first morphological processing includes pixel filtering and hole filling, and the second morphological processing includes pixel filtering.
3. The precision microsphere diameter detection method according to claim 1, characterized in that, In step 2a, for calculating the diameter of the circle using the least squares circle fitting method, the edge detection uses the Canny edge detection algorithm. The image is Gaussian smoothed and denoised. Partial derivatives are calculated on the smoothed and denoised image, and non-maximum suppression is performed. Then, double threshold detection and edge connection are performed. This uses a Gaussian convolution kernel mask to perform convolution calculations on the image, expressed by the following formula: Where G(i,j,δ) represents the Gaussian smoothing filter function, δ is the variance of the Gaussian filter function, and f(i,j) is the gray value in the image. This is the convolution operator, where s(i,j) is the smoothed image, and i and j represent the row and column pixel coordinates of the image, respectively. The gradient magnitude and direction of a pixel are calculated using first-order finite difference along the vertical and horizontal directions. The gradient magnitude |▽f(x, y)| represents the rate of change of the image at that point, where ▽ is the partial derivative with respect to the vector, x and y represent the x-axis and y-axis directions of the Cartesian coordinate system, respectively, and f(x, y) is the gray value in the image. x f is the partial derivative of the function f with respect to the x-direction, ▽ y f is the partial derivative of the function f with respect to the y-direction; the gradient direction θ represents the direction of the edge; the gradient magnitude and gradient direction are expressed as follows: Least squares is an optimization method that optimizes the fitting parameters by minimizing the sum of squared errors. It obtains the coordinates of several points on the edge through edge fitting, and then uses least squares to solve for the equation of the edge circle. Let the center O be (a, b) and the radius be r. Given a set of edge points (x... k y k ), k = 1, 2, 3, ..., m, where k is a certain edge point and m is the total number of edge points; the x-coordinate of edge point k is denoted by x. k The vertical axis is y k ; According to the general equation of a circle: The error function is obtained as follows: Let A = -2a, B = -2b, C = a 2 +b 2 -r 2 ; The objective function simplifies to: Since parameters A, B, and C satisfy the condition that the Loss condition is minimized, we can take the partial derivatives with respect to parameters A, B, and C respectively: We obtain FA, GA, HA, IA, and JA, where FA, GA, HA, IA, and JA represent the definitions of the right-hand side of equations 11 to 15: Further results were obtained: The coordinates of the center and radius of the fitted circle are as follows: The diameter of the circle fitted by the least squares method is: 。 4. The precision microsphere diameter detection method according to claim 1, characterized in that, The minimum bounding rectangle algorithm for calculating the diameter of the circle in step 2b includes: using the minimum bounding rectangle algorithm to locate the center of the precision microsphere and calculating the perpendicular distance from the center to different sides of the rectangle; the minimum bounding rectangle calculation includes determining the convex shell boundary value according to the convex shell boundary rotation algorithm, rotating the convex shell boundary, and calculating the minimum bounding rectangle. The maximum value and minimum value along the X-axis of the convex hull boundary are used as the initial minimum bounding rectangle for boundary rotation. The area of the initial minimum bounding rectangle and the maximum and minimum coordinates on the boundary are recorded. The angle α between each boundary line segment on the convex hull boundary and the X-axis is determined. i Rotate each boundary segment on the convex shell boundary counterclockwise, and calculate the angle between each boundary segment and the X direction, i.e., the rotation angle θ. i The calculation formula is: Where, θ i Let x be the rotation angle of the i-th line segment of the convex hull boundary. i y i Let x and y be the x and y coordinates of the i-th point on the convex hull boundary, respectively. i+1 y i+1 Let x and y be the x and y coordinates of the (i+1)th point on the convex hull boundary, respectively; let θ1, θ2, θ3, ..., θ4 be the coordinates of the convex hull boundary according to the rotation angles θ1, θ2, θ3, ..., θ4. i The points are rotated sequentially around the origin in a clockwise direction. The rotation transformation formula for points in the same coordinate system is derived as follows: Where, x i’ y i’ Let x and y be the x and y coordinates of the i-th point on the convex hull boundary after rotation, respectively. Represents the polar coordinate radius; T is the transpose matrix symbol; The maximum value along the X-axis and the minimum value along the Y-axis of the rotated convex hull boundary are used as the bounding rectangle after the boundary rotation. The area of the rotated bounding rectangle is calculated and compared with the area of the initial minimum bounding rectangle. The coordinates of the four vertices and the rotation angle of the bounding rectangle with the minimum area are retained, and the bounding rectangle with the minimum area is displayed in the image. Then, the convex hull boundary with the bounding rectangle is rotated back by the same rotation angle. The formula for the reverse coordinates is: Where, x i’’ y i’’ Let x and y be the x and y coordinates of the i-th point on the convex hull boundary after inverse rotation, respectively. The convex shell boundary is rotated by angles θ1, θ2, θ3, ..., θ i The rotation is repeated in sequence. If the area of the bounding rectangle obtained after the rotation is smaller than the area of the previous bounding rectangle, the area of the current bounding rectangle, the coordinates of the four vertices and the rotation angle will be retained until all boundaries are rotated. The rectangle with the smallest area is the smallest bounding rectangle. The four vertices of the smallest bounding rectangle are connected in sequence. The coordinates of the four vertices are A1(x1, y1), B1(x2, y2), C1(x3, y3) and D1(x4, y4). The center point of the rectangle is the center of the circle. The distances L1 and L2 from the center of the circle to different sides of the rectangle are respectively: Where k1 is the slope of side 1 of the smallest circumscribed rectangle, and k2 is the slope of side 2 of the smallest circumscribed rectangle; Therefore, the diameter of the precision microsphere calculated using the minimum circumscribed rectangle method is: 。
Citation Information
Patent Citations
Method for measuring diameter of microsphere based on Photoshop software
CN108956390A
Automatic solder ball diameter measuring device and method
CN112325783A
Regional power distribution network load demand hybrid prediction method
CN113537553A
Online car-hailing demand prediction method based on SSA-Conv-LSTM
CN115545746A
Post-welding unbalance correction method for assembling and welding heavy rotating member with two solid ends and multiple bamboo joints in middle
CN117086337A