A method for extracting the profile size of through-slots using multimodal partition detection and dynamic recursive fitting.

CN121053192BActive Publication Date: 2026-08-14SHANGHAI SPACE PRECISION MACHINERY RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

然而,轻合金结构件机械加工后通槽壁往往附着或粘连不同数量、形状各异的毛刺与碎屑,槽外表面存在冷却液等异物残留;通槽结构往往存在倒角或钝边,视觉检测时轻合金表面反射率不均导致槽壁一周图像灰度差异较大,且图像伴随一定数量的孤立反光噪声

Benefits of technology

[0025](1)本发明提出了“动态模糊核-四方向分区动态灰度增强-多模态边缘检测-前置异常筛选-多重几何约束递归拟合”的闭环检测技术链,系统性解决了现有专利在通槽检测中抗干扰性差、精度不足与效率低下的矛盾,显著提升了复杂噪声场景下通槽视觉检测的场景适配性、精度与鲁棒性、扩展性,达到亚像素级检测标准,为复杂轻合金结构件尺寸测量应用场景提供了系统性解决方案;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121053192B_ABST
    Figure CN121053192B_ABST
Patent Text Reader

Abstract

This invention discloses a method for extracting the contour dimensions of a through-slot using multimodal partitioning detection and dynamic recursive fitting. The method includes: preprocessing the original image of the through-slot and locating a pre-center point; extracting the midpoints of the reference edges of the four sides of the through-slot along the surrounding direction using the pre-center point as the origin; extracting independent Region of Interest (ROI) maps by partitioning the ROI maps using the midpoints of each reference edge as the center, and adaptively and dynamically enhancing the edge contrast of each ROI map; scanning each ROI map line by line to extract the initial edge point set of the corresponding direction of the through-slot; removing non-linear edge points within abnormal intervals in the initial edge point set of the ROI map; fitting edge lines to the edge point set after filtering the ROI map, and determining the first, last, and midpoints; mapping each edge line in the ROI map to the original image of the through-slot, determining the average spacing in the X / Y directions, and calculating the physical values ​​of the through-slot dimensions such as length, width, symmetry, and tilt angle deviation. This invention significantly improves the scene adaptability, accuracy, robustness, and scalability of visual detection of through-slots in complex noisy scenarios.
Need to check novelty before this filing date? Find Prior Art

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 through slots by multimodal partition detection and dynamic recursive fitting. Background Technology

[0002] Lightweight alloy structural components made of aluminum, magnesium, and titanium alloys are widely used in aerospace, automotive manufacturing, and precision instrumentation. Taking aerospace vehicle hulls as an example, their outer surfaces feature a number of through-slot structures. The dimensional accuracy of these through-slots requires high precision, and manufacturing accuracy directly impacts assembly reliability and product performance. Therefore, rigorous dimensional measurement of the machined through-slots and other structures is essential for ensuring high-quality development and production of lightweight alloy structural components such as hulls.

[0003] When dealing with the large number and high precision of through-slot inspection projects in 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 effective contact measurement of thin-walled edges; (c) Traditional contact measuring tools are prone to scratching the oxide layer of the slot wall, accelerating corrosion at the scratches, and causing irreversible damage; (d) In the scenario of large-scale full-form and position dimensional inspection projects, 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 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 has been extensively researched and applied to industrial manufacturing scenarios. However, after machining, the walls of through-slots in lightweight alloy structural parts often have varying numbers and shapes of burrs and debris attached or adhered to them, and foreign matter such as coolant may remain on the outer surface of the slot. Furthermore, through-slot structures often have chamfers or blunt edges, leading to significant grayscale differences in the image around the slot wall during visual inspection due to uneven surface reflectivity, and the images are accompanied by a certain amount of isolated reflective noise. Extensive research and comparison have revealed numerous deficiencies in the inspection of through-slot dimensions under complex geometric conditions, including foreign matter attachment, uneven reflectivity of chamfered or blunt edge surfaces, noise interference, and varying dimensions.

[0005] In particular, during the batch visual measurement of the length and width of slots, there are often multiple interference factors coupled together, such as uneven gray levels and messy, similar gray-level burrs and debris around the chamfered or blunt edges of the slots, and inconsistent brightness of the background noise of the processing texture outside the slot. However, existing technologies lack a solution that can eliminate many false edges to ensure sub-pixel-level fitting accuracy and take into account different states of the slots to ensure dynamic detection efficiency in the scenario of batch slot processing size measurement. Summary of the Invention

