Ligation clip contour fitting method and system based on sub-pixel edge extraction
Patent Information
- Application Number
- CN202610866514.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2046-06-16
AI Technical Summary
这一问题的本质原因在于,现有图像处理方案未区分结扎夹不同朝向边缘的模糊退化差异,也未适配不同属性轮廓段的特征提取需求,统一的模糊校正与轮廓拟合参数无法同时保证各段轮廓的提取精度
[0057] Compared to existing technologies, the advantages of this invention are as follows: By labeling the edge orientation angle for each edge pixel, the differential impact of motion blur on edges with different orientations is quantified into a calculable angular scalar, providing a grouping basis for subsequent differential correction. This avoids the problem of inconsistent positioning accuracy of edges with different orientations caused by uniform sub-pixel positioning parameters and eliminates systematic deviations in size measurement. Through the edge orientation grouping mechanism, an independent blur degradation correction kernel and sub-pixel interpolation weight coefficients are matched for each group, ensuring that the correction intensity received by each edge pixel is precisely matched with the actual amount of blur degradation. This avoids edge position shifts caused by undercorrection and noise amplification introduced by overcorrection. Simultaneously, the weight ratio of the interpolation method and the gray-scale moment method is adaptively adjusted, balancing robustness in high-blur scenes and positioning accuracy in low-blur scenes. Automatic segmentation of smooth and serrated contour segments is achieved through curvature fluctuation analysis, with independent fitting step sizes and smoothing coefficients configured for each segment. This approach ensures the measurement stability of dimensional parameters in smooth segments through a large fitting step size and smoothing coefficient, while preserving the micro-features of the serrated contour through a small fitting step size and smoothing coefficient. Simultaneously, it meets the high repeatability requirements for dimensional verification and the high sensitivity requirements for detecting micro-defects in anti-slip teeth. This solution utilizes image processing technology to significantly improve the accuracy and reliability of visual inspection of ligation clips in mass production under motion conditions, meeting the compliance requirements of Class III medical device quality inspection.
Smart Images

