Precise microsphere diameter detection method based on mixed geometrical characteristics
Through the detection method based on mixed geometric features, combined with image processing and geometric feature calculation, the problems of long-term detection, low accuracy and easy damage are solved, and high-precision, fast and damage-free detection effect is achieved.
Patent Information
- Application Number
- CN202510320566.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2045-03-18
AI Technical Summary
The prior art has problems such as long time-consuming, low accuracy and easy damage to the microspheres when detecting precision microspheres with smaller diameters.
The precision microsphere diameter detection method based on mixed geometric features is used to calculate the diameter of the circle through image processing, least squares circle fitting, minimum circumferential rectangle algorithm and maximum intangible circle method, and the mean value is taken as the final result.
It improves the accuracy and reliability of detection, reduces errors caused by blurred edges or unclear edges during image acquisition, avoids physical damage to microspheres, and shortens detection time.
Smart Images

Figure CN119863505A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of precision microsphere diameter detection, and in particular to a precision microsphere diameter detection method based on mixed geometric features. Background Art
[0002] Precision microspheres are the core units of high-precision mechanical parts and are widely used in aerospace, precision machine tools and other fields. The dimensional accuracy of precision microspheres not only affects their adaptability in products, but is also directly related to the accuracy of mechanical assembly, the service life of products and the stability of the system. In the production process of high-precision mechanical parts, how to quickly and accurately detect the size of precision microspheres has become an important factor limiting the improvement of processing technology and production efficiency.
[0003] After processing, the size of precision microspheres needs to be measured. Due to their small size and light weight, conventional contact measurements, such as AFM and micrometer, take a lot of time to position and measure precision microspheres, and are prone to damage the surface of the precision microspheres. Damaged precision microspheres cannot be used in subsequent processes.
[0004] Regarding the circle diameter detection method, Chinese invention patent application CN202011230587.7 discloses an automatic measurement device and method for solder ball diameter, in which the upper end surface of the optical glass is used to place the solder ball, a telecentric parallel light source is set at the bottom of the optical glass, and an industrial camera is set directly above the optical glass. The industrial camera uses a telecentric lens. When measuring, the solder ball is placed on the optical glass; the telecentric lens collects the image information of the solder ball; the industrial camera transmits the image information to the computer, and according to the obtained solder ball projection picture, the diameter of each solder ball is obtained by measuring the sum of pixels of each solder ball projection, and the average value is calculated. During the measurement process of this method, when there are tiny flaws or irregular shapes on the surface of the solder ball, the projection image cannot accurately reflect the actual sphere diameter, thereby 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. Take a photo of microspheres: evenly disperse the microspheres to be measured, and then place them under a microscope equipped with a mesh eyepiece ruler to enlarge and take photos to obtain a photo of the microspheres; b. Count the microspheres: use Photoshop software to open the microsphere photo, and mark the number of microspheres in the microsphere photo in the counting mode; c. Set the measurement scale: measure the pixel length of the unit length of the mesh eyepiece ruler in the microsphere photo in the Photoshop software; enter the value of the pixel length into the blank column of "pixel length" under the "Set measurement scale" item in the Photoshop software; enter the value of the unit length into the blank column of "logical length" under the "Set measurement scale" item in the Photoshop software; then the Photoshop software automatically calculates the measurement scale; d. Measurement: after setting the measurement scale, measure the diameter of the microspheres with the number of marked microspheres in the Photoshop software. The invention has the characteristics of fast and simple measurement method, low equipment requirements and accurate measurement. This patent uses Photoshop software to measure microspheres. Although batch detection is achieved, the microspheres are manually marked, the measurement ratio is manually input, and the diameter of each microsphere is measured in turn. The operation is cumbersome and prone to errors, which leads to limited measurement accuracy. The invention relies on manual operations such as dragging the mouse to measure the diameter, which has human errors and limited measurement accuracy. In addition, Photoshop software is used for image editing. It is not a professional metrology software, lacks sufficient sub-pixel precision support, and does not consider image distortion and image correction. Therefore, for the diameter detection of precision microspheres in the present invention, the method cannot obtain accurate diameter data. Summary of the invention
[0006] The purpose of the present invention is to provide a method for detecting the diameter of precision microspheres based on mixed geometric features, so as to solve the problems in the background art that the size detection of precision microspheres with smaller diameters (for example, diameters within 0.9 mm) using existing methods is time-consuming, has low accuracy, and is easy to damage the precision microspheres.
[0007] To achieve the above-mentioned purpose, the present invention provides a method for detecting the diameter of precision microspheres based on mixed geometric features, the method comprising the following steps: 1) image processing: specifically, collecting a color microscopic image of precision microspheres, converting it into a grayscale image, performing threshold segmentation on the grayscale image using the maximum inter-class variance method to obtain a binary image, performing morphological processing for the first time, extracting scale area features and positioning scales, performing pixel calibration on the scale size, performing morphological processing again, and inverting the image, thereby obtaining a target feature image with the background removed; 2) diameter calculation: using the least squares circle fitting method, the minimum circumscribed rectangle algorithm, and the maximum inscribed circle method to calculate the diameter of the circle, and taking the average of the diameters calculated by the three methods as the diameter of the precision microspheres; 3) unit conversion: converting the diameter of the precision microspheres in pixels in step 2) into actual length units to obtain the true diameter of the precision microspheres; 4) taking the average of multiple measurements: measuring the precision microspheres more than three times in different directions, and finally taking the average value as the final value of the precision microsphere diameter detection.
[0008] In the present invention, the conversion unit in step 3) includes converting the diameter of the precision microsphere in pixels into actual length units such as mm or μm.
[0009] In a specific embodiment, in the step 1), the first morphological processing includes pixel filtering and hole filling, and the second morphological processing includes pixel filtering; in the step 3), the scale calibration parameters obtained by pixel calibration of the scale size in step 1) are used for calculation to obtain the true precision microsphere diameter.
[0010] In a specific implementation, the step 2) specifically includes: after positioning the target feature image described in step 1), respectively using the following steps 2a, 2b and 2c to calculate the diameter of the circle, and then taking the average as the diameter of the precision microsphere; 2a, calculating the diameter of the circle by least squares circle fitting; specifically including first using the canny edge detection operator to perform edge detection, that is, edge extraction, and 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 by the minimum circumscribed rectangle algorithm; specifically taking the center of the minimum circumscribed rectangle as the center of the circle, and taking the average of the vertical distances from the center of the circle to the different sides of the rectangle as the radius to calculate the diameter of the circle; 2c, calculating the diameter of the circle by 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 a specific implementation, in the step 2), for the least squares circle fitting to calculate the diameter of the circle, the edge detection adopts the Canny edge detection algorithm, Gaussian smoothing and denoising is performed on the image, partial derivatives are calculated for the smoothed and denoised image, non-maximum suppression processing is performed, and then double threshold detection and edge connection are performed, and the image is convoluted using a Gaussian convolution kernel mask, and the formula can be expressed as: in, G(i, j, δ) represents the Gaussian smoothing filter function, δ is the variance value of the Gaussian filter function, f(i, j) is the grayscale value in the image, ⊗ is the convolution operator, s(i, j) is the smoothed image, i and j Represent the row pixel coordinates and column pixel coordinates of the image respectively; Use first-order finite differences in the vertical and horizontal directions to calculate the gradient magnitude and direction of the pixel point. The gradient magnitude |▽ f(x, y) | represents the rate of change of the image at that point, where ▽ is the partial derivative of the vector, x and y Represents the rectangular coordinate system x Axis and y Axis direction, f(x, y) is the gray value in the image, ▽ x f For the function f of x Direction is partial guidance, y f For the function f of y Direction partial derivative; gradient direction θ Indicates the direction of the edge; the gradient magnitude and gradient direction are expressed as: The least square method is an optimization method that optimizes the fitting parameters by minimizing the sum of squares of errors. The coordinates of several points on the edge are obtained by edge fitting. The equation of the edge circle is solved by the least square method. O for (a, b) , the 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 is the total number of edge points; k The horizontal axis is x k, the vertical axis is y k ; From the general equation of a circle: Get the error function: make A=-2a,B=-2b,C=a 2 +b 2 -r 2 ; The objective function can be simplified as: parameter A, B, C satisfy Loss To obtain the minimum value, we need to adjust the parameters A, B, C Find the partial derivative: Can get FA , GA , HA , I A , J A ,in FA , GA , HA , I A , J A Represents the definition of the right side of equations 11 to 15: We can further get: The center coordinates and radius of the fitted circle are: The diameter of the least squares fitted circle is: .
[0012] In a specific embodiment, the calculation of the diameter of the circle by the minimum circumscribed rectangle algorithm in step 2) includes: using the minimum circumscribed rectangle algorithm to locate the center of the precision microsphere, and calculating the vertical distance from the center of the circle to different sides of the rectangle; the minimum circumscribed rectangle calculation includes determining the convex hull boundary value according to the convex hull boundary rotation algorithm, rotating the convex hull boundary, and calculating the minimum circumscribed rectangle; The convex hull boundary X The maximum value in the axial direction and Y The minimum value in the axial direction is used as the initial minimum circumscribed rectangle of the boundary rotation, and the area of the initial minimum circumscribed rectangle and the maximum and minimum coordinates on the boundary are recorded; determine the relative position of each boundary line segment on the convex hull boundaryX Angle in direction α i ; Rotate each boundary line segment on the convex hull boundary counterclockwise and calculate the relative X The angle between the directions, that is, the rotation angle, the rotation angle θ i The calculation formula is: in, θ i is the convex hull boundary i The rotation angle of the line segment, x i ,y i are the first i The horizontal and vertical coordinates of the point, x i+1 ,y i+1 are the first i+1 The horizontal and vertical coordinates of the point; the convex hull boundary is based on the rotation angle θ 1 ,θ 2 ,θ 3 、…、 θ i The order of rotation around the origin of the coordinate system is rotated clockwise in sequence. The point rotation transformation in the same coordinate system, the rotation coordinate formula is derived as follows: in, x i’ 、y i’ They are the first i The horizontal and vertical coordinates of the point after rotation, represents the polar coordinate radius; T is the transposed matrix symbol; The rotated convex hull boundary X The maximum value in the axial direction and Y The minimum value in the axis direction is used as the bounding rectangle after the boundary rotation. The area of the bounding rectangle after rotation is calculated and compared with the initial minimum bounding rectangle area. The four vertex coordinates and rotation angle of the bounding rectangle with the minimum bounding rectangle area are retained, and the bounding rectangle with the smallest area is displayed in the image; then the convex hull boundary of the bounding rectangle is reversely rotated back at the same rotation angle, and the reverse coordinate formula is: in, x i’’、y i’’ They are the first i The horizontal and vertical coordinates of the point after reverse rotation; The convex hull boundary is rotated by an angle θ 1 ,θ 2 ,θ 3 ,…,θ i Repeat the rotation in the order of . If the area of the enclosing rectangle obtained after rotation is smaller than the area of the previous enclosing rectangle, the current enclosing rectangle area, four vertex coordinates and rotation angle will be retained until all boundaries are rotated. The rectangle with the smallest area is the minimum enclosing rectangle, and the four vertices of the minimum enclosing rectangle are connected in sequence. 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 ,y 4 ) ; Calculate the center point of the rectangle as the center of the circle: Distance from the center of the circle to different sides of the rectangle L 1 and L 2 They are: in, k 1 is the slope of the minimum circumscribed rectangle side 1, k 2 is the slope of side 2 of the minimum circumscribed rectangle; Therefore, the precision microsphere diameter calculated by the minimum circumscribed rectangle method is: .
[0013] In a specific embodiment, the maximum inscribed circle method is used to calculate the diameter of the circle in step 2. The circle calculated by the maximum inscribed circle method must satisfy the following conditions: all points on the contour of the precision microsphere are located on or outside the circle, and the circle has a maximum radius. Since some precision microspheres are not absolutely circular at the microscopic level, there may be multiple maximum inscribed circles in the process of solving the maximum inscribed circle, and there is no unique solution. For the pixel coordinates of the obtained contour, 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 expressed as: Among them, the curly brackets represent sets; && represents a collection, which means and. The collection symbol means that both the previous condition and the following condition must be met; C is the set of image pixel coordinates, i and j Is a collection C The horizontal and vertical coordinates of the points in; W Refers to the precision microsphere contour point set (x, y) , x and y Is a collection W The horizontal and vertical coordinates of the points in; According to the properties of the maximum inscribed circle, the center of the maximum inscribed circle is located inside the area enclosed by the contour of the precision microsphere, and the minimum value of the distance from the center to all points on the contour reaches the maximum value. Dij The maximum value of} determines the radius of the largest inscribed circle d n}, the formula is: in,{ Dij There may be multiple identical maxima in the image, but the coordinate pixel positions corresponding to the maxima are not the same. To reduce the calculation time, the pixel closest to the contour is selected. d 1 The starting point coordinates are the center O(a, b) In order to prevent the surface of the precision microsphere from being not cleaned properly, resulting in a small amount of impurities on the edge of the collected image, and the impurities cannot be directly processed by morphological methods, therefore, the general maximum inscribed circle calculation method has certain limitations, and its calculation accuracy needs to be further improved; through the sparrow algorithm optimization, the circle that best fits the contour of the precision microsphere is found, while overcoming the non-circular feature problem of the microsphere contour; O(a, b) As the center of the circle, establish an annular area with an inner radius of | d |, the outer radius is | d|+ δ ,in, δ It is an empirical value. By adjusting the thickness of the ring, we can ensure that the ring can fully cover the contour. Generally, we can ensure that the ring and the contour are highly overlapped. δ The value is between 1.2 and 1.8; the contour points are selected as candidate data points in the annular area, and the contour point set is { P i}, all contour points in this annular area P i The candidate data point Q i}; The process of optimizing the search through the sparrow algorithm is to find the optimal candidate data point. Each sparrow individual represents a set of candidate points. The sparrow individual updates its position according to its fitness. The fitness function Fitness It can be expressed as: in, R represents the maximum inscribed circle radius, P is a penalty term, which indicates the degree of deviation between the candidate point set and the circle. The smaller the penalty term, the smaller the deviation of the candidate point from the circle, and the better the coverage of the contour points by the circle. For each contour point I(x,y) , calculate its distance to the current center O(a, b) Distance d i : Calculate contour points I The difference Δd between the distance to the center of the circle and the radius of the largest inscribed circle: Penalty P It can be expressed as: in, m is the total number of contour points, that is, the total number of edge points; The sparrow algorithm searches for the optimal center position and the most suitable candidate point set by simulating group foraging behavior. Q i}Establish Voronoi picture, Voronoi The graph divides the space into multiple regions, each of which corresponds to a candidate point Q i , the distance between all points in the area Q i Recently; Calculate Voronoi The distance from the vertex to the candidate point, each VoronoiA vertex is a potential center of a circle, so calculating each Voronoi The distance from the vertex to the candidate point, the maximum value is the maximum inscribed circle radius max { VD i}, its corresponding Voronoi The vertex is the center of the largest inscribed circle; The diameter of the largest inscribed circle is: .
[0014] In the present invention, the diameter of the precision microspheres detected at the end of the last step 2) is: .
[0015] Compared with the prior art, the present invention has the following beneficial effects: 1) The precision microsphere diameter detection method based on mixed geometric features of the present invention utilizes a detection method combining multiple geometric features, including edge detection and least squares circle fitting, minimum circumscribed rectangle and maximum inscribed circle, etc. By calculating the diameter of precision microspheres from different angles, it can effectively reduce the error caused by blurred or unclear edges during image acquisition. Compared with the existing single circle fitting method, the present invention can comprehensively utilize the different geometric features of precision microspheres to obtain more accurate microsphere diameter measurement results, thereby improving the reliability and accuracy of detection.
[0016] 2) The precision microsphere diameter detection method based on hybrid geometric features of the present invention can automatically adapt to different microsphere postures without the need to rotate or translate the image. Traditional circle fitting methods often require additional image transformations when dealing with irregularly rotated or asymmetric microspheres, which not only increases the computational complexity but may also lead to measurement errors. The present invention, by adopting hybrid geometric features, can automatically track and calculate the diameter of microspheres without the need for image correction, and has stronger adaptability.
[0017] 3) The precision microsphere diameter detection method based on mixed geometric features of the present invention is combined with the sparrow optimization algorithm to optimize the maximum inscribed circle method, which can more accurately process microspheres of different sizes and shapes. Traditional methods often have large errors when processing microspheres with irregular shapes or slight deformations. By introducing the optimization algorithm, it is possible to automatically select the optimal solution and accurately calculate the diameter of the microsphere when there are multiple candidate circles. This method has good adaptability to microspheres of different sizes and different surface features, and can be widely used in precision microsphere size detection in different fields.
[0018] Compared with the prior art, the diameter data obtained by the micrometer from the precision microspheres can generally be regarded as the true and accurate diameter data of the precision microspheres. However, when using the micrometer for measurement, the micrometer needs to squeeze and contact the precision microspheres. It is very easy to operate improperly during the measurement process, resulting in the precision microspheres being crushed or surface damage, which will cause the precision microspheres to be unable to be used in subsequent product applications; and it takes about 3 to 5 minutes for the micrometer to measure each precision microsphere, and its detection is also time-consuming. AFM measurement is a contact probe measurement method, and it is also easy to operate improperly during the measurement process, resulting in scratches on the surface of the precision microspheres and thus causing the precision microspheres to be scrapped. And AFM measurement of each precision microsphere takes about several hours, and its detection is very time-consuming. The method described in the present invention is based on the very accurate measurement of the diameter size of the precision microspheres (its measurement error can fully meet the needs), does not require contact measurement, will not cause any damage to the microspheres, and the measurement time of each precision microsphere is only 1 to 2 minutes. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In addition to the above-described purposes, features and advantages, the present invention has other purposes, features and advantages. The present invention will be further described in detail below with reference to the accompanying drawings.
[0020] The accompanying drawings are used to provide further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the embodiments of the present invention, but do not constitute a limitation to the embodiments of the present invention.
[0021] Figure 1 It is a flow chart of the precise microsphere diameter detection method based on hybrid geometric features.
[0022] Figure 2 This is an image collected under a precision microsphere microscope used in the experiment.
[0023] Figure 3 It is a grayscale image of precision microspheres.
[0024] Figure 4 It is a binary image of precision microsphere.
[0025] Figure 5 It is the scale feature extraction image of the precision microsphere.
[0026] Figure 6 This is the image after removing the precision microsphere ruler.
[0027] Figure 7 This is the result image after inverting the image.
[0028] Figure 8 It is the precise microsphere circle reconstruction result based on the least squares method of edge detection.
[0029] Fig. 9It is the precise microsphere circle reconstruction result based on the minimum circumscribed rectangle algorithm.
[0030] Fig.10 It is the result of precise microsphere circle reconstruction based on the maximum inscribed circle.
[0031] Fig.11 It is a comparison result curve of the detection results of different balls and algorithms measured by contact micrometer. DETAILED DESCRIPTION
[0032] The present invention will be described in detail below in conjunction with the various embodiments shown in the accompanying drawings, but it should be noted that these embodiments are not limitations of the present invention, and any equivalent transformations or substitutions in functions, methods, or structures made by ordinary technicians in the field based on these embodiments are all within the scope of protection of the present invention.
[0033] In the present invention, the diameter of the standard sphere with a diameter of less than 0.9 mm used in the aerospace field is detected. For example, the diameter size requirement of the precision microsphere in this embodiment is 0.85 mm, and the diameter of the microsphere before precision machining is more than 0.9 mm. After precision machining, it is necessary to measure whether the diameter of the precision microsphere has reached the standard, and then the diameter needs to be detected. If the diameter has not reached the standard, then it is necessary to continue precision machining.
[0034] Figure 1 The flow chart of the precision microsphere diameter detection method based on mixed geometric features is shown. The core process of this method includes the following steps: using a microscope to collect images of precision microspheres, image preprocessing including grayscale, binarization, morphological processing and scale area extraction. Edge detection algorithm and least squares circle fitting, minimum circumscribed rectangle algorithm, maximum inscribed circle and other methods are used for processing. The maximum inscribed circle is optimized by the sparrow optimization algorithm to ensure the accuracy of the optimal solution. In the edge detection algorithm and the least squares circle fitting step, it includes first performing edge detection, then using the least squares circle fitting equation, and then outputting the diameter and circle center coordinates calculated by the method; in the minimum circumscribed rectangle algorithm, first extract the features of the minimum circumscribed rectangle, then locate the circle center and calculate the perpendicular distances from the circle center to different sides of the minimum circumscribed rectangle, then calculate the average value of different distances, and the calibration result is output as the circle diameter calculated by this method; in the maximum inscribed circle method, first implement the complete Euclidean distance transformation, then use the sparrow algorithm to optimize the search for the optimal candidate data point, and then calculate the distance from each vertex Voronoi to the candidate point, and the maximum value is the maximum inscribed circle radius.
[0035] Figure 2 As shown in Figure 1, an optical microscope is used to collect images of precision microspheres. The images collected under the microscope can clearly show the outline of the microspheres. To ensure the image quality, a high-resolution camera and a telecentric lens are used in the experiment to avoid image distortion and aberration.
[0036] Figures 2~4 and Figures 8-10 The 100 μm in the figure are scale bars.
[0037] Figure 3 It is a grayscale image of precision microspheres. Its purpose is to convert color images into grayscale images to simplify the complexity of subsequent processing. In the image, the edge information of the microspheres is more obvious.
[0038] Figure 4 It is a binary image of precision microspheres. The grayscale image is binarized by adaptively finding the threshold using the maximum inter-class variance method.
[0039] Figure 5 The figure shows the process of extracting scale features from precision microsphere images. The scale area is extracted from the image, and the size calibration can be converted into the actual microsphere diameter. This figure corresponds to the step of "first morphological processing, extracting scale area features and locating scale" in step 1). In the present invention, the first morphological processing includes pixel filtering and hole filling, specifically, for example, Figures 4 to 5 Shown is the 100 μm font that filters out low-pixel content and fills the hole in the center of the sphere. Figure 5 The 100μm characters in the image have been “pixel filtered out”, leaving only the horizontal lines that originally correspond to the 100μm characters.
[0040] Figure 6 As shown in FIG. 1 , after the scale area is extracted, the scale area needs to be removed from the image to avoid interference of the scale on the microsphere size calculation. The image after removing the scale is convenient for centralized processing of the microsphere area. This figure corresponds to the step of "pixel calibration of the scale size and re-performing morphological processing" in step 1). In the present invention, re-performing morphological processing includes pixel filtering, specifically as follows Figures 5 and 6 The ruler symbol with low pixels filtered out is shown.
[0041] Figure 7 To invert the image, the white area in the binary image was swapped with the black area to make the microsphere outline more prominent.
[0042] Figure 6 and Figure 7 The words "100μm" and the horizontal lines corresponding to the words "100μm" have been "pixel filtered out", so Figure 6 and Figure 7 The scale bar content is not displayed.
[0043] Figure 8 It is the result of least squares circle reconstruction based on edge detection. The microsphere contour is extracted by 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, and then the diameter of the microsphere is calculated.
[0044] Fig. 9 This is the circle reconstruction result based on the minimum bounding rectangle algorithm. The minimum bounding rectangle algorithm is used to obtain the bounding rectangle of the precision microsphere. This method has good adaptability to microspheres with slightly flat or irregular shapes.
[0045] Fig.10 The maximum inscribed circle reconstruction result is shown in Figure 1. The maximum inscribed circle method finds an inscribed circle with the maximum diameter within the contour of the microsphere, and uses the diameter of this circle as the diameter of the microsphere obtained by the maximum inscribed circle method. In order to improve the accuracy of the maximum inscribed circle method, the sparrow optimization algorithm is used to optimize the maximum inscribed circle. Through the optimization algorithm, the optimal maximum inscribed circle can be selected from multiple candidate solutions, thereby improving the calculation accuracy and avoiding errors caused by initial conditions or noise.
[0046] Finally, the diameter values calculated by the least squares circle fitting of edge detection, the minimum circumscribed rectangle method and the maximum inscribed circle method are comprehensively utilized, and the average of the three is calculated to obtain the diameter detection result of the precision microsphere.
[0047] Fig.11 The data in Table 1 correspond to the test results of different spheres and the present invention. Fig.11 Table 1 shows the precision microsphere diameter test results obtained by measuring different spheres (spheres 1 to 4) using the contact micrometer method (i.e., experimental sphere) and the method of the present invention (i.e., algorithm sphere).
[0048] Table 1 Diameter detection results of algorithm ball and experimental ball The present invention also adopts mean square error MSE , mean absolute proportional error MAPE The indicators are used to quantitatively evaluate the results in Table 1, and the results are shown in Table 2. Table 2 shows the evaluation indicators and result data of the algorithm measurement results and experimental results of four different balls. Ball 1 in Table 2 corresponds to the algorithm ball 1 and experimental ball 1 in Table 1, and ball 2 in Table 2 corresponds to the algorithm ball 2 and experimental ball 2 in Table 1, and so on.
[0049] In the formula, n is the sample size, f(x i ) is the algorithm measurement value, y i are experimental measured values.
[0050] Table 2 Comparison of algorithm measurement results and experimental results for four different balls MSE and MAPE evaluate from Fig.11 It can be seen from the results of Table 1 and Table 2 that the diameter detection result of the hybrid geometric feature method of the present invention is consistent with the measurement result of the traditional contact micrometer, and the detection error is small, indicating that the method of the present invention has high accuracy.
[0051] In general, the present invention discloses a method for detecting the diameter of precision microspheres based on mixed geometric features, including the steps of image processing, diameter calculation, unit conversion, and multiple measurements and averaging; in the image processing step, the present invention performs grayscale processing on the collected precision microsphere image, uses the maximum inter-class variance method to perform image segmentation, morphological processing, extracts the scale area, calculates the scale pixel value, and then performs morphological processing, and inverts the image to obtain a target feature image; in the diameter calculation step, the target area is processed by edge detection least squares circle fitting, the minimum circumscribed rectangle method, and the maximum inscribed circle method, respectively, to calculate the circle diameter. The present invention uses three different methods to calculate the diameter of precision microspheres, eliminating the error caused by unclear edge pixels during image acquisition. The method of the present invention does not need to rotate or move the image for correction, and can realize automatic tracking of the image acquisition position for adaptive diameter calculation. The precision microsphere diameter detection method of the present invention can realize the diameter detection of precision microspheres of different sizes, and it has high detection accuracy and high detection efficiency.
[0052] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for detecting the diameter of a precision microsphere based on mixed geometric features, characterized in that: The method comprises the steps of, 1) Image processing: specifically, it includes collecting color microscopic images of precision microspheres, converting them into grayscale images, performing threshold segmentation on the grayscale images using the maximum inter-class variance method to obtain binary images, performing morphological processing for the first time, extracting scale area features and locating scales, calibrating scale sizes by pixels, performing morphological processing again, and inverting the images to obtain target feature images with the background removed; 2) Diameter calculation: The diameter of the circle is calculated using the least squares circle fitting method, the minimum circumscribed rectangle algorithm, and the maximum inscribed circle method, and the average of the diameters calculated by these three methods is taken as the diameter of the precision microsphere; 3) Converting units: Convert the diameter of the precision microsphere in pixels in step 2) into actual length units to obtain the true diameter of the precision microsphere; 4) Take the average value after multiple measurements: Measure the precision microspheres more than three times in different directions, and finally take the average value as the final value of the precision microsphere diameter detection.
2. The method for detecting the diameter of a precision microsphere according to claim 1, characterized in that: In the step 1), the first morphological processing includes pixel filtering and hole filling, and the second morphological processing includes pixel filtering; in the step 3), the scale calibration parameters obtained by pixel calibration of the scale size in step 1) are used for calculation to obtain the true precision microsphere diameter.
3. The method for detecting the diameter of a precision microsphere according to claim 1, characterized in that: The step 2) specifically includes: after positioning the target feature image in step 1), respectively calculating the diameter of the circle by using the following steps 2a, 2b and 2c, and then taking the average as the diameter of the precision microsphere; 2a. Calculate the diameter of the circle by least squares circle fitting; specifically, first use the canny edge detection operator to perform edge detection, that is, edge extraction, then fit the circle equation according to the least squares method, and then calculate the diameter of the circle; 2b. Calculate the diameter of a circle using the minimum circumscribed rectangle algorithm. Specifically, the center of the minimum circumscribed rectangle is taken as the center of the circle, and the average of the vertical distances from the center of the circle to the different sides of the rectangle is taken as the radius to calculate the diameter of the circle. 2c. The maximum inscribed circle method is used to calculate the diameter of a circle. Specifically, the maximum inscribed circle diameter is found by traversing all coordinates of the contour and using the sparrow optimization algorithm.
4. The method for detecting the diameter of a precision microsphere according to claim 3, characterized in that: In the step 2), for the least squares circle fitting to calculate the diameter of the circle, the edge detection adopts the Canny edge detection algorithm, the image is Gaussian smoothed and denoised, the partial derivative of the smoothed and denoised image is calculated, non-maximum suppression processing is performed, and then double threshold detection and edge connection are performed. The image is convoluted using a Gaussian convolution kernel mask, and the formula can be expressed as: in, G(i, j, δ) represents the Gaussian smoothing filter function, δ is the variance value of the Gaussian filter function, f(i, j) is the grayscale value in the image, ⊗ is the convolution operator, s(i, j) is the smoothed image, i and j Represent the row pixel coordinates and column pixel coordinates of the image respectively; Use first-order finite differences in the vertical and horizontal directions to calculate the gradient magnitude and direction of the pixel point. The gradient magnitude |▽ f (x, y) | represents the rate of change of the image at that point, where ▽ is the partial derivative of the vector, x and y Represents the rectangular coordinate system x Axis and y Axis direction, f(x, y) is the gray value in the image, ▽ x f For the function f of x Direction is partial guidance, y f For the function f of y Direction partial derivative; gradient direction θ Indicates the direction of the edge; the gradient magnitude and gradient direction are expressed as: The least square method is an optimization method that optimizes the fitting parameters by minimizing the sum of squares of errors. The coordinates of several points on the edge are obtained by edge fitting. The equation of the edge circle is solved by the least square method. O for (a, b) , the radius is r , given a set of edge points (x k ,y k ),k=1,2,3,…,m ,in, k For an edge point, m is the total number of edge points; k The horizontal axis is x k , the vertical axis is y k ; From the general equation of a circle: Get the error function: make A=-2a,B=-2b,C=a 2 +b 2 -r 2 ; The objective function can be simplified as: parameter A, B, C satisfy Loss To obtain the minimum value, we need to adjust the parameters A, B, C Find partial derivatives: Can get FA , GA , HA , I A , J A ,in FA , GA , HA , I A , J A Represents the definition of the right side of equations 11 to 15: We can further get: The center coordinates and radius of the fitted circle are: The diameter of the least squares fitted circle is: 。 5. The method for detecting the diameter of a precision microsphere according to claim 1, characterized in that: The calculation of the diameter of the circle by the minimum circumscribed rectangle algorithm in step 2) includes: locating the center of the precision microsphere by the minimum circumscribed rectangle algorithm, and calculating the vertical distance from the center of the circle to different sides of the rectangle; the calculation of the minimum circumscribed rectangle includes determining the convex hull boundary value according to the convex hull boundary rotation algorithm, rotating the convex hull boundary, and calculating the minimum circumscribed rectangle; The convex hull boundary X The maximum value in the axial direction and Y The minimum value in the axial direction is used as the initial minimum circumscribed rectangle of the boundary rotation, and the area of the initial minimum circumscribed rectangle and the maximum and minimum coordinates on the boundary are recorded; determine the relative position of each boundary line segment on the convex hull boundary X Angle in direction α i ; Rotate each boundary line segment on the convex hull boundary counterclockwise and calculate the relative X The angle between the directions, that is, the rotation angle, the rotation angle θ i The calculation formula is: in, θ i is the convex hull boundary i The rotation angle of the line segment, x i ,y i are the first i The horizontal and vertical coordinates of the point, x i+1 ,y i+1 are the first i+1 The horizontal and vertical coordinates of the point; the convex hull boundary is based on the rotation angle θ 1 ,θ 2 ,θ 3 ,…,θ i The order of rotation around the origin of the coordinate system is rotated clockwise in sequence. The point rotation transformation in the same coordinate system, the rotation coordinate formula is derived as follows: in, x i’ 、y i’ They are the first i The horizontal and vertical coordinates of the point after rotation, represents the polar coordinate radius; T is the transposed matrix symbol; The rotated convex hull boundary X The maximum value in the axial direction and Y The minimum value in the axis direction is used as the bounding rectangle after the boundary rotation. The area of the bounding rectangle after rotation is calculated and compared with the initial minimum bounding rectangle area. The four vertex coordinates and rotation angle of the bounding rectangle with the minimum bounding rectangle area are retained, and the bounding rectangle with the smallest area is displayed in the image; then the convex hull boundary of the bounding rectangle is reversely rotated back at the same rotation angle, and the reverse coordinate formula is: in, x i’’ 、y i’’ They are the first i The horizontal and vertical coordinates of the point after reverse rotation; The convex hull boundary is rotated by an angle θ 1 ,θ 2 ,θ 3 ,…,θ i Repeat the rotation in the order of . If the area of the enclosing rectangle obtained after rotation is smaller than the area of the previous enclosing rectangle, the current enclosing rectangle area, four vertex coordinates and rotation angle will be retained until all boundaries are rotated. The rectangle with the smallest area is the minimum enclosing rectangle, and the four vertices of the minimum enclosing rectangle are connected in sequence. 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 ,y 4 ) ; Calculate the center point of the rectangle as the center of the circle: Distance from the center of the circle to different sides of the rectangle L 1 and L 2 They are: in, k 1 is the slope of the minimum circumscribed rectangle side 1, k 2 is the slope of the minimum circumscribed rectangle side 2; Therefore, the precision microsphere diameter calculated by the minimum circumscribed rectangle method is: 。 6. The method for detecting the diameter of a precision microsphere according to claim 1, characterized in that: In the step 2), the maximum inscribed circle method is used to calculate the diameter of the circle. The circle calculated by the maximum inscribed circle method must satisfy the requirement that all points on the contour of the precision microsphere are located on or outside the circle, and the circle has a maximum radius. Since some precision microspheres are not absolutely circular at the microscopic level, there may be multiple maximum inscribed circles in the process of solving the maximum inscribed circle, and there is no unique solution. The pixel coordinates of the obtained contour 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 expressed as: Among them, the curly brackets represent sets; && represents a collection, which means and. The collection symbol means that both the previous condition and the following condition must be met; C is the set of image pixel coordinates, i and j Is a collection C The horizontal and vertical coordinates of the points in; W Refers to the precision microsphere contour point set (x, y) , x and y Is a collection W The horizontal and vertical coordinates of the points in; According to the properties of the maximum inscribed circle, the center of the maximum inscribed circle is located inside the area enclosed by the contour of the precision microsphere, and the minimum value of the distance from the center to all points on the contour reaches the maximum value. Dij The maximum value of} determines the radius of the largest inscribed circle d n }, the formula is: in,{ Dij There may be multiple identical maxima in the image, but the coordinate pixel positions corresponding to the maxima are not the same. To reduce the calculation time, the pixel closest to the contour is selected. d 1 The starting point coordinates are the center O(a, b) In order to prevent the surface of the precision microsphere from being not cleaned properly, resulting in a small amount of impurities on the edge of the collected image, and the impurities cannot be directly processed by morphological methods, therefore, the general maximum inscribed circle calculation method has certain limitations, and its calculation accuracy needs to be further improved; through the sparrow algorithm optimization, the circle that best fits the contour of the precision microsphere is found, while overcoming the non-circular feature problem of the microsphere contour; O(a, b) As the center of the circle, establish an annular area with an inner radius of | d |, the outer radius is | d |+ δ ,in, δ It is an empirical value. By adjusting the thickness of the ring, we can ensure that the ring can fully cover the contour. Generally, we can ensure that the ring and the contour are highly overlapped. δ The value is between 1.2 and 1.8; the contour points are selected as candidate data points in the annular area, and the contour point set is { P i }, all contour points in this annular area P i The candidate data point Q i }; The process of optimizing the search through the sparrow algorithm is to find the optimal candidate data point. Each sparrow individual represents a set of candidate points. The sparrow individual updates its position according to its fitness. The fitness function Fitness It can be expressed as: in, R represents the maximum inscribed circle radius, P is a penalty term, which indicates the degree of deviation between the candidate point set and the circle. The smaller the penalty term, the smaller the deviation of the candidate point from the circle, and the better the coverage of the contour points by the circle. For each contour point I(x,y) , calculate its distance to the current center O(a, b) Distance d i : Calculate contour points I The difference Δd between the distance to the center of the circle and the radius of the largest inscribed circle: Penalty P It can be expressed as: in, m is the total number of contour points, that is, the total number of edge points; The sparrow algorithm searches for the optimal center position and the most suitable candidate point set by simulating group foraging behavior. Q i }Establish Voronoi picture, Voronoi The graph divides the space into multiple regions, each of which corresponds to a candidate point Q i , the distance between all points in the area Q i Recently; Calculate Voronoi The distance from the vertex to the candidate point, each Voronoi A vertex is a potential center of a circle, so calculating each Voronoi The distance from the vertex to the candidate point, the maximum value is the maximum inscribed circle radius max { VD i }, its corresponding Voronoi The vertex is the center of the largest inscribed circle; The diameter of the largest inscribed circle 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
A sunflower disc size measuring method
CN109360236A
Method and system for detecting high and low refractive indexes of glass beads
CN112710632A
Regional power distribution network load demand hybrid prediction method
CN113537553A
Cited By
Single cell image segmentation method based on minimum circumcircle
CN120374653A
Microsphere roundness error detection method based on multi-scale hierarchical search and gradient optimization
CN121876851A