[0006] The technical problem solved by this invention is to overcome the shortcomings of the prior art and provide a method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting, which has the comprehensive advantages of strong scene adaptability, high measurement accuracy and robustness, and strong flexible expansion.

[0007] The objective of this invention is achieved through the following technical solution: a method for extracting the contour size of a through-slot using multimodal partitioning detection and dynamic recursive fitting, comprising: preprocessing and locating a pre-center point in a preset original image of the through-slot; using the pre-center point as the origin, performing multimodal edge detection along four directions—X+, X-, Y+, and Y-—to extract the midpoints of the reference edges of each side of the through-slot; wherein the width direction of the through-slot is taken as the X-axis, the length direction of the through-slot as the Y-axis, and the pre-center point as the origin; and using the midpoints of the reference edges of each side of the through-slot as centers, extracting ROI maps of independently enveloping corresponding edges in the four directions—X+, X-, Y+, and Y-. Enhance the edge contrast of the ROI map; scan the ROI map line by line to extract the initial edge point set of each side of the channel in the corresponding direction, and obtain the initial edge point set of the ROI map; divide the initial edge point set of the ROI map into multiple equidistant intervals, count and locate abnormal intervals, and remove the edge points of non-linear elements to obtain the edge point set of the ROI map after filtering; for the edge point set of the ROI map after filtering, fit the edge lines of each side of the channel in the corresponding direction, and calculate the first point, last point and midpoint of the edge lines of each side of the channel in the corresponding direction; map the first point, last point and midpoint of the edge lines of each side of the channel in the corresponding direction to the original image of the channel to obtain the contour size of the channel.

[0008] In the above-mentioned method for extracting the contour size of a through-channel using multimodal partition detection and dynamic recursive fitting, the preprocessing includes generating a dynamic blur kernel, strengthening the connected components of the through-channel through-channel by mean blurring and Otsu reverse binarization, and filtering effective contours and calculating pre-center points based on a three-level verification mechanism.

[0009] In the above method for extracting the contour size of a through-slot using multimodal partitioning detection and dynamic recursive fitting, the size of the dynamic blur kernel is obtained by 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 through slot, respectively, and Size is the size of the dynamic blur kernel.

[0012] In the above-mentioned method for extracting the contour size of a through-slot using multimodal partition detection and dynamic recursive fitting, the pre-center point is used as the origin. A 1×3 window is taken row by row along the four directions of X+, X-, Y+, and Y- to calculate the Sobel gradient magnitude and local standard deviation. The first non-zero pixel of each row is then obtained. Multimodal edge detection is performed to extract the midpoint of the reference edge of each side of the through-slot. A 1×3 window is taken, and the ROI map of each direction is scanned row by row to calculate the Sobel gradient magnitude and local standard deviation. The first non-zero pixel of each row is then obtained to extract the initial edge point set of each side of the through-slot in the corresponding direction.

[0013] In the above method for extracting the through-slot profile size using multimodal partition detection and dynamic recursive fitting, the fusion weight of the Sobel gradient and the local standard deviation is obtained through the following formula:

[0014] F = α × G + (1 - α) × σ;

[0015] 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.

[0016] In the above-mentioned method for extracting the contour size of a through-slot using multimodal partitioning detection and dynamic recursive fitting, the method for extracting the ROI map includes: taking the midpoint of the reference edge as the center, extending 0.5×L0 along the X+ and X- directions respectively, and extending 0.5×W0 along the Y+ and Y- directions respectively, thereby defining an ROI map with a pixel size of L0×W0 that symmetrically encloses the reference edge of the through-slot; where L0 is the original pixel length of the through-slot and W0 is the original pixel width of the through-slot; enhancing the edge contrast of the ROI map is achieved by inversely amplifying the grayscale of all pixels in the ROI map according to the grayscale of the reference edge to which they belong.

[0017] In the above method for extracting the contour size of a through-slot using multimodal partitioning detection and dynamic recursive fitting, the number of equidistant intervals is obtained as follows:

[0018]

[0019] When m is a positive integer, there are m equal intervals; when m is not a positive integer, the number of equal intervals is the floor value of m.

[0020] Where L0 is the pixel length of the ROI image and W0 is the pixel width of the ROI image.

[0021] In the above-mentioned method for extracting the contour size of a through-slot using multimodal partition detection and dynamic recursive fitting, the number of edge points in each equidistant interval is counted. If the number of edge points exceeds 1.2 times the average number of points in a preset unit interval, it is determined to be an abnormal 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 tan85° or greater than tan5°, it is determined to be an edge point of a non-linear element.