Figure CN122415606B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection technology for medical devices, and specifically to a method and system for fitting the contour of ligation clips based on sub-pixel edge extraction. Background Technology In the mass production quality inspection of high-risk medical device ligation clips, automated visual inspection is a core technology for ensuring product compliance. Existing technologies typically employ a combination of sub-pixel edge extraction and contour fitting to automatically detect the overall size and structural defects of the ligation clip's occlusal end, replacing manual visual inspection to improve efficiency and meet the continuous operation requirements of mass production lines. These solutions usually rely on globally unified image processing parameters to complete feature extraction and index verification of the entire ligation clip contour.
[0002] During actual operation of the mass production line, quality control engineers discovered that among qualified ligation clips of the same batch and specifications, some products showed deviations exceeding compliance thresholds during continuous testing. Products that had passed initial inspection were misjudged during re-inspection for dimensional inaccuracies or missing teeth. The root cause of this problem lies in the fact that the existing image processing solution does not differentiate between the blurring and degradation differences of the ligation clip's edges facing different directions, nor does it adapt to the feature extraction requirements of contour segments with different attributes. Uniform blur correction and contour fitting parameters cannot simultaneously guarantee the extraction accuracy of each contour segment. This problem leads to the misjudgment and rejection of qualified products, increasing production scrap costs, and also allows substandard products with minor defects to enter the market. As high-risk medical devices directly applied to human surgery, ligation clips with structural defects may experience slippage or clamping failure during clinical use, directly threatening patient safety. Furthermore, it prevents manufacturers from meeting the compliance requirements of medical device regulations, exposing them to corresponding compliance risks. Summary of the Invention
[0003] To address the above problems, the present invention provides the following solution.
[0004] A method for fitting the contour of a ligation clip based on sub-pixel edge extraction S1: Acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain the initial edge pixel set, calculate the local gradient direction of each edge pixel in the initial edge pixel set and obtain the angle between it and the direction of transport motion, and generate an edge pixel set carrying edge orientation angle label.
[0005] Further, step S1 includes: S11: By deploying an industrial camera at the vision inspection station, the original inspection image of the ligation clip is acquired when it passes the conveyor track; at the same time, the movement direction of the conveyor track is recorded and represented as a unit direction vector, denoted as the conveyor direction vector.
[0006] S12: Perform Gaussian smoothing filtering on the original detection image of the ligation clip to remove high-frequency noise and obtain a smoothed image; calculate the gray-level gradient components along the horizontal and vertical directions of the smoothed image to obtain the horizontal gradient component map and the vertical gradient component map.
[0007] S13: Based on the horizontal gradient component map and the vertical gradient component map, calculate the gradient magnitude for each pixel in the smoothed image, and mark the pixels with gradient magnitudes greater than the preset edge detection threshold as edge pixels. All edge pixels constitute the initial edge pixel set.
[0008] S14: For each edge pixel in the initial set of edge pixels, calculate the local gradient direction vector of the edge pixel based on the gradient component values at the corresponding positions in the horizontal gradient component map and the vertical gradient component map.
[0009] S15: Calculate the angle between the local gradient direction vector and the input direction vector of each edge pixel, and record the angle as the edge orientation angle; write the edge orientation angle into the attribute field of the corresponding edge pixel to obtain the set of edge pixels with edge orientation angle annotation.
[0010] Specifically, the physical meaning of the edge orientation angle is as follows: the edge orientation angle reflects the degree of deviation between the edge normal direction and the conveying motion direction; when the edge orientation angle approaches zero degrees, the edge normal direction is parallel to the motion direction, and the edge segment is most affected by motion ambiguity; when the edge orientation angle approaches ninety degrees, the edge normal direction is perpendicular to the motion direction, and the edge segment is least affected by motion ambiguity.
[0011] S2: Based on the set of edge pixels with edge orientation angle labels, the edge pixels are divided into multiple orientation groups according to the edge orientation angle. Each orientation group is assigned an independent fuzzy degradation correction kernel and sub-pixel interpolation weight coefficient. Differentiated sub-pixel edge localization is performed on the edge pixels in each orientation group to obtain an orientation-adaptive sub-pixel edge point set.
[0012] Further, step S2 includes: S21: Divide the range of edge orientation angle from 0 degrees to 90 degrees into K orientation intervals. Assign each edge pixel in the set of edge pixels with edge orientation angle labels to the corresponding orientation group according to the orientation interval into which the edge orientation angle falls, and obtain K orientation groups.
[0013] S22: For each orientation group, calculate the motion blur degradation index of the orientation group based on the center angle value of the orientation interval corresponding to the orientation group.
[0014] Further, step S22 includes: S221: Based on the movement speed of the conveyor track and the exposure time of the industrial camera, calculate the maximum blur pixel span along the conveying direction vector, denoted as the maximum blur span.
[0015] S222: For each orientation group, take the center angle value of the orientation interval corresponding to the orientation group, calculate the projection length of the maximum fuzzy span in the edge normal direction, and record the projection length as the normal fuzzy span of the orientation group.
[0016] S223: Normalize the normal fuzzy span to the interval between zero and one to obtain the motion fuzz degradation index for each orientation group; when the edge orientation angle approaches zero degrees, the motion fuzz degradation index approaches one, and when the edge orientation angle approaches ninety degrees, the motion fuzz degradation index approaches zero.
[0017] S23: Based on the motion blur degradation degree index, generate an independent blur degradation correction kernel and sub-pixel interpolation weight coefficient for each orientation group.
[0018] Further, step S23 includes: S231: For orientation groups where the motion blur degradation index is greater than the preset high blur threshold, construct a one-dimensional motion blur point diffusion function with a length equal to the normal blur span along the direction of the transport direction vector. Perform Wiener inverse filtering on the one-dimensional motion blur point diffusion function to obtain the blur degradation correction kernel. Set the sub-pixel interpolation weight coefficient to the weight allocation of the biased gray-scale moment method so that the contribution of the gray-scale moment method is greater than the contribution of the interpolation method.
[0019] S232: For orientation groups where the motion blur degradation index is less than the preset low blur threshold, set the blur degradation correction kernel to a unit pulse kernel and do not perform blur correction; set the subpixel interpolation weight coefficient to the weight allocation of the bias interpolation method, so that the contribution of the interpolation method is greater than the contribution of the gray-scale moment method.
[0020] S233: For orientation grouping where the motion blur degradation index is between the high blur threshold and the low blur threshold, the intensity of the blur degradation correction kernel is linearly interpolated to generate a transition correction kernel based on the linear position of the motion blur degradation index between the high blur threshold and the low blur threshold. At the same time, the gray-scale moment method weight and the interpolation method weight are linearly interpolated to obtain the sub-pixel interpolation weight coefficient.
[0021] S24: Perform differential subpixel edge localization for each edge pixel in the orientation group.
[0022] Further, step S24 includes: S241: For each orientation group, extract the local gray-level neighborhood window centered on each edge pixel in the original detection image of the ligation clip, and use the blur degradation correction kernel corresponding to the orientation group to perform convolution correction on the local gray-level neighborhood window to obtain the corrected gray-level neighborhood window.
[0023] S242: For the corrected gray-level neighborhood window, the sub-pixel offset is calculated using interpolation and gray-level moment methods respectively. The interpolation method obtains the sub-pixel offset corresponding to the gray-level gradient extremum by performing a quadratic polynomial fitting on the gray-level values in the corrected gray-level neighborhood window. The gray-level moment method determines the sub-pixel offset based on the zero-crossing position of the gray-level moments by calculating the first and second moments of the gray-level distribution in the corrected gray-level neighborhood window.
[0024] S243: Based on the sub-pixel interpolation weight coefficients corresponding to the orientation group, the sub-pixel offsets obtained by the interpolation method and the sub-pixel offsets obtained by the gray-scale moment method are weighted and fused to obtain the fused sub-pixel offsets; the integer pixel coordinates of the edge pixels are added to the fused sub-pixel offsets to obtain the sub-pixel edge point coordinates.
[0025] S244: Summarize the sub-pixel edge point coordinates of all edge pixels in all orientation groups to form an orientation-adaptive sub-pixel edge point set.
[0026] S3: Based on the orientation-adaptive sub-pixel edge point set, the ligation clip contour is segmented into heterogeneous feature segments, smooth contour segments and jagged contour segments are identified, and independent fitting step size and smoothing coefficient are configured for smooth contour segments and jagged contour segments respectively. Piecewise adaptive contour fitting is performed to obtain the piecewise fitted contour parameter table.
[0027] Further, step S3 includes: S31: Sort the sub-pixel edge points in the adaptive sub-pixel edge point set according to the arc length direction along the ligation clip contour to generate an ordered sub-pixel edge point sequence.
[0028] S32: Perform local curvature fluctuation analysis on ordered subpixel edge point sequences to identify smooth contour segments and jagged contour segments.
[0029] Further, step S32 includes: S321: Along the ordered subpixel edge point sequence, with a preset curvature analysis window length as the sliding window, perform second-order difference calculation on the subpixel edge points within each sliding window to obtain the local curvature value of each subpixel edge point within the window.
[0030] S322: Calculate the standard deviation of all local curvature values within each sliding window, and denote the standard deviation as the curvature fluctuation.
[0031] S323: For each sub-pixel edge point in the ordered sub-pixel edge point sequence, compare the curvature fluctuation of the sliding window where the sub-pixel edge point is located with the preset curvature fluctuation threshold; mark the continuous sub-pixel edge point segments with curvature fluctuation less than the curvature fluctuation threshold as smooth contour segments, and mark the continuous sub-pixel edge point segments with curvature fluctuation greater than or equal to the curvature fluctuation threshold as jagged contour segments.
[0032] S324: Perform boundary refinement on the transition region between adjacent smooth contour segments and jagged contour segments, and classify the sub-pixel edge points in the transition region into smooth contour segments or jagged contour segments according to the gradual trend of curvature fluctuation, thus determining the final segmentation boundary position.
[0033] S33: Configure independent fitting step size and smoothing coefficient for smooth contour segments and jagged contour segments respectively.
[0034] Further, step S33 includes: S331: For smooth contour segments, configure a larger fitting step size and a larger smoothing coefficient; a larger fitting step size increases the number of sub-pixel edge points participating in a single fitting calculation, and a larger smoothing coefficient enhances the suppression of random noise by the fitting curve, thus meeting the need to eliminate noise interference and obtain smooth size parameters for smooth contour segments.
[0035] S332: For the sawtooth contour segment, configure a smaller fitting step size and a smaller smoothing coefficient; the smaller fitting step size reduces the number of sub-pixel edge points participating in a single fitting calculation, and the smaller smoothing coefficient allows the fitting curve to retain the micro-scale undulation features of the edge, adapting to the need of the sawtooth contour segment to retain the anti-slip tooth shape details for micro-defect identification.
[0036] S34: Perform contour fitting on smooth contour segments and jagged contour segments respectively, based on the configured fitting step size and smoothing coefficient.
[0037] Further, step S34 includes: S341: For each smooth contour segment, determine the fitting model type based on the geometric shape of the smooth contour segment. For smooth contour segments belonging to straight segments, use least squares linear fitting; for smooth contour segments belonging to arc segments, use least squares arc fitting. During the fitting process, points are taken sequentially according to the fitting step size corresponding to the smooth contour segment. The obtained sub-pixel edge point coordinates are preprocessed by weighted averaging according to the smoothing coefficient corresponding to the smooth contour segment before being input into the fitting model. The fitting parameters of the smooth contour segment are output, including the slope and intercept of the straight line or the center coordinates and radius of the circle.
[0038] S342: For each sawtooth contour segment, points are taken sequentially according to the fitting step size corresponding to the sawtooth contour segment, and cubic B-spline curve fitting is used. During the fitting process, the smoothing coefficient corresponding to the sawtooth contour segment is used as the smoothing factor of the B-spline. While preserving the anti-slip tooth shape features, sub-pixel level random jitter is filtered out, and the B-spline control point sequence and node vector of the sawtooth contour segment are output.
[0039] S343: Summarize and arrange the fitting parameters of all smooth contour segments and the B-spline control point sequences and node vectors of all serrated contour segments according to the segment number to generate a segmented fitting contour parameter table.
[0040] S4: Based on the segmented fitting contour parameter table, perform size verification on smooth contour segments and anti-slip tooth defect detection on serrated contour segments. Output the quality inspection judgment conclusion of the ligation clip by combining the size verification results and the anti-slip tooth defect detection results.
[0041] Further, step S4 includes: S41: Extract the fitting parameters of all smooth contour segments from the segmented fitting contour parameter table, and calculate the key size features of the ligation clip based on the fitting parameters.
[0042] Further, step S41 includes: S411: For smooth contour segments that are straight, calculate the width and length of the ligation clip body based on the slope and intercept of the straight line; for cases with parallel straight line segments, calculate the perpendicular distance between the two parallel fitted straight lines as the width of the clip body.
[0043] S412: For smooth contour segments that belong to arc segments, calculate the curvature radius and arc span of the tail arc of the ligation clip based on the center coordinates and radius.
[0044] S413: Summarize all key dimensional features, including clamp width, length, radius of curvature, and arc span, to form a set of dimensional features.
[0045] S42: Compare each key dimension feature in the set of dimension features with the corresponding upper and lower limits in the preset ligation clip dimension tolerance standard. If all key dimension features fall within the corresponding tolerance range, the dimension verification result is marked as dimension qualified; otherwise, it is marked as dimension unqualified and the out-of-tolerance item is recorded.
[0046] S43: Extract the B-spline control point sequence and node vector of all sawtooth contour segments from the segmented fitting contour parameter table, and perform anti-slip tooth defect detection on the sawtooth contour segments.
[0047] Further, step S43 includes: S431: Reconstruct the continuous fitting curve of the sawtooth profile segment based on the B-spline control point sequence and node vector, and obtain the sawtooth profile sampling point sequence by sampling at equal intervals along the fitting curve.
[0048] S432: Calculate the local curvature sequence for the serrated contour sampling point sequence, perform peak detection on the local curvature sequence, identify the tooth tip corresponding to each curvature peak position and the tooth valley corresponding to each curvature valley position, and count the number of tooth tips as the actual number of teeth.
[0049] S433: Compare the actual number of teeth with the preset standard number of teeth. If the actual number of teeth is less than the standard number of teeth, it is determined that there is a missing tooth defect.
[0050] S434: Calculate the tooth pitch between adjacent tooth tips and the peak curvature amplitude at each tooth tip, compare the tooth pitch with the preset standard tooth pitch, and compare the peak curvature amplitude with the preset standard peak curvature range; if the tooth pitch deviation exceeds the preset tooth pitch deviation threshold or the peak curvature amplitude is lower than the lower limit of the standard peak curvature range, it is determined that there is a wear micro-defect in the corresponding tooth position.
[0051] S435: Summarize the results of the missing tooth defect judgment and the wear micro-defect judgment. If there is no missing tooth defect and no wear micro-defect, the anti-slip tooth defect detection result is marked as qualified tooth shape; otherwise, it is marked as unqualified tooth shape and the defect tooth position number and defect type are recorded.
[0052] S44: Generate a quality inspection conclusion for the ligation clip by combining the dimensional verification results and the anti-slip tooth defect detection results; if the dimensional verification result is that the dimensions are qualified and the anti-slip tooth defect detection result is that the tooth shape is qualified, then the quality inspection conclusion for the ligation clip is qualified; if the dimensional verification result is that the dimensions are unqualified or the anti-slip tooth defect detection result is that the tooth shape is unqualified, then the quality inspection conclusion for the ligation clip is unqualified, and the specific out-of-tolerance item or defect tooth position number and defect type are recorded in the quality inspection conclusion for subsequent sorting and quality traceability.
[0053] The present invention also provides a ligation clip contour fitting method system based on sub-pixel edge extraction, which is used to implement the above-mentioned ligation clip contour fitting method based on sub-pixel edge extraction, the system comprising: Edge detection and annotation module: used to acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain an initial set of edge pixels, calculate the local gradient direction of each edge pixel in the initial set of edge pixels and obtain the angle between it and the direction of transport motion, and generate an edge pixel set carrying edge orientation angle annotation.
[0054] Subpixel localization module: Based on the set of edge pixels labeled with edge orientation angle, divide the edge pixels into multiple orientation groups according to the edge orientation angle, assign an independent fuzzy degradation correction kernel and subpixel interpolation weight coefficient to each orientation group, and perform differentiated subpixel edge localization on the edge pixels in each orientation group to obtain an orientation-adaptive subpixel edge point set.
[0055] The segmented fitting module is used to segment the ligation clip contour into heterogeneous feature segments based on the orientation adaptive sub-pixel edge point set, identify smooth contour segments and jagged contour segments, configure independent fitting step size and smoothing coefficient for the smooth contour segments and jagged contour segments respectively, perform segmented adaptive contour fitting, and obtain a segmented fitting contour parameter table.
[0056] Quality inspection judgment module: Based on the segmented fitting contour parameter table, it performs size verification on the smooth contour segment, performs anti-slip tooth defect detection on the serrated contour segment, and outputs the quality inspection judgment conclusion of the ligation clip by combining the size verification result and the anti-slip tooth defect detection result.
[0057] Compared to existing technologies, the advantages of this invention are as follows: By labeling the edge orientation angle for each edge pixel, the differential impact of motion blur on edges with different orientations is quantified into a calculable angular scalar, providing a grouping basis for subsequent differential correction. This avoids the problem of inconsistent positioning accuracy of edges with different orientations caused by uniform sub-pixel positioning parameters and eliminates systematic deviations in size measurement. Through the edge orientation grouping mechanism, an independent blur degradation correction kernel and sub-pixel interpolation weight coefficients are matched for each group, ensuring that the correction intensity received by each edge pixel is precisely matched with the actual amount of blur degradation. This avoids edge position shifts caused by undercorrection and noise amplification introduced by overcorrection. Simultaneously, the weight ratio of the interpolation method and the gray-scale moment method is adaptively adjusted, balancing robustness in high-blur scenes and positioning accuracy in low-blur scenes. Automatic segmentation of smooth and serrated contour segments is achieved through curvature fluctuation analysis, with independent fitting step sizes and smoothing coefficients configured for each segment. This approach ensures the measurement stability of dimensional parameters in smooth segments through a large fitting step size and smoothing coefficient, while preserving the micro-features of the serrated contour through a small fitting step size and smoothing coefficient. Simultaneously, it meets the high repeatability requirements for dimensional verification and the high sensitivity requirements for detecting micro-defects in anti-slip teeth. This solution utilizes image processing technology to significantly improve the accuracy and reliability of visual inspection of ligation clips in mass production under motion conditions, meeting the compliance requirements of Class III medical device quality inspection. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a flowchart of the ligation clip contour fitting method based on sub-pixel edge extraction in this invention; Figure 2 This is a schematic diagram illustrating the calculation of the angle between the local gradient direction vector of an edge pixel and the transport direction vector in an embodiment of the present invention; Figure 3 This is a schematic diagram of orientation grouping and normal fuzzy span projection in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the generation of a transition correction kernel by mixing a fuzzy degradation correction kernel and a unit pulse kernel in an embodiment of the present invention. Figure 5 This is a schematic diagram of local gray-level neighborhood window convolution correction in an embodiment of the present invention; Figure 6 This is a schematic diagram comparing the one-dimensional grayscale profile quadratic polynomial fitting and grayscale moment centroid calculation in an embodiment of the present invention; Figure 7 This is a schematic diagram of the curvature fluctuation analysis sliding window and segmentation boundary in an embodiment of the present invention; Figure 8 This is a schematic diagram of the step size selection and weighted average preprocessing for fitting smooth contour segments in an embodiment of the present invention; Figure 9 This is a schematic diagram showing the relationship between the control points and data points for fitting the B-spline of the sawtooth contour segment in an embodiment of the present invention; Figure 10 This is a functional block diagram of the ligation clip contour fitting system based on sub-pixel edge extraction in this invention. Detailed Implementation
[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0061] Example 1: Please see Figure 1 As shown, this embodiment provides a ligation clip contour fitting method based on sub-pixel edge extraction, including: S1: Acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain the initial edge pixel point set, calculate the local gradient direction of each edge pixel point in the initial edge pixel point set and obtain the angle with the transport motion direction to generate an edge pixel point set carrying edge orientation angle label; Further, step S1 includes: S11: By using an industrial camera deployed at the vision inspection station, the original inspection image of the ligation clip is acquired when it passes the conveyor track; at the same time, the movement direction of the conveyor track is recorded and represented as a unit direction vector, denoted as the conveyor direction vector. Further, step S11 includes: S111: The industrial camera is positioned directly above the vision inspection station. The optical axis of the industrial camera is perpendicular to the bearing plane of the conveyor track, and the field of view of the industrial camera covers the inspection area along the conveyor track through which the ligation clips pass. The vision inspection station is located on the conveyor track section between the vibratory feeder and the defective product sorting mechanism. The ligation clip parts are automatically fed by the vibratory feeder and enter the inspection area of the vision inspection station via the conveyor track. When the ligation clip parts reach the inspection area, a photoelectric trigger sensor deployed on the side of the conveyor track detects the leading edge of the ligation clip parts. The photoelectric trigger sensor sends a trigger signal to the industrial camera. After receiving the trigger signal, the industrial camera completes an image acquisition according to a preset exposure time, obtaining the original inspection image of the ligation clip. The original inspection image of the ligation clip is a grayscale image, containing the complete projected outline of the ligation clip parts and the background area of the conveyor track. The preset exposure time is determined based on the movement speed of the conveyor track and the pixel size of the industrial camera. Specifically, the actual size of a single pixel of the industrial camera in the object space is divided by the movement speed of the conveyor track, and half of the quotient is taken as the preset upper limit of the exposure time. The actual exposure time does not exceed the preset upper limit of the exposure time, so as to control the maximum pixel span of motion blur within a correctable range. For example, when the pixel object space resolution of the industrial camera is 5 micrometers per pixel and the movement speed of the conveyor track is 50 millimeters per second, the preset upper limit of the exposure time is 5 micrometers divided by 50 millimeters per second, which equals 0.1 milliseconds, and the actual exposure time can be set to 0.08 milliseconds.
[0062] S112: Record the movement direction of the conveyor track. Represent the movement direction of the conveyor track as a unit direction vector in the pixel coordinate system of the original detection image of the ligation clip, denoted as the conveyor direction vector. The method for determining the conveyor direction vector is as follows: During the equipment installation and commissioning phase, two reference points are marked on the track surface along the movement direction of the conveyor track. Image coordinates of the two reference points are acquired using an industrial camera. The difference between the image coordinates of the two reference points is normalized to obtain the conveyor direction vector. The normalization process involves dividing the difference between the image coordinates of the two reference points by the Euclidean norm of the difference between the image coordinates of the two reference points, making the magnitude of the conveyor direction vector equal to 1. After calibration during the equipment installation and commissioning phase, the conveyor direction vector is stored in the parameter configuration file of the detection system and can be directly read and used in subsequent detections without repeated calibration. For example, if the coordinates of two reference points in the image coordinate system are (120, 300) and (850, 305) respectively, then the difference between the image coordinates of the two reference points is (730, 5), the Euclidean norm is 730.02, and the transport direction vector is (0.9999, 0.0068), indicating that the transport direction is approximately along the horizontal direction in the image coordinate system.
[0063] S12: Perform Gaussian smoothing filtering on the original detection image of the ligation clip to remove high-frequency noise and obtain a smoothed image; calculate the gray-level gradient components along the horizontal and vertical directions of the smoothed image to obtain the horizontal gradient component map and the vertical gradient component map. Further, step S12 includes: S121: Perform Gaussian smoothing filtering on the original detection image of the ligation clip. The implementation process of Gaussian smoothing filtering is as follows: Construct a two-dimensional Gaussian convolution kernel. The size and standard deviation of the two-dimensional Gaussian convolution kernel are determined according to the frequency characteristics of the noise in the original detection image of the ligation clip. The standard deviation of the two-dimensional Gaussian convolution kernel is determined based on the following: the standard deviation should be greater than the spatial correlation scale of the noise to effectively suppress high-frequency random noise, and it should be smaller than the pixel width of the transition area of the ligation clip contour edge to avoid excessive blurring of edge information. For example, the standard deviation of the two-dimensional Gaussian convolution kernel can be set to 1.0 pixel, and the size of the two-dimensional Gaussian convolution kernel can be set to 5 pixels multiplied by 5 pixels. Perform a two-dimensional convolution operation between the two-dimensional Gaussian convolution kernel and the original detection image of the ligation clip to obtain a smoothed image. The smoothed image has the same pixel size as the original detection image of the ligation clip. High-frequency random noise in the smoothed image is suppressed, and the gray-level transition area of the ligation clip contour edge is preserved.
[0064] S122: Calculate the gray-level gradient components along the horizontal direction of the smoothed image to obtain a horizontal gradient component map. The horizontal gradient component map is calculated by performing a convolution operation between the smoothed image and the Sobel horizontal gradient operator. The Sobel horizontal gradient operator has a 3-pixel multiplied by 3-pixel convolution kernel. The output of the convolution operation is the gray-level change rate of each pixel in the smoothed image along the horizontal direction. Calculate the gray-level gradient components along the vertical direction of the smoothed image to obtain a vertical gradient component map. The vertical gradient component map is calculated by performing a convolution operation between the smoothed image and the Sobel vertical gradient operator. The Sobel vertical gradient operator has a 3-pixel multiplied by 3-pixel convolution kernel. The output of the convolution operation is the gray-level change rate of each pixel in the smoothed image along the vertical direction. Both the horizontal and vertical gradient component maps have the same pixel size as the smoothed image. The value of each pixel in the horizontal gradient component map is the gray-level gradient component value in the horizontal direction at the corresponding position, and the value of each pixel in the vertical gradient component map is the gray-level gradient component value in the vertical direction at the corresponding position.
[0065] S13: Based on the horizontal gradient component map and the vertical gradient component map, calculate the gradient magnitude for each pixel in the smoothed image, mark the pixels with gradient magnitudes greater than the preset edge detection threshold as edge pixels, and all edge pixels constitute the initial edge pixel set. Further, step S13 includes: S131: For each pixel in the smoothed image, read the horizontal gray-level gradient component value at the corresponding position from the horizontal gradient component map, and read the vertical gray-level gradient component value at the corresponding position from the vertical gradient component map. Summate the squares of the horizontal and vertical gray-level gradient component values and take the square root to obtain the gradient magnitude of the corresponding pixel. The gradient magnitudes of all pixels constitute a gradient magnitude map, which has the same pixel size as the smoothed image.
[0066] S132: Compare the gradient magnitude of each pixel in the gradient magnitude map with a preset edge detection threshold. The preset edge detection threshold is determined by: statistically analyzing the gradient magnitude of all pixels in the gradient magnitude map, calculating the mean and standard deviation of the gradient magnitudes, and adding a preset multiple to the mean gradient magnitude multiplied by the standard deviation to obtain the preset edge detection threshold. The preset multiple is determined based on the strength of the grayscale contrast between the ligation clip outline edge and the background area; for example, the preset multiple can be set to 2.0. Pixels with gradient magnitudes greater than the preset edge detection threshold are marked as edge pixels. The attribute of each edge pixel includes integer pixel coordinates, which are the row and column positions of the edge pixel in the original detection image of the ligation clip. All edge pixels constitute an initial edge pixel set. The data structure of the initial edge pixel set is a list, where each element is an attribute record of an edge pixel, and the attribute record includes an integer pixel coordinate field.
[0067] S14: For each edge pixel in the initial set of edge pixels, calculate the local gradient direction vector of the edge pixel based on the gradient component values at the corresponding positions in the horizontal gradient component map and the vertical gradient component map. Specifically, for each edge pixel in the initial set of edge pixels, the horizontal grayscale gradient component value at the integer pixel coordinates of the edge pixel is read from the horizontal gradient component map, and the vertical grayscale gradient component value at the integer pixel coordinates of the edge pixel is read from the vertical gradient component map. The horizontal and vertical grayscale gradient component values are combined to form a two-dimensional vector, denoted as the local gradient direction vector of the edge pixel. The direction of the local gradient direction vector points in the direction of the fastest increase in grayscale value, i.e., the normal direction of the contour edge at the edge pixel. The local gradient direction vector is not normalized; the gradient magnitude information is retained for use in subsequent steps.
[0068] S15: Calculate the angle between the local gradient direction vector and the input direction vector of each edge pixel, and record the angle as the edge orientation angle; write the edge orientation angle into the attribute field of the corresponding edge pixel to obtain the set of edge pixels with edge orientation angle annotation. Further, step S15 includes: S151: For each edge pixel in the initial set of edge pixels, calculate the angle between the local gradient direction vector and the transport direction vector of the edge pixel. The angle is calculated by: calculating the dot product of the local gradient direction vector and the transport direction vector of the edge pixel, and dividing the dot product by the product of the Euclidean norm of the local gradient direction vector and the Euclidean norm of the transport direction vector.
[0069] See Figure 2This diagram illustrates the calculation of the angle between the local gradient direction vector of an edge pixel and the transport direction vector, as provided in an embodiment of this application. The diagram demonstrates how, in a visual inspection scenario involving a ligation clip, the local gradient direction vector of an edge pixel is constructed using grayscale gradient components in the horizontal and vertical directions, and the edge orientation angle between it and the fixed transport direction vector is further calculated. The diagram clearly identifies the coordinate system of each vector and its geometric attribute relationships. In automated high-speed inspection, due to the displacement of the part during camera exposure, the resulting motion blur has a strong directionality, affecting edges with different normal orientations across varying ranges. The edge orientation angle is calculated using the dot product and inverse trigonometric operation logic shown in the diagram, accurately converting the geometric orientation differences into a calculable angle scalar. This operation quantifies the inherent degree of motion blur degradation of each pixel, successfully avoiding the "partial insufficiency, partial over-excess" errors caused by globally unified parameter kernel processing, laying the underlying mathematical foundation for achieving adaptive differentiated sub-pixel edge precision localization.
[0070] S152: Write the edge orientation angle into the attribute record of the corresponding edge pixel, and add an edge orientation angle field to the attribute record. After traversing all edge pixels in the initial edge pixel set to complete the calculation and writing of the edge orientation angle, an edge pixel set with edge orientation angle annotations is obtained. The data structure of the edge pixel set with edge orientation angle annotations is the same as that of the initial edge pixel set, which is a list structure. The attribute record of each element in the list contains an integer pixel coordinate field and an edge orientation angle field.
[0071] Specifically, the physical meaning of the edge orientation angle is as follows: the edge orientation angle reflects the degree of deviation between the edge normal direction and the transport motion direction. When the edge orientation angle approaches 0 degrees, the edge normal direction is parallel to the motion direction, and the direction of motion blur is consistent with the edge grayscale transition direction. The motion blur is directly superimposed on the grayscale gradient change direction of the edge, causing the grayscale transition area of the edge to be stretched and widened. The edge segment where the edge pixel is located is most affected by motion blur. When the edge orientation angle approaches 90 degrees, the edge normal direction is perpendicular to the motion direction, and the direction of motion blur is along the tangent direction of the edge. It only causes a slight translation of the edge along the tangent direction without changing the width of the edge grayscale transition area. The edge segment where the edge pixel is located is least affected by motion blur.
[0072] Specifically, step S1 involves performing pixel-level edge detection on the original detection image of the ligation clip and labeling the edge orientation angle for each edge pixel, thus constructing an edge pixel dataset carrying motion blur direction sensitivity labels. This provides a grouping basis for differentiated correction in the orientation-adaptive sub-pixel edge localization in the subsequent step S2. In the automated visual inspection scenario for mass production of ligation clips, the movement direction of the conveyor track is fixed. The ligation clip contour includes the long edge of the clip body parallel to the movement direction, the short edge of the clip body perpendicular to the movement direction, and the tail arc edge and the anti-slip tooth edge at the biting end, which are at any angle to the movement direction. The motion blur degradation amplitude of edge segments with different orientations varies significantly under the same movement speed and exposure time conditions. If the edge orientation angle is not labeled and subpixel localization with uniform parameters is performed directly on all edge pixels, the subpixel localization accuracy of edge segments parallel to the motion direction will be low due to severe motion blur, while the subpixel localization accuracy of edge segments perpendicular to the motion direction will be high because they are almost unaffected by motion blur. The inconsistency in localization accuracy between the two types of edge segments will directly affect the subsequent contour fitting and size measurement stages, causing a systematic deviation in the measurement accuracy of the same ligation clip in different directions. Step S1 calculates the angle between the local gradient direction vector and the transmission direction vector of each edge pixel, quantifying the differential impact of motion blur on edges with different orientations into a calculable angle scalar. This allows the subsequent step S2 to assign different strengths of blur correction kernels and different weight ratios of subpixel localization algorithms to edge pixels with different orientations based on the edge orientation angle value, thereby eliminating the problem of inconsistent subpixel localization accuracy caused by differences in edge orientation and providing a data foundation for the uniformity of overall contour fitting accuracy.
[0073] S2: Based on the set of edge pixels with edge orientation angle labels, the edge pixels are divided into multiple orientation groups according to the edge orientation angle. Each orientation group is assigned an independent fuzzy degradation correction kernel and sub-pixel interpolation weight coefficient. Differentiated sub-pixel edge localization is performed on the edge pixels in each orientation group to obtain an orientation-adaptive sub-pixel edge point set. Further, step S2 includes: S21: Divide the range of edge orientation angle from 0 degrees to 90 degrees into K orientation intervals evenly. Assign each edge pixel in the set of edge pixels with edge orientation angle labels to the corresponding orientation group according to the orientation interval into which the edge orientation angle falls, and obtain K orientation groups. Specifically, the number of orientation intervals K is determined as follows: K should be large enough to minimize the difference in motion blur degradation among edge pixels within the same orientation group, while K should not be too large to avoid a decrease in statistical reliability due to an insufficient number of edge pixels in a single orientation group. For example, K can be set to 6, in which case the width of each orientation interval is 15 degrees. The first orientation interval is 0 to 15 degrees, the second is 15 to 30 degrees, and so on, with the sixth orientation interval being 75 to 90 degrees. For each edge pixel in the set of edge pixels carrying edge orientation angle annotations, the edge orientation angle field value in the edge pixel's attribute record is read, the orientation interval number into which the edge orientation angle falls is determined, and the edge pixel is assigned to the corresponding orientation group. The data structure of each orientation group is a list, where each element is the attribute record of the edge pixel assigned to the current orientation group. All K orientation groups collectively contain all edge pixels in the set of edge pixels carrying edge orientation angle annotations, and any edge pixel belongs to only one orientation group.
[0074] S22: For each orientation group, calculate the motion blur degradation index of the orientation group based on the center angle value of the orientation interval corresponding to the orientation group; Further, step S22 includes: S221: Based on the movement speed of the conveyor track and the exposure time of the industrial camera, calculate the maximum blurring pixel span along the conveying direction vector, denoted as the maximum blurring span. The calculation method for the maximum blurring span is as follows: multiply the movement speed of the conveyor track by the exposure time of the industrial camera to obtain the physical displacement of the ligation clamp along the conveying direction during the exposure period; divide the physical displacement by the pixel object-space resolution of the industrial camera to obtain the maximum blurring span, with the unit of the maximum blurring span being pixels. The movement speed of the conveyor track is read from the equipment parameter configuration file of the detection system, the exposure time of the industrial camera is the preset exposure time set in step S111, and the pixel object-space resolution of the industrial camera is read from the calibration parameter file of the industrial camera. For example, when the movement speed of the conveyor track is 50 millimeters per second, the exposure time of the industrial camera is 0.08 milliseconds, and the pixel object resolution of the industrial camera is 5 micrometers per pixel, the physical displacement is 50 multiplied by 0.08 divided by 1000, which equals 0.004 millimeters, or 4 micrometers. The maximum blur span is 4 micrometers divided by 5 micrometers per pixel, which equals 0.8 pixels.
[0075] S222: For each orientation group, take the center angle value of the orientation interval corresponding to the orientation group, calculate the projection length of the maximum fuzzy span in the edge normal direction, and record the projection length as the normal fuzzy span of the orientation group. The method for calculating the center angle value of the orientation interval is: take the arithmetic mean of the upper and lower bound angle values of the orientation interval as the center angle value of the orientation interval. The method for calculating the normal fuzzy span is: multiply the maximum fuzzy span by the cosine value of the center angle value of the orientation interval to obtain the normal fuzzy span.
[0076] See Figure 3 This is a schematic diagram of orientation grouping and normal fuzzy span projection provided in an embodiment of this application. For example... Figure 3 As shown in the figure, this diagram visually illustrates the spatial geometric angular relationship between the edge tangent of the ligation clip profile, the corresponding edge normal direction, and the horizontally set conveying motion direction. It also demonstrates the computational logic of orthogonally projecting the maximum fuzzy span formed along the conveying motion direction onto the edge normal direction. The "normal fuzzy span" labeled in the figure reflects the actual physical extension of the vertical grayscale broadening phenomenon at the current orientation edge during continuous movement of the part. In high-frequency inspection on an assembly line, indiscriminately using the maximum displacement span will overestimate the fuzzy interference experienced by severely tilted edges. By extracting the cosine component of the angle value falling into the center of the orientation interval and mapping it, the effective normal span of the physical projection can be accurately calculated. This projection calculation mode precisely eliminates the false stretching illusion caused by parallel movement on the tilted profile, providing the most critical engineering design parameter basis for the next step of independently matching the strength of the fuzzy degradation correction kernel.
[0077] S223: Normalize the normal fuzzy span to the interval of 0 to 1 to obtain the motion blur degradation index for each orientation group. The normalization method is linear normalization: divide the normal fuzzy span of each orientation group by the maximum fuzzy span to obtain the motion blur degradation index. When the edge orientation angle approaches 0 degrees, the normal fuzzy span approaches the maximum fuzzy span, and the motion blur degradation index approaches 1; when the edge orientation angle approaches 90 degrees, the normal fuzzy span approaches 0, and the motion blur degradation index approaches 0. For example, the motion blur degradation index for the first orientation group is 0.7931 divided by 0.8, which equals 0.9914, and the motion blur degradation index for the sixth orientation group is 0.1044 divided by 0.8, which equals 0.1305.
[0078] S23: Based on the motion blur degradation degree index, generate an independent blur degradation correction kernel and sub-pixel interpolation weight coefficient for each orientation group; Further, step S23 includes: S231: For orientation groups where the motion blur degradation index exceeds a preset high blur threshold, a one-dimensional motion blur point diffusion function with a length equal to the normal blur span is constructed along the transport direction vector. Wiener inverse filtering is performed on the one-dimensional motion blur point diffusion function to obtain a blur degradation correction kernel. The sub-pixel interpolation weight coefficient is set to the weight allocation biased towards the gray-scale moment method, ensuring that the contribution of the gray-scale moment method is greater than that of the interpolation method. The preset high blur threshold is determined based on the upper tolerance limit of blur degradation for sub-pixel positioning accuracy. When the motion blur degradation index exceeds the preset high blur threshold, the impact of blur degradation on sub-pixel positioning accuracy becomes significant, necessitating explicit blur correction. For example, the preset high blur threshold can be set to 0.7. The one-dimensional motion blur point diffusion function is constructed by constructing a one-dimensional uniform distribution kernel with a length equal to the rounded normal blur span plus one pixel along the transport direction vector. The value of each element in the one-dimensional uniform distribution kernel is equal to 1 divided by the kernel length, representing the uniform diffusion of gray-scale energy caused by the uniform displacement of the target object along the motion direction during exposure. The implementation process of the Wiener inverse filtering inversion is as follows: A one-dimensional discrete Fourier transform is performed on the one-dimensional motion blur point spread function to obtain its frequency domain representation. A Wiener inverse filtering transfer function is constructed. The numerator of the Wiener inverse filtering transfer function is the conjugate of the frequency domain representation of the point spread function, and the denominator is the square of the modulus of the frequency domain representation of the point spread function plus the noise power ratio. The noise power ratio is determined based on the ratio of the gray-level variance of the background region to the overall gray-level variance of the image in the original detection image of the ligation clip. For example, the noise power ratio can be set to 0.01. A one-dimensional discrete Fourier inverse transform is performed on the Wiener inverse filtering transfer function to obtain a spatial domain correction kernel. The spatial domain correction kernel is truncated to the same length as the one-dimensional motion blur point spread function to obtain a blur degradation correction kernel. The sub-pixel interpolation weight coefficients are set to a gray-level moment weight of 0.7 and an interpolation weight of 0.3. The sum of the gray-level moment weight and the interpolation weight is equal to 1. The basis for selecting the weight of the gray-scale moment method as greater than that of the interpolation method is as follows: the gray-scale moment method locates the edge by calculating the statistical moments of the gray-scale distribution, and has good robustness to the widening of the residual gray-scale transition area after blur correction. In scenarios with a high degree of blur degradation, the sub-pixel positioning stability of the gray-scale moment method is better than that of the interpolation method.
[0079] S232: For orientation groups where the motion blur degradation index is less than a preset low blur threshold, the blur degradation correction kernel is set to a unit pulse kernel, and no blur correction is performed; the subpixel interpolation weight coefficients are set to the weight allocation of the biased interpolation method, so that the contribution of the interpolation method is greater than the contribution of the gray-scale moment method. The preset low blur threshold is determined by: determining it based on the negligible lower limit of the motion blur degradation amount on the subpixel positioning accuracy. When the motion blur degradation index is lower than the preset low blur threshold, the blur degradation amplitude is already less than the random error magnitude of the subpixel positioning algorithm itself, and performing blur correction will introduce unnecessary inverse filtering noise amplification. For example, the preset low blur threshold can be set to 0.3. The unit pulse kernel is a convolution kernel with only the center element being 1 and the rest being 0, which does not change the image content after convolution with the image. The subpixel interpolation weight coefficients are set to the interpolation method weight equal to 0.7 and the gray-scale moment method weight equal to 0.3. The basis for selecting the interpolation method weight to be greater than the gray-scale moment method weight is that in scenarios with low motion blur degradation, the edge gray-scale transition region is not significantly widened, the gray-scale gradient curve remains steep, and the interpolation method can obtain higher sub-pixel positioning accuracy by performing a quadratic polynomial fitting on the gray-scale gradient curve to find the extreme point.
[0080] S233: For orientation groups where the motion blur degradation index falls between a preset high blur threshold and a preset low blur threshold, a transition correction kernel is generated by linearly interpolating the intensity of the blur degradation correction kernel based on the linear position of the motion blur degradation index between the preset high blur threshold and the preset low blur threshold. Simultaneously, sub-pixel interpolation weights are obtained by linearly interpolating the gray-scale moment method weights and interpolation method weights. The linear position is calculated by subtracting the preset low blur threshold from the motion blur degradation index, then dividing by the difference between the preset high blur threshold and the preset low blur threshold to obtain a linear interpolation factor. The linear interpolation factor ranges from 0 to 1. The transition correction kernel is generated by calculating the complete blur degradation correction kernel corresponding to the current orientation group according to the method in step S231, and then weighting and mixing the complete blur degradation correction kernel with the unit pulse kernel according to the linear interpolation factor.
[0081] See Figure 4This diagram illustrates the generation of a transition correction kernel by mixing a blur degradation correction kernel and a unit pulse kernel, as provided in this embodiment. The left side of the diagram shows the complete noise reduction correction kernel distribution characteristics generated by inverse filtering inversion triggered by a one-dimensional motion blur point diffusion function. The right side depicts an array of unit pulse kernels that does not alter the original energy information of the input image. The central area shows the adaptive transition correction kernel morphology derived by dynamically weighting and summing the two kernels according to a linear distribution law. Since the widening degradation experienced by the edges of the production line clamps is in a continuously and gradually decreasing decay state, applying a strong inversion kernel to slightly blurred edges not only yields minimal results but also excites high-frequency random noise. By mixing and superimposing the inverse filtering kernel, which primarily targets the reduction of stretched width, with the purely transferable unit pulse kernel using linear interpolation coefficients, not only can the modulation of smooth restoration strength be adaptively adjusted, but it also possesses good spectral steady-state control, thereby ensuring consistent smoothness and extremely high grayscale accuracy in pixel restoration within the intermediate domain of the degradation threshold.
[0082] S24: Perform differential subpixel edge localization for each edge pixel in the orientation group; Further, step S24 includes: S241: For each orientation group, extract a local grayscale neighborhood window centered on each edge pixel within the orientation group from the original detection image of the ligation clip. Perform convolution correction on the local grayscale neighborhood window using the blur degradation correction kernel corresponding to the orientation group to obtain the corrected grayscale neighborhood window. The local grayscale neighborhood window is a two-dimensional array composed of the grayscale values of all pixels within a square area centered on the integer pixel coordinates of the edge pixels and with a side length of a preset window size. The preset window size is determined according to the length of the blur degradation correction kernel. The preset window size should be larger than the length of the blur degradation correction kernel to ensure that the convolution operation is performed effectively. For example, the preset window size can be set to 7 pixels by 7 pixels. The implementation process of the convolution correction is as follows: the blur degradation correction kernel is arranged and embedded in a two-dimensional convolution kernel of the same size as the local grayscale neighborhood window along the direction of the transport direction vector, and a two-dimensional convolution operation is performed on the local grayscale neighborhood window.
[0083] See Figure 5This is a schematic diagram of local grayscale neighborhood window convolution correction provided in this application embodiment. In this reconstruction verification process, the left grid area presents a blurred grayscale array (local grayscale neighborhood window) with excessive smudging due to high-speed passing of the lens optical axis and strong directional gradient; subsequently, the schematic diagram shows the process of performing convolution correction on the target area using a calibrated blur degradation correction kernel; finally, it is displayed on the right side of the figure as a high-fidelity reset array with a step gradient that rises sharply again and black and white blocks are differentiated and contrasted (corrected grayscale neighborhood window). In the physical microsecond of automatic feeding and over-station capture of ligation clip parts, the side light reflection is forcibly pulled. By using a pre-made convolution correction kernel to deeply penetrate the underlying pixel matrix for array traversal, the scattered and drifting redundant grayscale energy can be re-focused, so that the true normal fragmentation in the image is strongly enhanced. This effective error correction fundamentally provides a reliable visual contrast gradient base for performing second-order parabolic fitting or calculating the centroid of integrals.
[0084] S242: For the corrected grayscale neighborhood window, calculate the sub-pixel offset using both interpolation and grayscale moment methods. See also Figure 6 This is a schematic diagram comparing the one-dimensional grayscale profile quadratic polynomial fitting and grayscale moment centroid calculation provided in the embodiments of this application. The diagram shows two sub-pixel computing paths placed side by side on a one-dimensional scale profile constructed from the distance coordinate difference: the conceptual picture of the "interpolation method" that relies on continuous quadratic geometric functions to find the peak of the step segment, and the conceptual model of the "grayscale moment" that metaphorically refers to the grayscale size of the point set as the force mass to find the equilibrium point; and the bias guide of the calculated double-track offset is clearly marked at the central axis. The actual detection process is extremely subtle. For the window state with good recovery and sharp rise and fall of data points, the quadratic equation extreme value locking with zero derivative is accurate and precise; while for soft step image points that are severely dispersed over a long period of time and have not completely converged, the solution of the physical space centroid with quality weighting fully demonstrates the anti-aliasing interference and anti-jump potential. The system relies on this strategy to fuse interpolation with grayscale moments, thus building a precise coordinate barrier against various variable exposure errors and light spot defects.
[0085] S243: Based on the sub-pixel interpolation weight coefficients corresponding to the orientation group, the sub-pixel offsets obtained by the interpolation method and the sub-pixel offsets obtained by the gray-scale moment method are weighted and fused to obtain the fused sub-pixel offset. The calculation method of the weighted fusion is as follows: the fused sub-pixel offset equals the interpolation weight multiplied by the sub-pixel offset obtained by the interpolation method plus the gray-scale moment method weight multiplied by the sub-pixel offset obtained by the gray-scale moment method. The integer pixel coordinates of the edge pixels are offset along the unit direction of the local gradient direction vector of the edge pixels by the distance of the fused sub-pixel offset to obtain the sub-pixel edge point coordinates. The sub-pixel edge point coordinates are floating-point two-dimensional coordinates with sub-pixel precision.
[0086] S244: Traverse all edge pixels in all K orientation groups, repeating steps S241 to S243, and summarize the sub-pixel edge coordinates of all edge pixels to form an orientation-adaptive sub-pixel edge point set. The data structure of the orientation-adaptive sub-pixel edge point set is a list, where each element contains a sub-pixel edge coordinate field. The value of the sub-pixel edge coordinate field is a floating-point two-dimensional coordinate. The number of elements in the orientation-adaptive sub-pixel edge point set is equal to the total number of edge pixels in the edge pixel set carrying edge orientation angle labels.
[0087] Specifically, step S2 achieves differentiated sub-pixel edge localization by grouping edge pixels according to their edge orientation angle and assigning an independent blur degradation correction kernel and sub-pixel interpolation weight coefficient to each orientation group. This solves the problem of inconsistent sub-pixel localization accuracy of opposite-oriented edges caused by globally uniform blur correction parameters in existing technologies. In the visual inspection scenario of ligation clip mass production, the movement direction of the conveyor track is fixed and the movement speed remains constant for a short period of time. The motion blur degradation amplitude of edge segments with different orientations on the ligation clip contour can be accurately calculated through the edge orientation angle. If the same intensity of blur correction is uniformly applied to all edge pixels, for edge segments with an edge orientation angle close to 90 degrees, excessive blur correction will amplify the noise in the inverse filtering process and introduce it into the sub-pixel localization result, thus reducing the localization accuracy. For edge segments with an edge orientation angle close to 0 degrees, insufficient blur correction cannot eliminate the broadening effect of motion blur on the grayscale transition area, and the sub-pixel localization result is biased towards the blur center rather than the true edge position. The orientation grouping mechanism in step S2 discretizes this continuously varying blur degradation difference into K independently controllable correction channels. The blur degradation correction kernel strength and sub-pixel interpolation weight coefficient of each correction channel are precisely matched with the motion blur degradation degree index of the orientation group, so that the blur correction intensity received by each edge pixel is exactly equal to its actual motion blur degradation amount, without under-correction or over-correction. At the same time, the weight ratio of the interpolation method and the gray-level moment method is adaptively adjusted according to the motion blur degradation degree index. In the orientation group with a high degree of blur degradation, the weight of the gray-level moment method is increased to take advantage of the robustness of the gray-level moment method in widening the gray-level transition region. In the orientation group with a low degree of blur degradation, the weight of the interpolation method is increased to take advantage of the high-precision positioning advantage of the interpolation method on steep gray-level gradient curves. If step S2 is missing, the contour fitting in step S3 will be performed based on sub-pixel edge points with inconsistent accuracy. The edge points of the straight line segments parallel to the direction of motion in the smooth contour segment have low accuracy, which will cause systematic deviations in the slope and intercept of the least squares straight line fitting result, thus affecting the accuracy of the measurement of the clamp width and length dimensions in step S4.
[0088] S3: Based on the orientation-adaptive sub-pixel edge point set, the ligation clip contour is segmented into heterogeneous feature segments, smooth contour segments and jagged contour segments are identified, and independent fitting step size and smoothing coefficient are configured for smooth contour segments and jagged contour segments respectively. Piecewise adaptive contour fitting is performed to obtain the piecewise fitted contour parameter table. Further, step S3 includes: S31: Sort the sub-pixel edge points in the adaptive sub-pixel edge point set according to the arc length direction along the ligation clip contour to generate an ordered sub-pixel edge point sequence; Specifically, the method for sorting according to the arc length direction of the ligation clip contour is as follows: A starting sub-pixel edge point is selected from the orientation-adaptive sub-pixel edge point set. The selection method for the starting sub-pixel edge point is: select the sub-pixel edge point with the smallest row coordinate among the sub-pixel edge point coordinates. If there are multiple sub-pixel edge points with the smallest row coordinates, select the one with the smallest column coordinate. Taking the starting sub-pixel edge point as the current point, search in the orientation-adaptive sub-pixel edge point set for the sub-pixel edge point with the closest Euclidean distance to the current point that has not yet been sorted, and use it as the next sorting point. Mark the next sorting point as sorted and append it to the end of the ordered sub-pixel edge point sequence. Set the next sorting point as the new current point. Repeat the search process until all sub-pixel edge points in the orientation-adaptive sub-pixel edge point set have been sorted. The data structure of the ordered sub-pixel edge point sequence is an ordered list, where each element is the sub-pixel edge point coordinate, and the order of the elements in the list corresponds to the spatial order of the ligation clip contour along the arc length direction.
[0089] S32: Perform local curvature fluctuation analysis on ordered sub-pixel edge point sequences to identify smooth contour segments and jagged contour segments; Further, step S32 includes: S321: Along the ordered sub-pixel edge point sequence, using a preset curvature analysis window length as the sliding window, perform second-order difference calculations on the sub-pixel edge points within each sliding window to obtain the local curvature value of each sub-pixel edge point within the window. The preset curvature analysis window length is determined based on the following: the curvature analysis window length should be greater than the number of sub-pixel edge points corresponding to a single tooth cycle of the ligature clip anti-slip tooth, to ensure that the sliding window can capture the periodic curvature fluctuation characteristics of the sawtooth contour segment. For example, the preset curvature analysis window length can be set to 15 sub-pixel edge points. The implementation method of the second-order difference calculation is as follows: for each sub-pixel edge point within the sliding window, take the immediately preceding and following sub-pixel edge points in the ordered sub-pixel edge point sequence, calculate the discrete second-order difference value formed by the coordinates of the preceding, current, and following sub-pixel edge points, and use the discrete second-order difference value as the local curvature value of the current sub-pixel edge point. The method for calculating the discrete second-order difference value is as follows: subtract twice the coordinates of the current sub-pixel edge point from the coordinates of the next sub-pixel edge point, add the coordinates of the previous sub-pixel edge point, and take the Euclidean norm of the resulting vector as the discrete second-order difference value.
[0090] S322: Calculate the standard deviation of all local curvature values within each sliding window, and denote the standard deviation as the curvature fluctuation. The standard deviation is calculated as follows: calculate the arithmetic mean of all local curvature values within the sliding window, sum the squares of the differences between each local curvature value and the arithmetic mean, divide by the number of local curvature values within the sliding window, and then take the square root to obtain the curvature fluctuation.
[0091] S323: For each sub-pixel edge point in the ordered sub-pixel edge point sequence, compare the curvature fluctuation of the sliding window containing the sub-pixel edge point with a preset curvature fluctuation threshold. The preset curvature fluctuation threshold is determined as follows: acquire a set of standard ligation clip sample images containing smooth contour segments and jagged contour segments; calculate the curvature fluctuation of all sliding windows in the standard ligation clip sample images according to the process of steps S1 to S322; respectively count the maximum curvature fluctuation of the sliding window corresponding to the smooth contour segment and the minimum curvature fluctuation of the sliding window corresponding to the jagged contour segment; and take the arithmetic mean of the two as the preset curvature fluctuation threshold. For example, the preset curvature fluctuation threshold can be set to 0.05 pixels. Continuous sub-pixel edge point segments with curvature fluctuation less than the preset curvature fluctuation threshold are marked as smooth contour segments, and continuous sub-pixel edge point segments with curvature fluctuation greater than or equal to the preset curvature fluctuation threshold are marked as jagged contour segments. The continuous subpixel edge point segment refers to a segment of subpixel edge points that are adjacent in position and have the same labeling type in an ordered subpixel edge point sequence.
[0092] S324: Perform boundary refinement on the transition region between adjacent smooth contour segments and jagged contour segments. The transition region refers to the area where the curvature fluctuation between the end of an adjacent smooth contour segment and the beginning of a jagged contour segment fluctuates near a preset curvature fluctuation threshold. The boundary refinement is implemented as follows: within the transition region, calculate the forward difference value of the curvature fluctuation point by point along the ordered sub-pixel edge point sequence. The forward difference value is the curvature fluctuation of the sliding window where the current sub-pixel edge point is located minus the curvature fluctuation of the sliding window where the previous sub-pixel edge point is located. If the forward difference value is continuously greater than zero, it indicates that the curvature fluctuation is increasing. The position of the sub-pixel edge point where the forward difference value is first greater than zero is determined as the starting boundary of the jagged contour segment. If the forward difference value is continuously less than zero, it indicates that the curvature fluctuation is decreasing. The position of the sub-pixel edge point where the forward difference value is first less than zero is determined as the starting boundary of the smooth contour segment. The final segmentation boundary positions are determined through boundary refinement. The ordered sub-pixel edge point sequence is divided into several smooth contour segments and several jagged contour segments, with each segment assigned a unique segment number. See also Figure 7 This is a schematic diagram of the curvature fluctuation analysis sliding window and segmentation boundary provided in the embodiments of this application. Figure 7 The system is laid out with a long, orderly array of sub-pixel edge points representing the extension of the real geometric contour; and on its floating surface, a curvature detection sliding window is marked to collect drastic readings in different feature domains through sequential displacement. It can be clearly observed that the values on the left side in the horizontally smooth domain lag far behind the control threshold, and once the system wanders into the dense area of jagged ridges and valleys on the right, it exhibits continuous and highly oscillating high-amplitude fluctuations that exceed the threshold; as this dynamic progresses, the system accurately locates and marks the segmentation boundary point labels of the two types of segments based on positive and negative forward differential logic. For medical ligation clips that require a flat end to determine the total width and arc distance, and rely on anti-slip ripple points to screen for corner breaks, the sliding differential fluctuation monitoring module avoids the problem of tool rotation vibration deviation caused by manually setting fixed coordinate points for cutting, and promotes highly adaptive heterogeneous interval cutting using a non-sensory tracking method.
[0093] S33: Configure independent fitting step size and smoothing coefficient for smooth contour segments and jagged contour segments respectively; Further, step S33 includes: S331: For smooth contour segments, configure a larger fitting step size and a larger smoothing coefficient. The fitting step size for the smooth contour segment is determined by dividing the total number of sub-pixel edge points within the smooth contour segment by a preset number of fitting sampling points for the smooth segment, and rounding the quotient down to obtain the fitting step size. The preset number of fitting sampling points for the smooth segment is determined based on the number of parameters in the least squares fitting model, and should be at least 5 times the number of parameters in the fitting model to ensure the statistical reliability of the fitting. For example, for a straight line fitting model with 2 parameters, the preset number of fitting sampling points for the smooth segment can be set to 20; for a circular arc fitting model with 3 parameters, the preset number of fitting sampling points for the smooth segment can be set to 30. A larger fitting step size allows the sub-pixel edge points participating in a single fitting calculation to cover a longer contour arc segment, enhancing the averaging effect of the fitting result on local random noise. The smoothing coefficient for the smooth contour segment is determined based on the standard deviation of the random noise of the sub-pixel edge point coordinates, and the smoothing coefficient is equal to twice the standard deviation of the random noise of the sub-pixel edge point coordinates. The random noise standard deviation of the subpixel edge point coordinates is obtained by repeatedly acquiring multiple images of the same smooth contour segment of a standard ligation clip sample and calculating the standard deviation of the subpixel edge point coordinates at the same location. For example, the smoothing coefficient of the smooth contour segment can be set to 0.15 pixels.
[0094] S332: For the jagged contour segment, configure a smaller fitting step size and a smaller smoothing coefficient. The fitting step size for the jagged contour segment is set to 1, meaning it participates in the fitting calculation point by point, without skipping any sub-pixel edge points. The smaller fitting step size ensures that each sub-pixel edge point participates in the fitting, preserving the micro-scale spatial details of the anti-slip tooth shape. The smoothing coefficient for the jagged contour segment is determined based on the minimum detectable amplitude of the peak curvature at the tip of the anti-slip tooth. The smoothing coefficient should be less than one-tenth of the difference between the peak curvature amplitude at the tooth tip and the noise curvature fluctuation amplitude to ensure that the smoothing operation does not eliminate the tooth tip features. For example, the smoothing coefficient for the jagged contour segment can be set to 0.03 pixels.
[0095] S34: Perform contour fitting on the smooth contour segment and the jagged contour segment respectively, according to the configured fitting step size and smoothing coefficient. Further, step S34 includes: S341: For each smooth contour segment, determine the fitting model type based on the geometric shape of the smooth contour segment. The method for determining the geometric shape is as follows: Take the coordinates of the first sub-pixel edge point, the middle sub-pixel edge point, and the last sub-pixel edge point of the smooth contour segment, calculate the area of the triangle formed by the coordinates of the three sub-pixel edge points, and use the ratio of the triangle area to the square of the longest side length among the coordinates of the three sub-pixel edge points as the curvature index. If the curvature index is less than the preset curvature threshold, the smooth contour segment is determined to be a straight segment, and least squares straight line fitting is used; if the curvature index is greater than or equal to the preset curvature threshold, the smooth contour segment is determined to be an arc segment, and least squares arc fitting is used. The preset curvature threshold is determined based on the difference in geometric characteristics between straight segments and arc segments in the ligation clip product drawing. For example, the preset curvature threshold can be set to 0.01. During the fitting process, points are sequentially selected from the ordered sub-pixel edge point sequence within the smooth contour segment according to the fitting step size corresponding to the smooth contour segment. Weighted average preprocessing is performed on the coordinates of the selected sub-pixel edge points. The weighted average preprocessing method is as follows: for each selected sub-pixel edge point, the standard deviation of the Gaussian weight function is used as the smoothness coefficient corresponding to the smooth contour segment, and the Gaussian weighted average coordinates of the selected sub-pixel edge point and several adjacent sub-pixel edge points are calculated.
[0096] See Figure 8 This diagram illustrates the smooth contour segment fitting step size sampling and weighted average preprocessing provided in this application embodiment. It explains the large displacement extraction technique used to handle long arcs or wide-angle straight sections: a sampling scale with obvious skipping characteristics (fitting step size sampling) is set along the bottom sequence flow; directly above, a Gaussian distribution shape mask simulating distance attenuation intervention weights is erected; within this influence envelope, the target training coordinates are deeply affected by the combined tension interference of the distribution ratio of surrounding side points (differences in the size of small circle groups), ultimately causing the sampling center coordinates to deflect and move to the smooth "preprocessed sub-pixel edge point coordinates" region marked with a fork. Because the smooth segment point group responsible for measuring the major and minor axes and end arcs is affected by material grain roughness and shooting point frequency noise impurities, directly embedding it into the global straight line fitting and other micro-element tolerance conversion paradigms without refinement will likely encounter random jitter. By relying on this cross-extraction and low-pass weight amortization pre-washing process, an extremely robust geometric benchmark foundation is locked for the repeatedly reliable output of the size extraction.
[0097] S342: For each sawtooth contour segment, points are sequentially selected according to the fitting step size (i.e., step size of 1) corresponding to the sawtooth contour segment, and a cubic B-spline curve is used for fitting. The method for implementing the cubic B-spline curve fitting is as follows: the coordinates of all sub-pixel edge points within the sawtooth contour segment are used as data points, and the smoothing coefficient corresponding to the sawtooth contour segment is used as the smoothing factor in the cubic B-spline fitting. The smoothing factor controls the approximation degree of the cubic B-spline curve to the data points. The smaller the smoothing factor, the closer the cubic B-spline curve is to the data points and the more micro-scale features are retained; the larger the smoothing factor, the smoother the cubic B-spline curve and the more micro-scale features are suppressed. The control point sequence and node vector are solved by the cubic B-spline fitting algorithm to minimize the sum of squared residuals between the cubic B-spline curve and the data points under the condition of satisfying the smoothing factor constraint.
[0098] See Figure 9 This is a schematic diagram illustrating the relationship between control points and data points for B-spline fitting of the serrated contour segment provided in this application embodiment. This diagram reveals the core reconstructed skeletal mechanism of the anti-slip micro-tooth row region. The visual bottom is covered with dense, periodically surging sub-pixel edge data point waves, while the outer edge features a series of B-spline control point arrays acting as a marionette mechanism. Under the tension and relaxation constraints of this tensile gravitational network, the reconstructed cubic B-spline curve traverses it, maintaining an extremely precise and dense approximation of the attachment surface at each apical cone and its trough groove segment. As the main force responsible for hemostasis and gripping firmly on the inner side of the medical clamp, the presence or absence of microscopic defects on its surface is crucial to its quality; all global smoothing will wear down these original sharp edges like sandpaper. By introducing data point by point and using a small-scale smoothing factor to generate an elastic cubic skeleton network, the original tooth profile is accurately restored with excellent anti-torsion tolerance. This provides extremely detailed mathematical analysis wire for subsequent searches to capture subtle curvature differences and discover tiny corrosion pits.
[0099] S343: Summarize and arrange the fitting parameters of all smooth contour segments and the B-spline control point sequences and node vectors of all serrated contour segments according to the segment number to generate a segmented fitting contour parameter table. The data structure of the segmented fitting contour parameter table is an ordered table, where each row corresponds to a segment, and each row contains the following fields: segment number, segment type label (smooth contour segment or serrated contour segment), fitting model type (linear, circular, or cubic B-spline), and fitting parameters (slope and intercept of a straight line, or center coordinates and radius of a circle, or B-spline control point sequence and node vector). The rows in the segmented fitting contour parameter table are arranged in ascending order of segment number.
[0100] Specifically, step S3 addresses the problem in existing technologies where uniform fitting parameters cannot simultaneously adapt to the accuracy requirements of both smooth and serrated contour segments by performing heterogeneous feature segment segmentation on the ligation clip contour and configuring independent fitting step sizes and smoothing coefficients for each segment. The straight body segment and the arc segment at the tail of the smooth contour segment in the ligation clip contour are used for size verification. Their fitting objective is to obtain smooth geometric parameters to calculate key dimensional features such as width, length, and radius of curvature. Therefore, a larger fitting step size and a larger smoothing coefficient are needed to effectively suppress random noise in the sub-pixel edge point coordinates, making the fitting results more stable. The anti-slip teeth at the biting end of the serrated contour segment are used for defect detection. Their fitting objective is to retain the micro-scale features of tooth tips and valleys to identify missing teeth and wear micro-defects. Therefore, a smaller fitting step size and a smaller smoothing coefficient are needed to avoid smoothing out the tooth profile details. If the same fitting step size and smoothing coefficient are used for both smooth and sawtooth contour segments, the tooth tip features of the sawtooth contour segment will be over-smoothed under the smoothing coefficient required to reduce noise in the smooth contour segment, leading to a decrease in the sensitivity of tooth loss detection and wear micro-defect detection in step S4. Under the smoothing coefficient required to preserve tooth shape details in the sawtooth contour segment, the fitting results of the smooth contour segment will be affected by random noise, leading to an increase in the repeatability deviation of the dimensional measurement in step S4. The curvature fluctuation analysis in step S3 utilizes the essential difference in the curvature change patterns of the smooth and sawtooth contour segments. The curvature of the smooth contour segment changes slowly or remains constant along the arc length direction, while the curvature of the sawtooth contour segment exhibits periodic large fluctuations due to the alternation of tooth tips and tooth valleys. This difference is quantified into a curvature fluctuation scalar, realizing the automated segmentation of the two types of heterogeneous feature segments and avoiding the operational costs and subjective errors of relying on manual annotation of segment boundaries.
[0101] S4: Based on the segmented fitting contour parameter table, perform size verification on smooth contour segments and anti-slip tooth defect detection on sawtooth contour segments. Output the quality inspection judgment conclusion of the ligation clip by combining the size verification results and the anti-slip tooth defect detection results. Further, step S4 includes: S41: Extract the fitting parameters of all smooth contour segments from the segmented fitting contour parameter table, and calculate the key size features of the ligation clip based on the fitting parameters. Further, step S41 includes: S411: For smooth contour segments belonging to the straight segment, calculate the width and length dimensions of the ligation clip body based on the slope and intercept of the straight line. The method for calculating the clip body width is as follows: Identify two smooth contour segments belonging to the straight segment from the segmented fitting contour parameter table. The two smooth contour segments belonging to the straight segment correspond to the two long side contour lines of the ligation clip body, respectively. Calculate the vertical distance between the two fitted lines as the clip body width dimension. The method for calculating the vertical distance is as follows: Subtract the absolute value of the intercept of the second fitted line from the intercept of the first fitted line, divide by 1, and add the arithmetic square root of the square of the slope of the first fitted line to obtain the vertical distance between the two fitted lines. The method for calculating the clip body length is as follows: Take the coordinates of the first sub-pixel edge point and the last sub-pixel edge point of the smooth contour segment corresponding to any one of the two fitted lines, calculate the projection distance of the first sub-pixel edge point coordinates and the last sub-pixel edge point coordinates along the direction of the fitted line, and use the projection distance as the clip body length dimension.
[0102] S412: For smooth contour segments belonging to the arc segment, calculate the radius of curvature and arc span angle of the tail arc of the ligation clip based on the center coordinates and radius. The radius of curvature is directly taken from the fitted output radius value. The arc span angle is calculated as follows: take the coordinates of the first and last sub-pixel edge points of the smooth contour segment belonging to the arc segment, calculate the direction angle of the first and last sub-pixel edge point coordinates relative to the center coordinates, and take the absolute value of the difference between the two direction angles as the arc span angle.
[0103] S413: Summarize all key dimensional features, including clamp width, clamp length, radius of curvature, and arc span, to form a set of dimensional features. The data structure of the set of dimensional features is a dictionary, where each key is the name of a key dimensional feature, and each value is the corresponding numerical value.
[0104] S42: Compare each critical dimensional feature in the dimensional feature set with the corresponding upper and lower limits in the preset ligation clip dimensional tolerance standard. The preset ligation clip dimensional tolerance standard is read from the product parameter configuration file of the testing system. The product parameter configuration file stores the upper and lower limits of each critical dimensional feature for each specification and model of ligation clip. The upper and lower limits are determined according to the ligation clip product drawings and medical device registration inspection standards. If all critical dimensional features in the dimensional feature set fall within the corresponding tolerance range, that is, the value of each critical dimensional feature is greater than or equal to the corresponding lower limit and less than or equal to the corresponding upper limit, the dimensional verification result is marked as dimensionally qualified. Otherwise, the dimensional verification result is marked as dimensionally unqualified, and the out-of-tolerance item is recorded. The out-of-tolerance item includes the name, measured value, and corresponding upper and lower limits of the critical dimensional feature that exceeds the tolerance range.
[0105] S43: Extract the B-spline control point sequence and node vector of all sawtooth contour segments from the segmented fitting contour parameter table, and perform anti-slip tooth defect detection on the sawtooth contour segments. Further, step S43 includes: S431: Reconstruct the continuous fitting curve of the sawtooth contour segment based on the B-spline control point sequence and node vector, and obtain the sawtooth contour sampling point sequence by sampling at equal intervals along the continuous fitting curve. The reconstruction method of the continuous fitting curve is as follows: Based on the B-spline control point sequence and node vector, use the cubic B-spline basis function formula to calculate the parameterized representation of the continuous fitting curve in the parameter range of 0 to 1, take values at equal intervals along the parameter range with a preset sampling interval, calculate the two-dimensional coordinate point on the continuous fitting curve corresponding to each parameter value, and arrange all two-dimensional coordinate points in ascending order of parameter value to form the sawtooth contour sampling point sequence. The preset sampling interval is determined based on the anti-slip tooth pitch, and the preset sampling interval should be less than one-fifth of the anti-slip tooth pitch to ensure that the sampling density is sufficient to capture the tooth shape features. For example, the preset sampling interval can be set to one-tenth of the standard anti-slip tooth pitch.
[0106] S432: Calculate the local curvature sequence for the serrated profile sampling point sequence. The calculation method for the local curvature sequence is as follows: For each sampling point in the serrated profile sampling point sequence, take the immediately preceding and following sampling points, and calculate the local curvature value using the three-point discrete curvature formula. The local curvature values of all sampling points are arranged in the order of the sampling points to form the local curvature sequence. Perform peak detection on the local curvature sequence to identify the tooth tip corresponding to each curvature peak position and the tooth valley corresponding to each curvature valley position. The peak detection method is as follows: Traverse the local curvature sequence. If a local curvature value is greater than its immediately preceding local curvature value and greater than its immediately following local curvature value, it is marked as a curvature peak position, corresponding to a tooth tip; if a local curvature value is less than its immediately preceding and less than its immediately following local curvature value, it is marked as a curvature valley position, corresponding to a tooth valley. Count the number of all curvature peak positions as the actual number of teeth.
[0107] S433: Compare the actual number of teeth with the preset standard number of teeth. The preset standard number of teeth is read from the product parameter configuration file of the detection system and is determined according to the design number of anti-slip teeth in the ligation clip product drawing. If the actual number of teeth is less than the preset standard number of teeth, it is determined that there is a missing tooth defect, and the number of missing teeth in the missing tooth defect is recorded as the preset standard number of teeth minus the actual number of teeth.
[0108] S434: Calculate the tooth pitch between adjacent tooth tips and the peak curvature amplitude at each tooth tip. The tooth pitch is calculated as follows: for sampling points corresponding to two adjacent peak curvature positions in the sawtooth profile sampling point sequence, calculate the Euclidean distance between the two sampling points' two-dimensional coordinates, and use the Euclidean distance as the tooth pitch between adjacent tooth tips. The peak curvature amplitude is the local curvature value corresponding to the peak curvature position. Compare the tooth pitch with a preset standard tooth pitch, which is read from the product parameter configuration file of the detection system. Compare the peak curvature amplitude with a preset standard peak curvature range, which is determined based on the statistical distribution of the peak curvature amplitude at the anti-slip tooth tips of qualified ligation clip samples. Specifically, acquire a set of images of qualified ligation clip samples, calculate the peak curvature amplitude at all tooth tips according to the process from steps S1 to S432, take the mean of the peak curvature amplitude minus 3 times the standard deviation as the lower limit of the preset standard peak curvature range, and take the mean of the peak curvature amplitude plus 3 times the standard deviation as the upper limit of the preset standard peak curvature range. The method for determining the preset tooth pitch deviation threshold is as follows: Images of a set of qualified ligation clip samples are acquired. The tooth pitch between all adjacent tooth tips is calculated using the same procedure. The mean of the absolute values of the differences between the tooth pitch and the preset standard tooth pitch, plus three times the standard deviation, is taken as the preset tooth pitch deviation threshold. If the absolute value of the difference between the tooth pitch and the preset standard tooth pitch exceeds the preset tooth pitch deviation threshold, or if the peak curvature amplitude is lower than the lower limit of the preset standard peak curvature range, then the corresponding tooth position is determined to have a micro-defect of wear. The corresponding tooth position is numbered according to the sequence number of the peak curvature position in the local curvature sequence.
[0109] S435: Summarize the results of the missing tooth defect assessment and the wear micro-defect assessment. If there are no missing tooth defects and no wear micro-defects, the anti-slip tooth defect detection result is marked as tooth shape qualified. Otherwise, the anti-slip tooth defect detection result is marked as tooth shape unqualified, and the defect tooth position number and defect type are recorded. The defect types include missing tooth defects and wear micro-defects.
[0110] S44: The quality inspection conclusion for the ligation clip is generated by combining the dimensional verification results and the anti-slip tooth defect detection results. If the dimensional verification result is that the dimensions are qualified and the anti-slip tooth defect detection result is that the tooth shape is qualified, then the quality inspection conclusion for the ligation clip is qualified. If the dimensional verification result is that the dimensions are unqualified or the anti-slip tooth defect detection result is that the tooth shape is unqualified, then the quality inspection conclusion for the ligation clip is unqualified. The specific out-of-tolerance item or defective tooth position number and defect type are recorded in the quality inspection conclusion for subsequent use by the unqualified product sorting mechanism and the quality traceability system. The quality inspection conclusion for the ligation clip is sent to the controller of the unqualified product sorting mechanism through the communication interface of the detection system. When the quality inspection conclusion for the ligation clip is unqualified, the controller of the unqualified product sorting mechanism drives the sorting actuator to remove the corresponding ligation clip part from the conveyor track to the unqualified product collection tank; when the quality inspection conclusion for the ligation clip is qualified, the ligation clip part continues to be conveyed to the downstream station along the conveyor track.
[0111] Specifically, step S4 transforms the segmented fitting contour parameter table output in step S3 into executable quality inspection judgment conclusions and sorting control actions, realizing a complete closed loop from sub-pixel contour data to engineering quality inspection decisions. The design of performing dimensional verification and anti-slip tooth defect detection on smooth and sawtooth contour segments in step S4, respectively, forms a functional-level synergy with the design of configuring independent fitting parameters for the two types of heterogeneous feature segments in step S3: the large fitting step size and large smoothing coefficient of the smooth contour segment in step S3 ensure the stability of the fitting parameters, giving high repeatability accuracy to the clamp width, clamp length, radius of curvature, and arc span angle dimensions calculated from the fitting parameters in step S4; the small fitting step size and small smoothing coefficient of the sawtooth contour segment in step S3 preserve the micro-scale characteristics of the anti-slip tooth profile, ensuring the sensitivity of identifying tooth tips and valleys through curvature peak detection in step S4, enabling the detection of wear micro-defects corresponding to the slight attenuation of the tooth tip curvature peak amplitude. The orientation-adaptive sub-pixel edge positioning in step S2 provides a fundamental guarantee for the accuracy of steps S3 and S4: if step S2 does not perform differentiated fuzz correction on edge pixels with different orientations, the low sub-pixel positioning accuracy of the long side edge of the clamp parallel to the conveying direction will directly lead to an increase in the measurement repeatability error of the clamp width dimension in step S4. Furthermore, the inconsistent positioning accuracy of the tooth surface edges with different orientations in the sawtooth contour segment will result in a systematic deviation in the calculation results of the tooth pitch and peak curvature amplitude in step S4, increasing the risk of missing wear micro-defects. Through the hierarchical collaboration of four steps—edge orientation angle annotation in step S1, differentiated sub-pixel positioning in step S2, adaptive fitting of heterogeneous feature segments in step S3, and classification quality inspection judgment in step S4—this technical solution simultaneously meets the dual quality inspection requirements of high repeatability in dimensional measurement and high sensitivity in micro-defect detection in the automated visual inspection scenario of ligation clip mass production. This enables the ligation clip quality inspection system to stably output inspection results that meet the compliance requirements of Class III medical device quality inspection under continuous movement of the conveying track.
[0112] Example 2: This embodiment, based on Embodiment 1, provides a ligation clip contour fitting system based on sub-pixel edge extraction, such as... Figure 10 As shown, it includes: Edge detection and annotation module: used to acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain an initial set of edge pixels, calculate the local gradient direction of each edge pixel in the initial set of edge pixels and obtain the angle between it and the direction of the transport motion, and generate an edge pixel set carrying edge orientation angle annotation; Subpixel localization module: Based on the set of edge pixels labeled with edge orientation angle, divide the edge pixels into multiple orientation groups according to the edge orientation angle, assign an independent fuzzy degradation correction kernel and subpixel interpolation weight coefficient to each orientation group, and perform differentiated subpixel edge localization on the edge pixels in each orientation group to obtain an orientation-adaptive subpixel edge point set; Segmented Fitting Module: Based on the orientation adaptive sub-pixel edge point set, the ligation clip contour is segmented into heterogeneous feature segments, smooth contour segments and jagged contour segments are identified, independent fitting step size and smoothing coefficient are configured for the smooth contour segments and jagged contour segments respectively, segmented adaptive contour fitting is performed, and segmented fitted contour parameter table is obtained. Quality inspection judgment module: Based on the segmented fitting contour parameter table, it performs size verification on the smooth contour segment, performs anti-slip tooth defect detection on the serrated contour segment, and outputs the quality inspection judgment conclusion of the ligation clip by combining the size verification result and the anti-slip tooth defect detection result.
Claims
1. A method for fitting the contour of a ligation clip based on sub-pixel edge extraction, characterized in that, The method includes: S1: Acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain an initial set of edge pixels, calculate the local gradient direction of each edge pixel in the initial set of edge pixels and obtain the angle between it and the direction of the transport motion, and generate an edge pixel set carrying edge orientation angle label; S2: Based on the set of edge pixels carrying edge orientation angle labels, the range of edge orientation angle values from 0 degrees to 90 degrees is uniformly divided into K orientation intervals. Each edge pixel in the set of edge pixels carrying edge orientation angle labels is assigned to a corresponding orientation group according to the orientation interval into which the edge orientation angle falls, resulting in K orientation groups. For each orientation group, the motion blur degradation degree index of the orientation group is calculated based on the center angle value of the orientation interval corresponding to the orientation group. Based on the motion blur degradation degree index, an independent blur degradation correction kernel and sub-pixel interpolation weight coefficient are generated for each orientation group. For orientation groups whose motion blur degradation degree index is greater than a preset high blur threshold, a one-dimensional motion blur point diffusion function is constructed along the direction of the transport direction vector. The blur degradation correction kernel is obtained by performing Wiener inverse filtering on the one-dimensional motion blur point diffusion function. The subpixel interpolation weight coefficient is set to be greater than the gray-scale moment weight. For orientation groups where the motion blur degradation index is less than a preset low blur threshold, the blur degradation correction kernel is set to a unit pulse kernel, and the subpixel interpolation weight coefficient is set to be greater than the gray-scale moment weight. For orientation groups where the motion blur degradation index is between a preset high blur threshold and a preset low blur threshold, linear interpolation is performed on the blur degradation correction kernel strength and the subpixel interpolation weight coefficient according to the linear position of the motion blur degradation index. Differential subpixel edge localization is performed on the edge pixels in each orientation group to obtain an orientation-adaptive subpixel edge point set. S3: Based on the orientation adaptive sub-pixel edge point set, the ligation clip contour is segmented into heterogeneous feature segments, smooth contour segments and jagged contour segments are identified, and independent fitting step size and smoothing coefficient are configured for the smooth contour segments and jagged contour segments respectively. Piecewise adaptive contour fitting is performed to obtain the piecewise fitted contour parameter table. S4: Based on the segmented fitting contour parameter table, perform size verification on the smooth contour segment, perform anti-slip tooth defect detection on the serrated contour segment, and output the ligation clip quality inspection judgment conclusion by combining the size verification result and the anti-slip tooth defect detection result.
2. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 1, characterized in that, The step of generating the set of edge pixels carrying edge orientation corner labels includes: An industrial camera deployed at the vision inspection station is used to trigger the acquisition of the original inspection image of the ligation clip when it passes the conveyor track. At the same time, the movement direction of the conveyor track is recorded and represented as a unit direction vector, which is denoted as the conveyor direction vector. Gaussian smoothing filter is applied to the original detection image of the ligation clip to remove high-frequency noise and obtain a smoothed image. The horizontal gradient component and the vertical gradient component are calculated on the smoothed image to obtain the horizontal gradient component map and the vertical gradient component map. The gradient magnitude of each pixel is calculated based on the horizontal gradient component map and the vertical gradient component map. Pixels with gradient magnitudes greater than a preset edge detection threshold are marked as edge pixels, forming an initial set of edge pixels. For each edge pixel in the initial set of edge pixels, calculate the local gradient direction vector, calculate the angle between the local gradient direction vector and the transmission direction vector, map the angle to the range of 0 degrees to 90 degrees to obtain the edge orientation angle, and generate a set of edge pixels with edge orientation angle labels.
3. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 2, characterized in that, The method for determining the conveying direction vector includes: During the equipment installation and commissioning phase, two reference points are marked on the track surface along the direction of movement of the conveying track. The image coordinates of the two reference points are collected by an industrial camera. The difference between the image coordinates of the two reference points is normalized to obtain the conveying direction vector. The conveying direction vector is stored in the parameter configuration file of the detection system for direct reading in subsequent detection.
4. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 1, characterized in that, The steps for calculating the motion blur degradation index towards the group include: Based on the movement speed of the conveyor track and the exposure time of the industrial camera, the maximum blur pixel span along the conveying direction vector is calculated and denoted as the maximum blur span. For each orientation group, take the center angle value of the orientation interval corresponding to the orientation group, calculate the projection length of the maximum fuzzy span in the edge normal direction, and denot it as the normal fuzzy span; The normal fuzzy span is normalized to the interval between 0 and 1 to obtain the motion fuzzy degradation index for each orientation group.
5. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 1, characterized in that, The step of obtaining the piecewise fitted contour parameter table includes: The sub-pixel edge points in the adaptive sub-pixel edge point set are sorted according to the arc length direction along the ligation clip contour to generate an ordered sub-pixel edge point sequence. Perform local curvature fluctuation analysis on the ordered sub-pixel edge point sequence to identify smooth contour segments and jagged contour segments; Independent fitting step size and smoothing coefficient are configured for the smooth contour segment and the serrated contour segment, respectively; Based on the configured fitting step size and smoothing coefficient, contour fitting is performed on the smooth contour segment and the sawtooth contour segment respectively, generating a segmented fitting contour parameter table.
6. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 5, characterized in that, The steps for identifying smooth contour segments and jagged contour segments include: Along the ordered subpixel edge point sequence, with a preset curvature analysis window length as the sliding window, second-order difference calculation is performed on the subpixel edge points within each sliding window to obtain the local curvature value of each subpixel edge point within the window; Calculate the standard deviation of all local curvature values within each sliding window, and denote it as the curvature fluctuation. Continuous subpixel edge segments with curvature fluctuation less than a preset curvature fluctuation threshold are marked as smooth contour segments, while continuous subpixel edge segments with curvature fluctuation greater than or equal to the preset curvature fluctuation threshold are marked as jagged contour segments.
7. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 5, characterized in that, The step of configuring independent fitting step sizes and smoothing coefficients for smooth contour segments and jagged contour segments respectively includes: For smooth contour segments, configure a fitting step size greater than a preset step size threshold and a smoothing coefficient greater than a preset smoothing threshold; For the jagged contour segment, configure the fitting step size as 1 and the smoothing coefficient as less than the preset smoothing threshold.
8. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 1, characterized in that, The steps for outputting the quality inspection conclusion of the ligation clip include: Extract the fitting parameters of all smooth contour segments from the segmented fitting contour parameter table, calculate the key size features of the ligation clip, and compare the key size features with the preset ligation clip size tolerance standard to obtain the size verification result. Extract the fitting parameters of all sawtooth contour segments from the segmented fitting contour parameter table, perform anti-slip tooth defect detection on the sawtooth contour segments, and obtain the anti-slip tooth defect detection results. The quality inspection conclusion of the ligation clip is generated by combining the dimensional verification results and the anti-slip tooth defect detection results.
9. The ligation clip contour fitting method based on sub-pixel edge extraction according to claim 8, characterized in that, The step of performing anti-slip tooth defect detection on the sawtooth contour segment includes: The continuous fitting curve of the sawtooth profile segment is reconstructed based on the B-spline control point sequence and node vector of the sawtooth profile segment, and the sawtooth profile sampling point sequence is obtained by sampling at equal intervals along the continuous fitting curve. Calculate the local curvature sequence for the serrated contour sampling point sequence, perform peak detection to identify tooth tips and tooth valleys, count the actual number of teeth, and compare the actual number of teeth with the preset standard number of teeth to determine whether there is a missing tooth defect; Calculate the tooth pitch between adjacent tooth tips and the peak curvature amplitude at each tooth tip, and compare them with the preset standard tooth pitch and the preset standard peak curvature range to determine whether there are wear micro-defects.
10. A ligation clip contour fitting system based on sub-pixel edge extraction, used to implement the ligation clip contour fitting method based on sub-pixel edge extraction as described in any one of claims 1-9, characterized in that, The system includes: Edge detection and annotation module: used to acquire the original detection image of the ligation clip, perform pixel-level edge detection on the original detection image of the ligation clip to obtain an initial set of edge pixels, calculate the local gradient direction of each edge pixel in the initial set of edge pixels and obtain the angle between it and the direction of the transport motion, and generate an edge pixel set carrying edge orientation angle annotation; Sub-pixel positioning module: Based on the set of edge pixels carrying edge orientation angle labels, it uniformly divides the range of edge orientation angle from 0 degrees to 90 degrees into K orientation intervals. Each edge pixel in the set of edge pixels carrying edge orientation angle labels is assigned to a corresponding orientation group according to the orientation interval into which the edge orientation angle falls, resulting in K orientation groups. For each orientation group, it calculates the motion blur degradation degree index based on the center angle value of the orientation interval corresponding to the orientation group. Based on the motion blur degradation degree index, it generates an independent blur degradation correction kernel and sub-pixel interpolation weight coefficient for each orientation group. For orientation groups with a motion blur degradation degree index greater than a preset high blur threshold, a one-dimensional motion blur point is constructed along the direction of the transport direction vector. A diffusion function is used to perform Wiener inverse filtering on the one-dimensional motion blur point diffusion function to obtain a blur degradation correction kernel. The sub-pixel interpolation weight coefficients are set to be greater than the gray-scale moment method weights. For orientation groups where the motion blur degradation index is less than a preset low blur threshold, the blur degradation correction kernel is set to a unit impulse kernel, and the sub-pixel interpolation weight coefficients are set to be greater than the gray-scale moment method weights. For orientation groups where the motion blur degradation index is between a preset high blur threshold and a preset low blur threshold, linear interpolation is performed on the blur degradation correction kernel strength and sub-pixel interpolation weight coefficients according to the linear position of the motion blur degradation index. Differential sub-pixel edge localization is performed on the edge pixels in each orientation group to obtain an orientation-adaptive sub-pixel edge point set. Segmented Fitting Module: Based on the orientation adaptive sub-pixel edge point set, the ligation clip contour is segmented into heterogeneous feature segments, smooth contour segments and jagged contour segments are identified, independent fitting step size and smoothing coefficient are configured for the smooth contour segments and jagged contour segments respectively, segmented adaptive contour fitting is performed, and segmented fitted contour parameter table is obtained. Quality inspection judgment module: Based on the segmented fitting contour parameter table, it performs size verification on the smooth contour segment, performs anti-slip tooth defect detection on the serrated contour segment, and outputs the quality inspection judgment conclusion of the ligation clip by combining the size verification result and the anti-slip tooth defect detection result.
Citation Information
Patent Citations
Hyperspectral remote sensing image correction method and system based on superpixel uniformity constraint
CN122289063A