Polar coordinate and geometry constraint dynamically fused countersunk hole contour dimension extraction method
Patent Information
- Application Number
- CN202511019891.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2045-07-23
AI Technical Summary
然而,轻合金结构件机械加工后沉头孔壁往往附着或粘连不同数量、形状各异的毛刺与碎屑,孔外表面存在冷却液等异物残留;视觉检测时轻合金表面反射率不均导致孔壁一周图像灰度差异较大,且图像伴随一定数量的孤立反光噪声;此外,不同尺度的批量沉头孔加工后直径、圆度往往不一
[0033](1)本发明提出了“极坐标动态分析-四象限动态灰度增强-多模态边缘检测-异常点筛选修正-多重几何约束递归拟合-孔径分层迭代”的创新检测技术链,系统性解决了现有专利在低对比度、高噪声及复杂几何场景下的精度不足、鲁棒性差及效率低下等核心问题,通过场景驱动的技术协同与几何约束强化,在轻合金高反光、碎屑附着、灰度不均等复杂耦合工况下稳定实现检测精度、效率与鲁棒性的同步突破,达到亚像素级检测标准,为复杂轻合金结构件尺寸测量应用场景提供了系统性解决方案;
Smart Images

Figure CN121053063B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision and precision measurement technology, and in particular relates to a method for extracting the contour dimensions of countersunk holes by dynamically fusing polar coordinates and geometric constraints. Background Technology
[0002] In aerospace, automotive manufacturing, and precision instrumentation, lightweight alloy structural components made of aluminum, magnesium, and titanium alloys are widely used. Taking aerospace vehicle hulls as an example, their outer surfaces feature numerous conical or cylindrical countersunk holes. These countersunk holes typically have multiple concentric diameters and are through-holes. The design precision requirements for the internal and external hole dimensions are high, and manufacturing accuracy directly impacts assembly reliability and product performance. Therefore, rigorous dimensional measurement of the countersunk holes and other structures after machining is essential for ensuring high-quality development and production of lightweight alloy structural components such as hulls.
[0003] When dealing with the inspection of countersunk holes in a large number of high-precision light alloy structural components, the traditional measuring tools or inspection systems such as calipers and coordinate measuring machines have revealed many drawbacks: (a) Caliper operation and accuracy assessment are highly dependent on personnel experience; (b) Coordinate measuring machines are difficult to adapt to measurement scenarios such as small-diameter inner holes and outer diameters of surface tapered holes; (c) Traditional contact measuring tools are prone to scratching the oxide layer on the hole wall, accelerating corrosion at the scratches, and causing irreversible damage; (d) In the scenario of inspecting a large number of full-form and position dimensional items, the degree of automation is low, the time is long, and the labor intensity of personnel is high; (e) Quality result data relies on manual copying and cannot be directly interconnected with the information-based quality management platform. Once a quality problem occurs, traceability is difficult and the cycle is long.
[0004] To address the shortcomings of traditional inspection methods, non-contact visual inspection technology for aperture has been extensively studied and applied in industrial manufacturing. However, after machining, the countersunk hole walls of light alloy structural parts often have varying numbers and shapes of burrs and debris adhering to or sticking to them, and foreign matter such as coolant may remain on the outer surface of the hole. During visual inspection, the uneven reflectivity of the light alloy surface leads to significant differences in image grayscale around the hole wall, and the image is accompanied by a certain amount of isolated reflective noise. In addition, the diameter and roundness of countersunk holes of different sizes often vary after machining. After extensive review and comparison, existing patents have many shortcomings in the process of detecting aperture-related dimensions in complex geometric scenarios with foreign matter adhesion, uneven surface reflectivity, noise interference, and varying sizes.
[0005] In particular, in the process of batch visual measurement of the inner and outer diameters of countersunk holes, there are many interference factors coupled, such as the existence of partial holes, the uneven gray scale of the hole wall, the similar gray scale burr debris, the unclear noise of the hole outer processing texture, and the like. However, the prior art lacks a solution that can eliminate many pseudo-edges to ensure sub-pixel level fitting accuracy and also consider the different states of the hole to ensure dynamic detection efficiency in the scene of large-batch hole processing size measurement. SUMMARY
[0006] The technical problem solved by the present application is to overcome the shortcomings of the prior art and provide a polar coordinate and geometric constraint dynamic fusion countersunk hole profile size extraction method, which has the comprehensive advantages of strong scene adaptability, high measurement accuracy and robustness, and strong flexible expansion.
[0007] The present application is achieved by the following technical scheme: a polar coordinate and geometric constraint dynamic fusion countersunk hole profile size extraction method, comprising: step S1: pre-processing a preset countersunk hole original image to obtain a pre-center point; step S2: performing polar coordinate transformation with the pre-center point as the pole point to obtain a polar coordinate image, and performing morphological opening operation on the polar coordinate image; step S3: dividing the polar coordinate image to obtain four quadrant sub-regions, obtaining corresponding countersunk hole inner hole reference edge points in each quadrant sub-region, and enhancing the contrast of the countersunk hole inner hole edge of each quadrant sub-region to obtain an enhanced contrast polar coordinate image; step S4: scanning the enhanced contrast polar coordinate image row by row to extract an initial edge point set of the countersunk hole inner hole; step S5: dividing the initial edge point set of the countersunk hole inner hole into multiple intervals, locating abnormal intervals, screening and correcting abnormal edge points in the abnormal intervals, and obtaining a corrected edge point set of the countersunk hole inner hole; step S6: inversely mapping the corrected edge point set of the countersunk hole inner hole from the polar coordinate space to the Cartesian space; step S7: fitting and outputting the inner hole edge profile of the countersunk hole with the corrected edge point set inversely mapped to the Cartesian space, and obtaining the inner hole center, the inner hole diameter and the inner hole roundness of the countersunk hole in combination with the preset object / image resolution; and step S8: performing mask processing on the inner hole envelope region in the preset countersunk hole original image, taking the inner hole center as the pole point, and performing steps S2 to S7 to obtain the outer hole center, the outer hole diameter and the outer hole roundness of the countersunk hole, and the coaxiality of the inner hole and the outer hole of the countersunk hole.
[0008] In the above-mentioned method for extracting the profile size of countersunk holes by dynamically fusing polar coordinates and geometric constraints, the preprocessing includes generating a dynamic blur kernel, strengthening the connected domain of the through hole through mean blurring and Otsu's inverse binarization, and filtering valid profiles and calculating the pre-center point based on a three-level verification mechanism. The three-level verification mechanism includes geometric containment detection, centroid approximation sorting, and zero-moment derivation of the geometric center. Geometric containment detection verifies whether the profile encloses the candidate region for the pre-center point; centroid approximation sorting sorts the profiles by their Euclidean distance from the centroid and selects the closest profile; and zero-moment derivation of the geometric center calculates the pre-center point using the zero-moment and first-moment of the profile.
[0009] In the above method for extracting the countersunk hole contour dimensions by dynamically fusing polar coordinates and geometric constraints, the dynamic fuzzy kernel size is obtained using the following formula:
[0010] Size=max(151,0.2×min(W,H));
[0011] Where W and H are the width and height of the original image of the countersunk hole, respectively, and Size is the size of the dynamic blur kernel.
[0012] In the above method for extracting the countersunk hole contour dimensions by dynamically fusing polar coordinates and geometric constraints, in step S2, the polar coordinate transformation is based on the pre-center point (x... c ,y c Let (x, y) be the pole. Transform any pixel (x, y) in the Cartesian coordinate system into its polar radius ρ and polar angle θ; where the polar radius ρ and polar angle θ are obtained using the following formulas:
[0013]
[0014] Where, x c Let y be the x-coordinate of the pre-center point. c Let x be the ordinate of the pre-center point, y be the abscissa of any pixel, ρ be the polar radius of the pixel after polar coordinate transformation, and θ be the polar angle of the pixel after polar coordinate transformation.
[0015] In the above-mentioned method for extracting the countersunk hole contour dimensions by dynamically fusing polar coordinates and geometric constraints, in step S3, the four-quadrant sub-region division is defined as follows: Quadrant 1: y∈[0,H / 4), corresponding to 0°~-90° in the original image; Quadrant 2: y∈[H / 4,H / 2), corresponding to -90°~-180° in the original image; Quadrant 3: y∈[H / 2,3H / 4), corresponding to -180°~-270° in the original image; Quadrant 4: y∈[3H / 4,H), corresponding to -270°~0° in the original image; where H is the height of the original image of the countersunk hole.
[0016] In the above-mentioned method for extracting the contour size of countersunk holes by dynamically fusing polar coordinates and geometric constraints, the pre-center point is used as the origin, and a 1×3 window is taken row by row along the X+ direction to calculate the Sobel gradient magnitude and local standard deviation. The first non-zero pixel of each row is obtained, and multimodal edge detection is performed to extract the corresponding reference edge points of the countersunk hole in each quadrant sub-region. A 1×3 window is taken, and the polar coordinate image after contrast enhancement is scanned row by row to calculate the Sobel gradient magnitude and local standard deviation. The first non-zero pixel of each row is obtained to extract the initial edge point set of the countersunk hole.
[0017] In the above method for extracting countersunk hole contour dimensions by dynamically fusing polar coordinates and geometric constraints, the fusion weights of the Sobel gradient and local standard deviation are obtained using the following formula:
[0018] F = α × G + (1 - α) × σ;
[0019] Where F is the fusion weight of Sobel gradient magnitude G and local standard deviation σ, G is Sobel gradient magnitude, σ is local standard deviation, and α is the fusion weight coefficient.
[0020] In the above method for extracting the outline size of countersunk holes by dynamically fusing polar coordinates and geometric constraints, the contrast of the inner hole edge of the countersunk hole in each quadrant sub-region is enhanced by inversely amplifying the grayscale of all pixels in each quadrant sub-region according to the reference grayscale of the inner hole edge point.
[0021] In the above method for extracting the contour dimensions of countersunk holes by dynamically fusing polar coordinates and geometric constraints, in step S5, the initial edge point set of the inner hole of the countersunk hole is divided into 12 angular intervals around the original image of the countersunk hole, and the number of edge points N in each angular interval is counted. i An interval is defined as an abnormal interval if the number of points exceeds 1.2 times the average number of points in a unit interval. For each point in an abnormal interval, the local slope of the five points before and after it is calculated. If the local slope is less than tan75°, it is defined as a pseudo-edge point.
[0022] In the above-mentioned method for extracting the countersunk hole contour size by dynamically fusing polar coordinates and geometric constraints, step S7, which involves fitting the corrected edge point set mapped to Cartesian space to output the inner hole edge contour of the countersunk hole, includes: selecting 5 pre-selected points from the corrected edge point set for fitting; performing geometric angle verification on the 5 pre-selected points, wherein the verification rule is that at least 2 or more pre-selected points have an included angle > 80°, and all pre-selected points have an included angle > 4°. If the condition is met, the process continues; otherwise, iterative selection is performed again from the corrected edge point set; a dynamically recursive decreasing inner point threshold is adopted, with an initial inner point threshold of 95%, recursively shrinking to 85%, and a maximum of 100 iterations. During the fitting process, it is determined whether the inner points satisfy the ellipse equation error and geometric center offset tolerance. If both are satisfied, the fitting is defined as successful; otherwise, the fitting is re-fitted.
[0023] In the above method for extracting the countersunk hole profile dimensions by dynamically fusing polar coordinates and geometric constraints, in step S7, the inner diameter of the countersunk hole is obtained by the following formula:
[0024]
[0025] Where D is the inner diameter of the countersunk hole, a and b are the major and minor axes of the fitted ellipse profile of the corresponding hole diameter, and k is the object / image resolution;
[0026] The roundness of the countersunk hole's inner hole is obtained using the following formula:
[0027] δ=max(ρ i )-min(ρ i );
[0028] Where δ is the roundness of the countersunk hole inner hole, ρ i The polar radius from the edge point to the center of the ellipse;
[0029] The coaxiality of the inner and outer holes of a countersunk hole is obtained by the following formula:
[0030] f = Δ1 × k;
[0031] Where f is the coaxiality of the inner and outer holes of the countersunk hole, Δ1 is the Euclidean deviation distance between the centers of the inner and outer holes of the countersunk hole, and k is the object / image resolution.
[0032] Compared with the prior art, the present invention has the following advantages:
[0033] (1) This invention proposes an innovative detection technology chain of “polar coordinate dynamic analysis - four-quadrant dynamic grayscale enhancement - multimodal edge detection - anomaly point screening and correction - multiple geometric constraint recursive fitting - aperture layered iteration”, which systematically solves the core problems of existing patents such as insufficient accuracy, poor robustness and low efficiency in low contrast, high noise and complex geometric scenes. Through scene-driven technology collaboration and geometric constraint enhancement, it can stably achieve simultaneous breakthroughs in detection accuracy, efficiency and robustness under complex coupled conditions such as high reflectivity of light alloy, debris adhesion and uneven grayscale, and reach the sub-pixel level detection standard, providing a systematic solution for the application scenario of dimensional measurement of complex light alloy structural parts;
[0034] (2) The present invention designs a polar coordinate dynamic analysis framework, which transforms the ring edge detection into a linear scanning problem through polar coordinate transformation, breaking through the limitations of traditional Cartesian space and significantly reducing the algorithm complexity;
[0035] (3) This invention proposes a four-quadrant fusion dynamic gray-scale enhancement and multimodal edge detection method to achieve regional adaptive low-contrast edge enhancement, compensate for the uneven reflectivity of light alloy surfaces, and avoid local distortion caused by global threshold. In low-contrast regions with gray-scale difference <25, the edge detection rate is significantly higher than that of the traditional Canny algorithm. It breaks through the limitation of the traditional Canny algorithm relying on a single gradient magnitude, solves the problem of low-contrast edge breakage of light alloys, and improves the edge detection rate to 98% in low-contrast scenes.
[0036] (4) The present invention designs a strategy of “12 interval abnormal distribution statistics + mirror symmetry correction”, which effectively preserves the real geometric features. The success rate of detecting false edges such as burrs and debris is greater than 96%, which is significantly better than the single morphological operation of existing patents. The edge continuity error after geometric mirror symmetry repair is less than 1 pixel. The pre-interval statistics and slope screening replace the traditional outlier removal mechanism after fitting, which fully eliminates the interference of outlier noise on contour fitting.
[0037] (5) This invention proposes a "multiple geometric constraint verification + dynamic recursive fitting" algorithm, which breaks through the blind sampling defect of traditional methods. Under 20% noise interference, the robustness and convergence speed of contour fitting are significantly better than the traditional least squares RANSAC fitting method.
[0038] (6) The present invention adopts the mask iterative polar coordinate layered analysis method, which generates a binary mask by fitting an ellipse with the inner diameter and performs a second polar coordinate transformation on the outer diameter region. This breaks through the bottleneck of inner and outer diameter interference in the single detection framework of the existing patent, realizes the priority locking of the inner diameter and the simultaneous elimination of the dynamic interference of the outer diameter, and can be extended to support the detection of three-level stepped holes.
[0039] (7) The present invention constructs a dynamic fuzzy kernel to solve the problem of interference suppression of through holes of different sizes and automatically and quickly determines the geometric center of the countersunk hole. Attached Figure Description
[0040] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0041] Figure 1 This is a flowchart of the countersunk hole contour size extraction method based on dynamic fusion of polar coordinates and geometric constraints provided in this embodiment of the invention;
[0042] Figure 2 This is a schematic diagram of a countersunk hole provided in an embodiment of the present invention;
[0043] Figure 3This is a schematic diagram of an implementation scheme of S1 provided in this embodiment of the invention;
[0044] Figure 4 This is a schematic diagram illustrating the implementation of S2 and S3 provided in the embodiments of the present invention;
[0045] Figure 5 This is a schematic diagram illustrating the implementation of S4 and S5 provided in the embodiments of the present invention;
[0046] Figure 6 This is a schematic diagram of an implementation scheme of S6 provided in this embodiment of the invention;
[0047] Figure 7 This is a schematic diagram illustrating an implementation of S7 provided in an embodiment of the present invention;
[0048] Figure 8 This is a schematic diagram illustrating an implementation of S8 provided in an embodiment of the present invention;
[0049] Figure 9 This is a schematic diagram illustrating an implementation of S8 provided in an embodiment of the present invention;
[0050] Figure 10 This is a schematic diagram illustrating an implementation of S8 provided in an embodiment of the present invention;
[0051] Figure 11 This is a schematic diagram illustrating an implementation of S8 provided in an embodiment of the present invention. Detailed Implementation
[0052] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the disclosure to those skilled in the art. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0053] Figure 1 This is a flowchart of a method for extracting the contour dimensions of a countersunk hole by dynamically fusing polar coordinates and geometric constraints, as provided in an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0054] S1: Preprocess the input original image of the countersunk hole to locate the pre-center point;
[0055] S2: Perform polar coordinate transformation with the pre-center point as the pole, and perform morphological opening operation on the polar coordinate image;
[0056] S3: Divide the polar coordinate image into four quadrant sub-regions, obtain the reference grayscale of the corresponding countersunk hole inner hole edge points in each quadrant sub-region, and adaptively and dynamically enhance the contrast of the inner hole edge in each quadrant sub-region to obtain the polar coordinate image after contrast enhancement.
[0057] S4: Extract the initial edge point set of the countersunk hole from the polar coordinate image after progressive scanning to enhance contrast;
[0058] S5: Divide the edge point set into multiple intervals, statistically locate abnormal intervals, filter and correct abnormal edge points to obtain the corrected edge point set of the countersunk hole inner hole;
[0059] S6: Inversely map the corrected edge point set of the countersunk hole from polar coordinate space to Cartesian space;
[0060] S7: Fit the corrected edge point set that has been inversely mapped to Cartesian space to output the inner edge contour of the countersunk hole, and combine the object / image resolution to obtain the center, inner diameter and roundness of the inner hole of the countersunk hole.
[0061] S8: Mask the inner hole envelope region in the preset original image of the countersunk hole, and take the center of the inner hole as the pole. Then, execute steps S2 to S7 to obtain the center of the outer hole, the outer diameter and its roundness, and the coaxiality of the inner and outer holes of the countersunk hole.
[0062] In step S1, the preprocessing includes generating a dynamic blur kernel, strengthening the via connected regions through mean blurring and Otsu's inverse binarization, and filtering valid contours and calculating pre-center points based on a three-level verification mechanism. The blur kernel size is dynamically set according to the original image size, being 0.2 times the shorter side of the image and not less than 151 pixels, as shown in the formula:
[0063] Size=max(151,0.2×min(W,H));
[0064] Where W and H are the width and height of the original image, and the blur kernel is forced to be an odd number to ensure symmetry; Size is the size of the dynamic blur kernel.
[0065] In step S2, the polar coordinate transformation is performed with respect to the pre-center point (x c ,y c Let (x, y) be the pole. Transform any pixel (x, y) in the Cartesian coordinate system into its polar radius ρ and polar angle θ; where the polar radius ρ and polar angle θ are obtained using the following formulas:
[0066]
[0067] Where, x c Let y be the x-coordinate of the pre-center point. cLet x be the ordinate of the pre-center point, y be the abscissa of any pixel, ρ be the polar radius of the pixel after polar coordinate transformation, and θ be the polar angle of the pixel after polar coordinate transformation.
[0068] In step S3, the four-quadrant sub-region division is defined as follows: Quadrant 1: y∈[0,H / 4), corresponding to 0° to -90° in the original image; Quadrant 2: y∈[H / 4,H / 2), corresponding to -90° to -180° in the original image; Quadrant 3: y∈[H / 2,3H / 4), corresponding to -180° to -270° in the original image; Quadrant 4: y∈[3H / 4,H), corresponding to -270° to 0° in the original image; where H is the height of the original image of the countersunk hole.
[0069] In step S3, taking the pre-center point as the origin, a 1×3 window is taken row by row along the X+ direction to calculate the Sobel gradient magnitude and local standard deviation, and the first non-zero pixel of each row is obtained. Multimodal edge detection is performed to extract the corresponding countersunk hole reference edge points in each quadrant sub-region. In step S4, a 1×3 window is taken, and the polar coordinate image after contrast enhancement is scanned row by row to calculate the Sobel gradient magnitude and local standard deviation, and the first non-zero pixel of each row is obtained to extract the initial edge point set of the countersunk hole.
[0070] The method for extracting the edge points of the countersunk hole is to take a 1×3 window along the X+ direction row by row, calculate the Sobel gradient magnitude G and the local standard deviation σ, and use the fusion weight formula F = 0.5G + 0.5σ to calculate the first non-zero pixel of each row. Gradient and standard deviation fusion weight formula:
[0071] F = α × G + (1 - α) × σ;
[0072] Where α is the fusion weight coefficient, α∈[0.3,0.7], which is dynamically adjusted according to the material characteristics of the countersunk hole; F is the fusion weight of Sobel gradient magnitude G and local standard deviation σ, where G is the Sobel gradient magnitude and σ is the local standard deviation.
[0073] In step S3, adaptively and dynamically enhancing the contrast of the inner hole edges in each quadrant sub-region means that the grayscale of all pixels in each quadrant sub-region is inversely amplified according to the reference grayscale of the inner hole edge point. The specific formula is as follows:
[0074]
[0075] Where i represents the quadrant sub-region number, G i I is the reference gray value for the inner hole edge point of this quadrant sub-region. i (row,col) represents the original grayscale value of any pixel within this quadrant sub-region, I i ′(row, col) is the dynamically enhanced gray value of any pixel in the quadrant sub-region, where row is the row number of the pixel, and col is the column number of the pixel.
[0076] In step S5, the initial edge point set of the inner hole of the countersink is divided into 12 angular intervals along the circumference of the original image of the countersink, and the number N of edge points in each angular interval is counted i , where an interval with the number of points exceeding 1.2 times the mean value of the number of points per unit interval is determined as an abnormal interval, and the formula is as follows:
[0077]
[0078] where i is the index serial number of the 12 angular intervals, N i is the number of edge points in the i-th angular interval; j is the interval index serial number value of the abnormal interval, N j is the number of edge points in the abnormal interval.
[0079] For any point P in the abnormal interval k , calculate the local slope formed by the two points whose ranks in the initial edge point set are k-5 and k+5 respectively:
[0080]
[0081] where k is the index serial number of any point P in the abnormal interval in the initial edge point set, s k is the index serial number of the initial edge point set k is the local slope formed by the 5 points before and after P k , y k:5 is the ordinate of the edge point whose index serial number in the initial edge point set is k+5, x k:5 is the abscissa of the edge point whose index serial number in the initial edge point set is k+5, y k;5 is the ordinate of the edge point whose index serial number in the initial edge point set is k-5, x k;5 is the abscissa of the edge point whose index serial number in the initial edge point set is k-5.
[0082] If s k < tan(75°), the point is determined as a false edge point, and is replaced with the mirror point (x with the center line y=H / 2 in the polar coordinate image as the symmetry axis k , H-y k ), so as to generate a corrected point set; where x k is the abscissa of any point P in the abnormal interval k , y k is the ordinate of any point P in the abnormal interval k .
[0083] In step S7, the implementation steps of fitting the corrected edge point set to output the edge contour of the inner hole of the countersink are as follows:
[0084] (a) First, the geometric angles of the 5 pre-selected points for ellipse fitting are checked. The check rule is that at least 2 points have an angle > 80° and all pre-selected points have an angle > 4°. If the condition is met, continue; otherwise, iterate from the corrected edge point set again.
[0085] (b) Improved least-squares RANSAC ellipse fitting employs a dynamically recursive decreasing inlier threshold. The initial inlier threshold is 95%, recursively shrinking to 80%, with a maximum of 100 iterations. During the fitting process, the inlier points satisfy the ellipse equation error and geometric center offset tolerance. The formula for the ellipse equation error is:
[0086]
[0087] Where, x j Let y be the x-coordinate of the j-th interior point. j Let x be the ordinate of the j-th interior point. e Let y be the x-coordinate of the center point of the fitted ellipse. e Let y be the ordinate of the center point of the fitted ellipse, a be the length of the major semi-axis of the ellipse, b be the length of the minor semi-axis of the ellipse, and j be the index number of the point inside the fitted ellipse.
[0088] The geometric center offset tolerance is defined as the Euclidean distance Δ0 between the fitted center and the pre-center ≤ 1. If both conditions are met, the fitting is considered successful; otherwise, the fitting is refitted.
[0089] The formulas for calculating the inner and outer diameters of countersunk holes are:
[0090]
[0091] Where a and b are the major and minor axes of the corresponding aperture fitting ellipse profile, and k is the object / image resolution (mm / pixel).
[0092] The formula for calculating the roundness of countersunk holes is:
[0093] δ=max(ρ i )-min(ρ i );
[0094] Where, ρ i It is the polar radius from the edge point to the center of the ellipse.
[0095] The formula for calculating the coaxiality of countersunk holes is:
[0096] f = Δ1 × k;
[0097] Where Δ1 is the Euclidean deviation distance between the centers of the inner and outer holes of the countersunk hole, and k is the object / image resolution (mm / pixel).
[0098] The three-level verification mechanism includes geometric inclusiveness testing, centroid approximation sorting, and zero-order moment derivation of the geometric center.
[0099] in:
[0100] (a) Geometric Enclosure Detection: Verify whether the contour encloses the candidate region for the precenter point;
[0101] (b) Centroid Approximation Sort: Sort by Euclidean distance between the centroid and candidate points, and select the closest contour first;
[0102] (c) Derivation of the zeroth moment: Geometric center: The zeroth moment M through the profile 00 and first moment M 10 M 01 Calculate the precise geometric center:
[0103]
[0104] Where, x c Let y be the x-coordinate of the pre-center point. c M is the ordinate of the pre-center point. 10 M is the sum of the x-coordinates of all pixels in the outline. 01 M is the sum of the ordinates of all pixels in the contour. 00 The total number of pixels in the outline;
[0105] The pre-center point (x) was finally determined. c ,y c ), which serves as the pole of the polar coordinate transformation during the subsequent calculation of the inner diameter of the countersunk hole.
[0106] Specifically, taking a countersunk hole as the object of description in this embodiment, in Figure 1 Under the overall process diagram, combined with Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8 , Figure 9 , Figure 10 , Figure 11 Detailed description of the implementation steps of the method of the present invention:
[0107] S1: Preprocess the input original image of the countersunk hole to locate the pre-center point O1. Figure 3 This includes generating a dynamic blur kernel, strengthening the via connectivity through mean blurring and Otsu's inverse binarization, and filtering effective contours and calculating the pre-center point O1 based on a three-level verification mechanism. Figure 3 The three-level verification mechanism includes geometric inclusiveness testing, centroid approximation sorting, and zero-order moment derivation of the geometric center. Among these:
[0108] (a) Geometric Enclosure Detection: Verify whether the contour encloses the candidate region for the precenter point;
[0109] (b) Centroid Approximation Sort: Sort by Euclidean distance between the centroid and candidate points, and select the closest contour first;
[0110] (c) Derivation of the zeroth moment: Geometric center: The zeroth moment M through the profile 00 and first moment M 10 M 01 Calculate the precise geometric center:
[0111]
[0112] Finally, the pre-center point O1(x) was determined. c ,y c ()( Figure 3 The polar coordinate transformation is used as the pole for subsequent calculation of the countersunk hole inner diameter; the fuzzy kernel size is dynamically set according to the original image size, which is 0.2 times the shorter side of the image and not less than 151 pixels, and the formula is:
[0113] Size=max(151,0.2×min(W,H));
[0114] Where W and H are the width and height of the original image, and the blur kernel is forced to be an odd number to ensure symmetry.
[0115] S2: with the pre-center point O1 ( Figure 4 A polar coordinate transformation is performed with the pole as the reference point, and a morphological opening operation is performed on the polar coordinate image. The polar coordinate transformation is performed with the pre-center point O1(x) as the reference point. c ,y c ()( Figure 4 Let ρ be the pole, and map the Cartesian coordinates to the polar radius ρ and polar angle θ:
[0116]
[0117] S3: Divide the polar coordinate image into four quadrant sub-regions: I, II, III, and IV. Figure 4 ):
[0118] Quadrant I ( Figure 4 ): y∈[0,H / 4), corresponding to 0°~-90° in the original image;
[0119] Quadrant II ( Figure 4 ): y∈[H / 4,H / 2), corresponding to -90°~-180° of the original graph;
[0120] Quadrant III Figure 4 ): y∈[H / 2,3H / 4), corresponding to -180°~-270° of the original graph;
[0121] Quadrant IV ( Figure 4 ): y∈[3H / 4,H), corresponding to the original graph -270°~0°.
[0122] Where H is the height of the original image, and the corresponding countersunk hole inner hole edge points P1, P2, P3, P4, and P5 in each quadrant sub-region are obtained. Figure 4 The reference grayscale is used to dynamically enhance the contrast of the inner hole edges in each quadrant sub-region. Specifically, the grayscale of all pixels in each quadrant sub-region is inversely amplified according to the reference grayscale of the corresponding inner hole edge point. The specific formula is as follows:
[0123]
[0124] Where i represents the quadrant sub-region number, G i I is the reference gray value for the inner hole edge point of this quadrant sub-region. i (row,col) represents the original grayscale value of any pixel within this quadrant sub-region, I i ′ (row,col) represents the dynamically enhanced grayscale value of any pixel within this quadrant sub-region, where row is the row number of the pixel and col is the column number of the pixel.
[0125] S4: Extract the initial edge point set of the countersunk hole inner hole by scanning the polar coordinate image line by line. The method is to take a 1×3 window along the X+ direction line by line, calculate the Sobel gradient magnitude G and the local standard deviation σ, and use the fusion weight formula F = 0.5G + 0.5σ to calculate the first non-zero pixel of each line. Gradient and standard deviation fusion weight formula:
[0126] F = α × G + (1 - α) × σ;
[0127] Where α is the fusion weight coefficient, α∈[0.3,0.7], which is dynamically adjusted according to the material properties of the countersunk hole.
[0128] S5: Divide the edge point set into 12 intervals: A1, A2, A3, A4, A5, A6, A7, A8, A9, A 10 A 11 A 12 ( Figure 5 ), statistically locate the abnormal intervals Q1 and Q2 ( Figure 5 ), filter and correct abnormal edge points Q1. ′ Q2 ′ ( Figure 5 The specific implementation method is as follows:
[0129] (a) Divide the initial edge point set P0 into 12 angular intervals A1, A2, A3, A4, A5, A6, A7, A8, A9, A1 according to the 360° circumference of the original image aperture. 10 A11 , A 12 ( Figure 5 ), counting the number N of edge points in each angle interval i , wherein an interval with the number of points exceeding 1.2 times the mean value of the number of points in the unit interval is determined as abnormal intervals Q1, Q2( Figure 5 ), and the formula is as follows:
[0130]
[0131] (b) For each point p in the abnormal interval k , calculate the local slope of its 5 preceding and succeeding points:
[0132]
[0133] If s k <tan(75°), it is determined as a false edge point, and is replaced with a mirror point (x taking the center line y=H / 2 of the polar coordinate image as the symmetry axis k , H-y k ), so as to generate corrected point sets Q1 ′ , Q2 ′ ( Figure 5 ).
[0134] S6: Inversely map the corrected edge point set of the inner hole of the countersunk head hole from the polar coordinate space to the Cartesian space.
[0135] S7: Fit the corrected edge point set to output the edge contour of the inner hole of the countersunk head hole, and obtain the center O2 of the inner hole of the countersunk head hole in combination with the object / image resolution( Figure 7 ), the inner diameter and the roundness, the implementation steps are as follows:
[0136] (a) First, perform geometric angle verification on 5 preselected points for ellipse fitting, the verification rule is that the included angle between at least 2 or more points is >80°, and the included angles of all preselected points are >4°, if the conditions are met, proceed, otherwise iteratively select again from the corrected edge point set;
[0137] (b) The improved least square RANSAC ellipse fitting adopts a dynamically recursive decreasing inlier threshold, the initial inlier threshold is 95%, the recursion shrinks to 80%, with a maximum of 100 iterations. The inliers in the fitting process satisfy the ellipse equation error and the geometric center offset tolerance, wherein the ellipse equation error formula is:
[0138]
[0139] The geometric center offset tolerance is defined as that the Euclidean distance Δ0 between the fitting center and the pre-center is ≤1, if both conditions are met, the fitting is defined as successful, otherwise the fitting is performed again.
[0140] S8: Masking the inner hole envelope region in the original image of the countersunk hole, with the inner hole center O2 ( Figure 8 Using the pole as the reference point, the process of polar coordinate transformation, edge point set extraction and correction, and edge contour fitting is repeated to obtain the geometric dimensions of the countersunk hole, including the center, outer diameter, roundness, and coaxiality of the inner and outer holes. The formula for calculating the countersunk hole diameter is:
[0141]
[0142] Where a and b are the major and minor axes of the corresponding aperture fitting ellipse profile, and k is the object / image resolution (mm / pixel);
[0143] The formula for calculating the roundness of countersunk holes is:
[0144] δ=max(ρ i )-min(ρ i );
[0145] Where, ρ i The extreme diameter is the distance from the edge point to the center of the ellipse; the formula for calculating the coaxiality of the countersunk hole is...
[0146] f = Δ1 × k;
[0147] Where Δ1 is the Euclidean deviation distance between the centers of the inner and outer holes of the countersunk hole, and k is the object / image resolution (mm / pixel).
[0148] This embodiment proposes an innovative detection technology chain of "polar coordinate dynamic analysis - four-quadrant dynamic grayscale enhancement - multimodal edge detection - outlier point screening and correction - multiple geometric constraint recursive fitting - aperture layered iteration". It systematically solves the core problems of existing patents, such as insufficient accuracy, poor robustness and low efficiency in low contrast, high noise and complex geometric scenes. Through scene-driven technology synergy and geometric constraint enhancement, it stably achieves simultaneous breakthroughs in detection accuracy, efficiency and robustness under complex coupled conditions such as high reflectivity of light alloys, debris adhesion and grayscale unevenness, and reaches the sub-pixel level detection standard. It provides a systematic solution for the application scenario of dimensional measurement of complex light alloy structural parts.
[0149] This embodiment designs a polar coordinate dynamic analysis framework, transforming ring edge detection into a linear scanning problem through polar coordinate transformation, overcoming the limitations of traditional Cartesian space and significantly reducing algorithm complexity. This embodiment proposes a four-quadrant fusion dynamic grayscale enhancement and multimodal edge detection method to achieve region-adaptive low-contrast edge enhancement, compensating for uneven reflectivity on light alloy surfaces, and avoiding local distortion caused by global thresholds. In low-contrast regions with a grayscale difference <25, the edge detection rate is significantly higher than the traditional Canny algorithm. It overcomes the limitation of the traditional Canny algorithm relying on a single gradient magnitude, solving the problem of low-contrast edge breakage in light alloys, and improving the edge detection rate to 98% in low-contrast scenes. This embodiment designs a "12-interval anomaly distribution statistics + mirror symmetry correction" strategy, effectively preserving true geometric features, with a successful detection rate of over 96% for false edges such as burrs and debris, significantly better than the single-morphology approach of existing patents. The algorithm, based on geometric mirror symmetry repair, achieves an edge continuity error of less than 1 pixel. It replaces the traditional outlier removal mechanism after fitting with pre-interval statistics and slope filtering, effectively eliminating interference from outlier noise in contour fitting. This embodiment proposes a "multiple geometric constraint verification + dynamic recursive fitting" algorithm, overcoming the blind sampling defects of traditional methods. Under 20% noise interference, the contour fitting robustness and convergence speed are significantly better than the traditional least-squares RANSAC fitting method. This embodiment employs a mask iterative polar coordinate hierarchical analysis method, using an inner diameter-fitted ellipse to generate a binary mask and a quadratic polar coordinate transformation of the outer diameter region. This overcomes the bottleneck of inner and outer diameter interference in the single-detection framework of existing patents, achieving simultaneous inner diameter priority locking and outer diameter dynamic interference elimination, and can be extended to support three-level stepped hole detection. This embodiment constructs a dynamic fuzzy kernel to solve the interference suppression problem of through holes of different sizes, automatically and quickly determining the geometric center of countersunk holes.
[0150] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications to the technical solutions of the present invention by utilizing the methods and techniques disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solutions of the present invention shall fall within the protection scope of the technical solutions of the present invention.
Claims
1. A method for extracting the profile dimensions of countersunk holes by dynamically fusing polar coordinates and geometric constraints, characterized in that... include: Step S1: Preprocess the original image of the countersunk hole to obtain the pre-center point; Step S2: Perform polar coordinate transformation with the pre-center point as the pole to obtain a polar coordinate image, and perform morphological opening operation on the polar coordinate image; Step S3: Divide the polar coordinate image into four quadrant sub-regions, obtain the corresponding countersunk hole inner hole reference edge points in each quadrant sub-region, and enhance the contrast of the countersunk hole inner hole edges in each quadrant sub-region to obtain a polar coordinate image with enhanced contrast. Step S4: Extract the initial edge point set of the countersunk hole from the polar coordinate image after line-by-line scanning to enhance contrast; Step S5: Divide the initial edge point set of the countersunk hole into multiple intervals, statistically locate abnormal intervals, filter and correct abnormal edge points in abnormal intervals, and obtain the corrected edge point set of the countersunk hole. Step S6: Inversely map the corrected edge point set of the countersunk hole from polar coordinate space to Cartesian space; Step S7: Fit the corrected edge point set that has been inversely mapped to Cartesian space to output the inner edge contour of the countersunk hole, and combine it with the preset object / image resolution to obtain the inner center, inner diameter and inner roundness of the countersunk hole. Step S8: Mask the inner hole envelope region in the preset original image of the countersunk hole, and take the center of the inner hole as the pole. Then, execute steps S2 to S7 to obtain the outer hole center, outer hole diameter, outer hole roundness, and coaxiality of the inner and outer holes of the countersunk hole. In step S5, the initial edge point set of the countersunk hole is divided into 12 angular intervals according to the original image of the countersunk hole, and the number of edge points in each angular interval is counted. An interval is considered abnormal if the number of points exceeds 1.2 times the average number of points in the unit interval. For each point within the abnormal interval, calculate the local slope of the five points before and after it. If the local slope is less than... If so, it is determined to be a false edge point; In step S7, fitting the corrected set of edge points, which has been inversely mapped to Cartesian space, to output the countersunk hole inner hole edge profile includes: Five pre-selected points are selected from the corrected edge point set for fitting. The geometric angle of the five pre-selected points is checked. The check rule is that at least two or more pre-selected points have an angle greater than 80°, and all pre-selected points have an angle greater than 4°. If the condition is met, the process continues; otherwise, the points are iteratively selected from the corrected edge point set again. A dynamic recursive gradually decreasing in-point threshold is adopted, with an initial in-point threshold of 95%, which is recursively shrunk to 85% for a maximum of 100 iterations. During the fitting process, it is determined whether the in-points satisfy the ellipse equation error and geometric center offset tolerance. If both are satisfied, the fitting is defined as successful; otherwise, the fitting is re-fitted. In step S7, the inner diameter of the countersunk hole is obtained by the following formula: ; in, The inner diameter of the countersunk hole. and These are the major and minor axes of the fitted ellipse profile for the corresponding aperture, respectively, and k is the object / image resolution; The roundness of the countersunk hole's inner hole is obtained using the following formula: ; in, For the roundness of the countersunk hole inner hole, The polar radius from the edge point to the center of the ellipse; The coaxiality of the inner and outer holes of a countersunk hole is obtained by the following formula: ; in, To ensure the coaxiality of the inner and outer holes of the countersunk hole, denoted by Euclidean distance, which is the distance between the centers of the inner and outer holes of the countersunk hole; k is the object / image resolution.
2. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 1, characterized in that: The preprocessing includes generating a dynamic blur kernel, strengthening the via connected regions through mean blurring and Otsu inverse binarization, and filtering effective contours and calculating pre-center points based on a three-level verification mechanism. The three-level verification mechanism includes geometric containment detection, centroid approximation sorting, and zero-moment derivation of the geometric center. Geometric containment detection verifies whether the contour encloses the candidate region of the pre-center point. Centroid approximation sorting sorts the candidates by their Euclidean distance from the centroid and selects the contour that is closest to the candidate. Zero-moment derivation of the geometric center calculates the pre-center point using the zero-moment and first-moment of the contour.
3. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 2, characterized in that: The dynamic fuzzy kernel size is obtained using the following formula: ; in, and These represent the width and height of the original image of the countersunk hole, respectively. The size of the dynamic fuzzy kernel.
4. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 1, characterized in that: In step S2, the polar coordinate transformation is performed with a pre-center point. As the pole, any pixel in the Cartesian coordinate system ( Convert to polar radius and polar angle Among them, the polar radius and polar angle It can be obtained through the following formula: ; in, Let x be the x-coordinate of the pre-center point. The ordinate of the pre-center point, Let x be the x-coordinate of any pixel. Let be the y-coordinate of any pixel. This is the polar radius of the pixel after polar coordinate transformation. This is the polar angle after the polar coordinate transformation of the pixel.
5. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 1, characterized in that: In step S3, the four-quadrant sub-region division is defined as follows: Quadrant 1: Corresponding to the original image Quadrant 2: Corresponding to the original image Quadrant 3: Corresponding to the original image Quadrant 4: Corresponding to the original image ;in, The height of the original image of the countersunk hole.
6. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 1, characterized in that: Using the pre-center point as the origin, calculate the Sobel gradient magnitude and local standard deviation by taking a 1×3 window row by row along the X+ direction, and obtain the first non-zero pixel point of each row. Perform multimodal edge detection to extract the corresponding countersunk hole reference edge points in each quadrant sub-region. Take a 1×3 window, scan the polar coordinate image after contrast enhancement line by line, calculate the Sobel gradient magnitude and local standard deviation, and obtain the first non-zero pixel of each line to extract the initial edge point set of the countersunk hole.
7. The method for extracting the profile dimensions of a countersunk hole by dynamic fusion of polar coordinates and geometric constraints according to claim 6, characterized in that: The fusion weights of the Sobel gradient and the local standard deviation are obtained by the following formula: ; in, Sobel gradient magnitude With local standard deviation The fusion weight, This represents the magnitude of the Sobel gradient. For local standard deviation, For fusion weighting coefficients.
Citation Information
Patent Citations
Anchor drill hole contour extraction method and system based on contour geometric constraint
CN116152483A
Cerebral hemorrhage image processing method and device, computer device and storage medium
WO2020093566A1