[0022] In the above-mentioned method for extracting the contour dimensions of through-channels using multimodal partitioning detection and dynamic recursive fitting, the fitting output of the edge lines in the corresponding directions of each side of the through-channel includes: performing geometric spacing verification on the two pre-selected points used to construct the straight line fitting. The verification rule is that if the ROI map is on the X+ or X- direction side, the spacing between the two pre-selected points is >0.5×W0, and the angle between the points is >85°; otherwise, the spacing between the two pre-selected points is >0.5×L0, and the angle between all pre-selected points is <5°. If the conditions are met, the process continues; otherwise, the selection is iteratively reselected from the filtered edge point set. A dynamic recursive decreasing in-point threshold is adopted, with an initial in-point threshold of 95%, which is recursively reduced to 85% for a maximum of 50 iterations. During the fitting process, it is determined whether the in-points satisfy the linear equation residual. If they do, the fitting is defined as successful; otherwise, the fitting is re-fitted.

[0023] In the above-mentioned method for extracting the contour size of a through-slot using multimodal partitioning detection and dynamic recursive fitting, 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 for the pre-center point. Centroid approximation sorting prioritizes the closest contour by sorting the contours according to their Euclidean distance from the centroid. Zero-moment derivation of the geometric center calculates the pre-center point using the zero-moment and first-moment of the contour.

[0024] Compared with the prior art, the present invention has the following advantages:

[0025] (1) This invention proposes a closed-loop detection technology chain of “dynamic fuzzy kernel - four-directional partition dynamic grayscale enhancement - multimodal edge detection - pre-anomaly screening - multiple geometric constraint recursive fitting”, which systematically solves the contradiction of poor anti-interference, insufficient accuracy and low efficiency in the detection of through slots in existing patents. It significantly improves the scene adaptability, accuracy and robustness and scalability of through slot visual detection in complex noise scenarios, and reaches the sub-pixel level detection standard, providing a systematic solution for the application scenario of dimensional measurement of complex light alloy structural parts.

[0026] (2) This invention proposes an independent partitioned ROI fusion dynamic gray-scale enhancement and multimodal edge detection method to achieve adaptive low-contrast edge enhancement on each side of the through slot, compensate for the uneven reflectivity of the light alloy surface, avoid local distortion caused by global threshold, and achieve a significantly higher edge detection rate than the traditional Canny algorithm in the low gray-scale difference contrast area; it breaks through the limitation of the traditional Canny algorithm relying on a single gradient magnitude and solves the problem of low-contrast edge breakage of light alloy.

[0027] (3) The present invention designs a strategy of “pre-interval statistics and slope screening outlier removal”, which effectively preserves the real geometric features and removes false edges such as burrs and debris in advance. It is significantly better than the single morphological operation of the existing patents. By replacing the traditional outlier removal mechanism after fitting with pre-interval statistics and slope screening, the interference of outlier noise on contour fitting is fully eliminated.

[0028] (3) This invention proposes a "multiple geometric constraint verification + dynamic recursive fitting" algorithm, which breaks through the blind sampling defect of traditional methods. Under 30% noise interference, the robustness and convergence speed of contour fitting are significantly better than the traditional least squares RANSAC straight line fitting method.

[0029] (4) The present invention constructs a dynamic fuzzy kernel to solve the interference suppression problem of through slots of different sizes and automatically and quickly determines the geometric center of the through slot. Attached Figure Description

[0030] 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:

[0031] Figure 1 This is a flowchart of the method for extracting the contour size of a through-slot using multimodal partition detection and dynamic recursive fitting provided in an embodiment of the present invention;

[0032] Figure 2 This is a schematic diagram of the through groove provided in an embodiment of the present invention;

[0033] Figure 3 This is a schematic diagram illustrating the implementation of steps S1 and S2 provided in the embodiments of the present invention;

[0034] Figure 4 This is a schematic diagram illustrating an implementation of step S3 provided in this embodiment of the invention;

[0035] Figure 5 This is a schematic diagram illustrating the implementation of steps S3, S4, S5, and S6 provided in the embodiments of the present invention.

[0036] Figure 6 This is a schematic diagram illustrating the implementation of steps S3, S4, S5, and S6 provided in the embodiments of the present invention.

[0037] Figure 7 This is a schematic diagram illustrating the implementation of steps S3, S4, S5, and S6 provided in the embodiments of the present invention.

[0038] Figure 8 This is a schematic diagram illustrating the implementation of steps S3, S4, S5, and S6 provided in the embodiments of the present invention.

[0039] Figure 9 This is a schematic diagram illustrating an implementation of step S7 provided in an embodiment of the present invention. Detailed Implementation

[0040] 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.

[0041] Figure 1 This is a flowchart of the method for extracting the contour size of a through-slot using multimodal partition detection and dynamic recursive fitting, provided in an embodiment of the present invention. Figure 1 As shown, the method for extracting the contour size of a through-channel using multimodal partition detection and dynamic recursive fitting includes the following steps:

[0042] S1: Preprocess the input slot raw image to locate the pre-center point;

[0043] S2: Using the pre-center point as the origin, perform multimodal edge detection along the four directions of X+, X-, Y+, and Y- to extract the midpoint of the reference edge around the four sides of the through slot; where the width direction of the through slot is the X-axis, the length direction of the through slot is the Y-axis, and the pre-center point is the origin;

[0044] S3: Taking the midpoint of the reference edge of each side of the through slot as the center, extract the ROI map of the corresponding edge in four directions: X+, X-, Y+ and Y-, and adaptively and dynamically enhance the edge contrast of the ROI (Region of Interest) map in each direction.

[0045] S4: Scan the ROI map line by line, extract the initial edge point set of the corresponding direction of the through slot, and obtain the initial edge point set of the ROI map;

[0046] S5: For the initial edge point set of the ROI map, divide the edge point set into m equal intervals according to the length of the point set, count and locate the abnormal intervals, remove the edge points of non-linear elements, and obtain the edge point set of the ROI map after filtering.

[0047] S6: For the edge point set after filtering the ROI map, fit the corresponding edge line of the through slot and calculate the first point, last point and midpoint of the corresponding edge line of each side of the through slot.

[0048] S7: Map the first, last, and midpoints of the corresponding edge lines on each side of the channel to the original channel image to obtain the channel profile dimensions. Specifically, map the first, last, and midpoints of each edge line in the ROI map to the original channel image. Calculate the distances between the first, last, and midpoints of the corresponding edge lines in the X and Y directions in the original channel image, and obtain the average distances in the X and Y directions. Combine this with the object / image resolution to output the physical values ​​of the channel's length, width, symmetry, and tilt angle deviation.

[0049] In step S1, preprocessing includes generating a dynamic blur kernel, strengthening the connected components of the slots 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. The dynamic blur kernel size is obtained using the following formula:

[0050] Size=max(151,0.2×min(W,H));

[0051] 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.

[0052] In step S2, taking the pre-center point as the origin, a 1×3 window is taken row by row along the four directions of X+, X-, Y+ and Y- to calculate the Sobel gradient magnitude and local standard deviation, and the first non-zero pixel point of each row is obtained. Multimodal edge detection is performed to extract the midpoint of the reference edge of each side of the through slot.

[0053] In step S4, a 1×3 window is taken, and the ROI map of each direction is scanned row by row. The Sobel gradient magnitude and local standard deviation are calculated, and the first non-zero pixel of each row is obtained to extract the initial edge point set of each side of the through slot in the corresponding direction.

[0054] In S2 and S4, the method for extracting the edge points of the through slot is to start from the pre-center point, take a 1×3 window in each row in the X+ / X- / Y+ / Y- directions respectively, calculate the Sobel gradient magnitude G and the local standard deviation σ, and obtain the first non-zero pixel point of each row.

[0055] The fusion weights of the Sobel gradient and the local standard deviation are obtained by the following formula:

[0056] F = α × G + (1 - α) × σ;

[0057] Where 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; α is the fusion weight coefficient, α∈[0.3,0.7], which is dynamically adjusted according to the material properties of the channel.

[0058] In step S3, the ROI map extraction method includes: taking the midpoint of the reference edge as the center, extending 0.5×L0 along the X+ and X- directions respectively, and extending 0.5×W0 along the Y+ and Y- directions respectively, thereby defining the ROI map with pixel size L0×W0, symmetrically enclosing the reference edge of the slot; where L0 is the original pixel length of the slot, and W0 is the original pixel width of the slot. The four ROIs are processed independently to avoid local information loss caused by global calculations.

[0059] In step S3, adaptive dynamic enhancement of the edge contrast of the ROI map means that the grayscale of all pixels in the ROI map is inversely amplified according to the grayscale of their respective edge references. The specific formula is as follows:

[0060] Where i represents the ROI plot number, G i I represents the grayscale value of the midpoint of the reference edge in the ROI map. i (row,col) represents the original grayscale value of any pixel within the ROI image. i ′ (row,col) represents the dynamically enhanced grayscale value of any pixel within the ROI image, where row is the row number of the pixel and col is the column number of the pixel.

[0061] In step S5, the number of equally spaced intervals is obtained through the following steps:

[0062]

[0063] When m is a positive integer, there are m equal intervals; when m is not a positive integer, the number of equal intervals is the floor value of m.

[0064] Where L0 is the pixel length of the ROI image and W0 is the pixel width of the ROI image.

[0065] Determination method for abnormal intervals: The initial edge point set P of each ROI image i is divided into m equidistant intervals, and the number N of edge points in each interval is counted k . Intervals with the number of points exceeding 1.2 times the average number of points in the unit interval are determined as abnormal intervals. The formula is as follows:

[0066]

[0067] where k is the index number of the equidistant interval, N k is the number of edge points in the k-th equidistant interval, j is the index number value of the abnormal interval, and N j is the number of edge points in the abnormal interval, and m is the number of equidistant intervals.

[0068] Determination method for edge points of non-linear elements: For any point P in the abnormal interval k , calculate the local slope formed by the two points with sorting positions of k - 5 and k + 5 in the initial edge point set:

[0069]

[0070] where k is the index number of any point P k in the initial edge point set, s 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 with the index number of k + 5 in the initial edge point set, x k+5 is the abscissa of the edge point with the index number of k + 5 in the initial edge point set, y k-5 is the ordinate of the edge point with the index number of k - 5 in the initial edge point set, x k-5 is the abscissa of the edge point with the index number of k - 5 in the initial edge point set.

[0071] If s k < tan(85°) (in the X+ / X- direction) or s k > tan(5°) (in the Y+ / Y- direction), then it is determined as an edge point of a non-linear element and is removed from the initial edge point set P i .

[0072] In step S6, the implementation steps for fitting and outputting the edge straight line in the corresponding direction of the through slot from the filtered edge point set are as follows:

[0073] First, the geometric distance between the two pre-selected points used for line fitting is checked. The check rule is as follows: if the ROI is on the X+ / X- direction side, the distance between the two pre-selected points is >0.5×W0, and the angle between the points is >85°; otherwise, the distance between the two pre-selected points is >0.5×L0, and the angle between all pre-selected points is <5°. If the condition is met, continue; otherwise, re-iterate from the already filtered edge point set.

[0074] An improved least-squares RANSAC line fitting method is adopted, using a dynamically recursive decreasing in-point threshold. The initial in-point threshold is 95%, which is recursively reduced to 85% with a maximum of 50 iterations. During the fitting process, the in-points satisfy the linear equation residuals, where the formula for the linear equation residuals is:

[0075]

[0076] Where A, B, and C are all coefficients of the linear equation, x j Let y be the x-coordinate of the j-th interior point. j Let be the ordinate of the j-th interior point.

[0077] If all conditions are met, the fit is considered successful; otherwise, refitting is required.

[0078] 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 prioritizes the closest profile by sorting the profiles according to their Euclidean distance from the centroid; and zero-moment derivation of the geometric center uses the zero-moment M of the profile to derive the geometric center. 00 and first moment M 10 M 01 Calculate the pre-center point (x) c ,y c ):

[0079]

[0080] 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 outline. 00 This represents the total number of pixels in the outline.

[0081] Specifically, taking a certain through-slot as the object of description in this embodiment, in Figure 1 Under the overall flowchart, combined with Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8 , Figure 9 Detailed description of the implementation steps of the method of the present invention:

[0082] S1: The original image of the input slot ( Figure 2 Preprocessing to locate the pre-center point O1 Figure 3 This includes generating a dynamic blur kernel, strengthening the connected components of the slot through mean blurring and Otsu's inverse binarization, and filtering effective contours based on a three-level verification mechanism and calculating the pre-center point O1. Figure 3 The three-level verification mechanism includes geometric inclusiveness testing, centroid approximation sorting, and zero-order moment derivation of the geometric center, among which:

[0083] (a) Geometric Enclosure Detection: Verify whether the contour encloses the candidate region for the precenter point;

[0084] (b) Centroid Approximation Sort: Sort by Euclidean distance between the centroid and candidate points, and select the closest contour first;

[0085] (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 pre-center point (x) c ,y c ):

[0086]

[0087] The blur kernel size is dynamically set based on the original image size, and is 0.2 times the shorter side of the image but not less than 151 pixels. The formula is as follows:

[0088] Size=max(151,0.2×min(W,H));

[0089] 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.

[0090] S2: with the pre-center point O1 ( Figure 3 Using the origin as the reference point, calculate the Sobel gradient magnitude G and local standard deviation σ by taking a 1×3 window along each of the four directions X+ / X- / Y+ / Y-. Then, find the first non-zero pixel in each row and perform multimodal edge detection to extract the midpoints M1, M2, M3, and M4 of the four reference edges around the slot. Figure 3 The formula for weighting gradient and standard deviation is as follows:

[0091] F = α × G + (1 - α) × σ;

[0092] Wherein, α is the fusion weight coefficient, α∈[0.3,0.7], which is dynamically adjusted according to the material characteristics of the channel.

[0093] S3: Using the midpoints M1, M2, M3, and M4 of each side of the through groove as reference points... Figure 4 Centered on , extend 0.5×L0 along the X+ / X- direction and 0.5×W0 along the Y+ / Y- direction, thereby defining the pixel size L0×W0. Figure 4 The ROI regions located at the reference edge of the slot containing the symmetrical envelope are processed independently in four directions to avoid local information loss caused by global computation; adaptive dynamic enhancement of the edge contrast of each ROI map means that the grayscale of all pixels in each ROI map is inversely amplified according to the grayscale of their respective edge reference. Figure 5 The first picture in the middle Figure 6 The first picture in the middle Figure 7 The first picture in the middle Figure 8 (The first figure in the text), specific formula:

[0094]

[0095] Where i represents the ROI plot number, G i I represents the grayscale value of the midpoint of the reference edge in the ROI map. i (row,col) represents the original grayscale value of any pixel within the ROI image. i ′ (row,col) represents the dynamically enhanced grayscale value of any pixel within the ROI map.

[0096] S4: Take a 1×3 window, scan the ROI map row by row, calculate the Sobel gradient magnitude G and local standard deviation σ, and find the first non-zero pixel in each row to extract the initial edge point set in the corresponding direction of the slot. Figure 5 The second image in the middle Figure 6 The second image in the middle Figure 7 The second image in the middle Figure 8 (Second figure in the middle), the formula for weighting the gradient and standard deviation:

[0097] F=α×G+(1-α)×σ

[0098] Wherein, α is the fusion weight coefficient, α∈[0.3,0.7], which is dynamically adjusted according to the material characteristics of the channel.

[0099] S5: For the initial edge point set of the ROI map, divide the edge point set into m equally spaced intervals A1, A2, A3, A4, A5, A6, A7, A8 according to the length of the point set. Figure 5 , Figure 7 A1, A2, A3, A4 Figure 6 , Figure 8 ), count and locate abnormal intervals, and remove edge points of non-linear elements:

[0100] (a) The calculation formula for the number m of equidistant intervals is as follows:

[0101]

[0102] where m takes the floor value of the calculated value.

[0103] (b) Method for determining abnormal intervals: Divide the initial edge point set P of each ROI map i into m equidistant intervals A1, A2, A3, A4, A5, A6, A7, A8 ( Figure 5 , Figure 7 ), A1, A2, A3, A4 ( Figure 6 , Figure 8 ), count the number N of edge points in each interval j , where the intervals with the number of points exceeding 1.2 times the average number of points in the unit interval are determined as abnormal intervals R1, R2, R3 ( Figure 5 , the second figure in Figure 6 ), R1, R2 ( Figure 7 , the second figure in Figure 8 ), R1, R2 ( Figure 7 [[ID=...]]), R1, R2 ( Figure 8 ), the formula is as follows:

[0104]

[0105] (c) Method for determining edge points of non-linear elements: For each point p in the abnormal interval k , calculate its local slope with the 5 points before and after it:

[0106]

[0107] If s k < tan(85°) (X+ / X- direction) or s k > tan(5°) (Y+ / Y- direction), then it is determined as an edge point of a non-linear element and removed from the initial edge point set P i ( Figure 5 , the third figure in Figure 6 , the third figure in Figure 7 , the third figure in Figure 8 , the third figure in

[0108] S6: For the filtered edge point sets of each ROI map, fit and output the edge lines in the corresponding directions of the through slots, and respectively obtain the starting and ending points P1, Q1 of the edge lines ( Figure 5 , the fourth figure in Figure 6 ), P2, Q2 ( Figure 7 , the fourth figure in Figure 8 ), P3, Q3 ( Figure 5 ), P4, Q4 ( Figure 8 ), the fourth figure in Figure 5The fourth figure in the middle), M2 ( Figure 6 The fourth figure in the middle), M3 ( Figure 7 The fourth figure in the middle), M4 ( Figure 8 (The fourth figure in the middle) The implementation steps are as follows:

[0109] (a) First, the geometric distance between the two pre-selected points used to construct the line fitting is checked. The check rule is that if the ROI map is on the X+ / X- direction side, the distance between the two pre-selected points is >0.5×W0, and the angle between the points is >85°; otherwise, the distance between the two pre-selected points is >0.5×L0, and the angle between all pre-selected points is <5°. If the condition is met, continue; otherwise, re-iterate from the already filtered edge point set.

[0110] (b) Improved least-squares RANSAC line fitting uses a dynamically recursive decreasing in-point threshold. The initial in-point threshold is 95%, recursively shrinking to 85% with a maximum of 50 iterations. During the fitting process, the in-points satisfy the linear equation residuals, where the formula for the linear equation residuals is:

[0111]

[0112] If all conditions are met, the fit is considered successful; otherwise, refitting is required.

[0113] S7: Map the first and last points P1, Q1, P2, Q2, P3, Q3, P4, Q4 and the midpoints M1, M2, M3, M4 of each edge line in the directional ROI map to the original slot image. Figure 9 In the original image of the channel, calculate the mutual distance between three corresponding points on the X / Y oriented edge lines, and obtain the average distances W1, W2, W3, L1, L2, and L3 in the X / Y directions. Figure 9 Combined with the object / image resolution, the output provides physical values ​​of the dimensions of the slot, such as length, width, symmetry, and tilt deviation.

[0114] Repeat steps S1 to S7 for subsequent through-slots to automatically perform batch processing quality inspection.

[0115] This embodiment proposes a closed-loop detection technology chain consisting of "dynamic fuzzy kernel - four-directional partitioned dynamic grayscale enhancement - multimodal edge detection - pre-anomaly screening - multi-geometric constraint recursive fitting," systematically solving the contradictions of poor anti-interference, insufficient accuracy, and low efficiency in existing patents for through-slot detection. It significantly improves the scene adaptability, accuracy, robustness, and scalability of through-slot visual detection in complex noisy scenarios, achieving sub-pixel-level detection standards and providing a systematic solution for the application scenarios of dimensional measurement of complex light alloy structural components. This embodiment also proposes an independent partitioned ROI fusion dynamic grayscale enhancement and multimodal edge detection method to achieve adaptive low-contrast edge enhancement on each side of the through-slot, compensating for the uneven reflectivity of light alloy surfaces and avoiding local distortion caused by global thresholds. In low grayscale contrast areas, the edge detection rate is significantly higher than that of the traditional Canny algorithm. This represents a breakthrough. Traditional Canny algorithms rely on the limitations of a single gradient magnitude to address the low-contrast edge fracture problem in light alloys. This embodiment designs a "pre-interval statistics and slope screening outlier removal" strategy, effectively preserving true geometric features and removing false edges such as burrs and debris. This is significantly superior to the single morphological operation of existing patents. By replacing the traditional outlier removal mechanism after fitting with pre-interval statistics and slope screening, the interference of outlier noise on contour fitting is fully eliminated. This embodiment proposes a "multiple geometric constraint verification + dynamic recursive fitting" algorithm, overcoming the blind sampling defects of traditional methods. Under 30% noise interference, the robustness and convergence speed of contour fitting are significantly better than the traditional least squares RANSAC linear fitting method. This invention constructs a dynamic fuzzy kernel to solve the interference suppression problem of through slots of different sizes, automatically and quickly determining the geometric center of the through slot.

[0116] 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 contour dimensions of a through-slot using multimodal partition detection and dynamic recursive fitting, characterized in that... include: The pre-center point is obtained by preprocessing the original image of the through slot; With the pre-center point as the origin, multimodal edge detection is performed along the four directions of X+, X-, Y+, and Y- to extract the midpoints of the reference edges of each side of the through slot; where the width direction of the through slot is the X-axis, the length direction of the through slot is the Y-axis, and the pre-center point is the origin. Using the midpoint of each reference edge of the through slot as the center, separate ROI maps with independent envelopes for the corresponding edges are extracted in four directions: X+, X-, Y+, and Y-, to enhance the edge contrast of each ROI map. Scan the ROI map line by line and extract the initial edge point set of each side of the through slot in the corresponding direction to obtain the initial edge point set of the ROI map. The initial edge point set of the ROI map is divided into multiple equidistant intervals. Abnormal intervals are counted and located. Edge points of non-linear elements are removed to obtain the edge point set of the ROI map after filtering. For the edge point set after filtering the ROI map, fit the corresponding edge lines of each side of the through channel and calculate the first point, last point and midpoint of the corresponding edge lines of each side of the through channel. Map the first, last, and midpoints of the edge lines in the corresponding directions of each side of the through slot to the original image of the through slot to obtain the through slot profile dimensions.

2. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 1, characterized in that: The preprocessing includes generating a dynamic blur kernel, strengthening the connected components of the slot through mean blurring and Otsu reverse binarization, and filtering effective contours and calculating pre-center points based on a three-level verification mechanism.

3. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 2, characterized in that: The dynamic fuzzy kernel size is obtained using the following formula: Size=max(151,0.2×min(W,H)); Where W and H are the width and height of the original image of the through slot, respectively, and Size is the size of the dynamic blur kernel.

4. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting 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 in each of the four directions X+, X-, Y+ and Y-, and find the first non-zero pixel in each row. Perform multimodal edge detection to extract the midpoint of the reference edge of each side of the through slot. Take a 1×3 window, scan the ROI map of each direction row by row, calculate the Sobel gradient magnitude and local standard deviation, and find the first non-zero pixel of each row to extract the initial edge point set of each side of the through slot in the corresponding direction.

5. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 4, characterized in that: The fusion weights of the Sobel gradient and the local standard deviation are obtained by the following formula: F = α × G + (1 - α) × σ; 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.

6. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 1, characterized in that: The method for extracting the ROI map includes: taking the midpoint of the reference edge as the center, extending 0.5×L0 along the X+ and X- directions respectively, and extending 0.5×W0 along the Y+ and Y- directions respectively, thereby defining the ROI map with a pixel size of L0×W0 that symmetrically encloses the reference edge of the slot; where L0 is the original pixel length of the slot and W0 is the original pixel width of the slot; Enhancing the edge contrast of the ROI map involves inversely amplifying the grayscale of all pixels in the ROI map according to the grayscale of their respective edge reference.

7. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 1, characterized in that: The number of equidistant intervals is obtained as follows: When m is a positive integer, there are m equal intervals; when m is not a positive integer, the number of equal intervals is the floor value of m. Where L0 is the pixel length of the ROI image and W0 is the pixel width of the ROI image.

8. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 1, characterized in that: Count the number of edge points in each equidistant interval. If the number of edge points exceeds 1.2 times the average number of points in a preset unit interval, it is judged as an abnormal 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 tan85° or greater than tan5°, it is determined to be an edge point of a non-linear element.

9. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 1, characterized in that: The fitted output includes the edge lines in the corresponding directions of each side of the through slot, including: The geometric spacing between the two pre-selected points used to construct the line fitting is verified. The verification rules are as follows: if the ROI is on the X+ or X- direction side, the spacing between the two pre-selected points is >0.5×W0, and the angle between the points is >85°; otherwise, the spacing between the two pre-selected points is >0.5×L0, and the angle between all pre-selected points is <5°. If the conditions are met, the process continues; otherwise, the selection is re-iterated from the filtered edge point set. A dynamic recursive decreasing in-point threshold is adopted, with an initial in-point threshold of 95%, which is recursively reduced to 85% for a maximum of 50 iterations. During the fitting process, it is determined whether the in-points satisfy the linear equation residual. If they do, the fitting is considered successful; otherwise, the fitting is re-fitted.

10. The method for extracting the contour size of a through-slot by multimodal partition detection and dynamic recursive fitting according to claim 2, characterized in that: The three-level verification mechanism includes geometric inclusiveness detection, centroid approximation sorting, and zero-order moment derivation of the geometric center; among which... Geometric inclusion detection verifies whether the contour encloses the candidate region for the pre-center point; The centroid approximation sorting is based on the Euclidean distance between the centroid and the candidate points, prioritizing the selection of the closest contour. The zeroth moment is used to derive the geometric center by calculating the pre-center point using the zeroth and first moments through the profile.

Citation Information

Patent Citations

  • High-precision linear distance detection algorithm

    CN117911447A

  • Precise detection method and device for lead screw module based on multi-parameter recursive optimization

    CN120276369A