Method for detecting surface defects of heat-shrinkable tube based on image feature recognition

By using an adaptive shape factor super-Gaussian mathematical model and nonlinear mapping technology, the problem of false detection and missed detection in the surface defect detection of heat shrink tubing was solved, and accurate detection was achieved under complex lighting and deformation environments.

CN121708023BActive Publication Date: 2026-04-21SUZHOU HAMPOOL NEW MATERIAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUZHOU HAMPOOL NEW MATERIAL TECH CO LTD
Filing Date
2026-02-13
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing industrial vision inspection technologies suffer from high false detection and false negative rates when detecting surface defects in heat shrink tubing because the models cannot adapt to tubing deformation and high-light environments. This makes it difficult to accurately detect minute defects under complex lighting and deformation interference.

Method used

By cropping the grayscale image of heat shrink tubing, an adaptive shape factor super-Gaussian mathematical model is constructed. Combined with the normalization of difference intensity and nonlinear mapping, an ideal background image is generated and threshold segmentation is performed to eliminate fitting residuals and improve the accuracy of defect detection.

Benefits of technology

Under complex lighting and deformation interference, it significantly improves the detection accuracy of surface defects in heat shrink tubing, effectively suppresses high light interference and stretches the intensity of weak defect signals, thereby reducing the false detection rate and the missed detection rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121708023B_ABST
    Figure CN121708023B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of image processing technology, specifically relating to a method for detecting surface defects in heat shrink tubing expansion based on image feature recognition. The method includes: acquiring a grayscale image of the heat shrink tubing and cropping it to obtain a region of interest (ROI) image; traversing each row of the ROI image, statistically analyzing the proportion of pixels with normalized grayscale values ​​greater than a statistical threshold to obtain a flatness ratio, and calculating an adaptive shape factor based on the flatness ratio; constructing a super-Gaussian mathematical model using the adaptive shape factor, and optimizing parameters based on an effective sample set of the ROI image to generate an ideal background image; performing difference operations and nonlinear enhancement processing on the ideal background image and the ROI image to obtain an enhanced difference image; and performing threshold segmentation and connected component analysis on the enhanced difference image to extract the defect region. This invention eliminates background fitting errors caused by tubing geometric deformation and improves the detection accuracy of subtle defects in heat shrink tubing expansion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a method for detecting surface defects in heat shrink tubing expansion based on image feature recognition. Background Technology

[0002] In the manufacturing process of heat shrink tubing, the expansion process is a crucial step that determines its final shrinkage performance. However, due to random influences such as uneven heating temperature, fluctuations in mechanical traction force, and impurities in raw materials, the expanded tubing surface is prone to minor defects such as scratches, black spots, bubbles, and pits. These defects not only directly affect the product's appearance consistency but, in severe cases, can lead to decreased insulation strength or impaired mechanical properties, thus posing safety hazards during subsequent use. Therefore, defect detection on the surface of heat shrink tubing is of great significance for ensuring product quality and production safety.

[0003] Current industrial visual inspection technologies typically employ background subtraction to extract surface defects. This involves constructing an ideal mathematical model to fit the illumination distribution on the surface of the heat shrink tubing, and then performing a difference operation between the original acquired image and the background model to separate the defect target. Since heat shrink tubing ideally presents a regular cylindrical surface, existing mainstream inspection schemes usually assume that its lateral illumination grayscale distribution conforms to a standard normal distribution. They also use a standard Gaussian model with fixed shape parameters to fit and reconstruct the diffuse reflection background on the tubing surface, using this as the benchmark for defect judgment.

[0004] However, in actual production lines, the cross-sectional geometry of heat shrink tubing does not always maintain a standard circle, but rather fluctuates dynamically between a standard cylinder and a flat elliptical cylinder. When the tubing becomes flattened due to process influences, the illumination distribution at its top exhibits a significant flat-top characteristic. The fixed Gaussian model based on the standard normal distribution can only describe a peaked distribution and cannot adapt to this flat-top illumination characteristic. This results in the model generating an unavoidable structural residual in the central region when fitting the flat tubing. These residuals are easily misjudged by the system as surface defects. In addition, the surface of heat shrink tubing is a typical highly reflective curved surface, which forms a high-brightness specular reflection strip along the axis during imaging. The grayscale value of real defects such as tiny scratches is often only slightly higher than the background noise, resulting in extremely low contrast between the two. Traditional linear differential processing is difficult to effectively separate weak defect signals while suppressing high-light interference. This leads to a high false detection rate and false negative rate when the detection system faces tubing deformation and complex lighting environments. Summary of the Invention

[0005] To address the technical problems of existing technologies, such as large fitting residuals due to the model's inability to adapt to tube deformation and the difficulty in separating weak defects under strong reflective light, resulting in high false negative and false negative rates, this invention provides a method for detecting surface defects on expanded heat shrink tubing based on image feature recognition, comprising:

[0006] The grayscale image of the heat shrink tubing is cropped to obtain the region of interest (ROI) image. The ROI image is then iterated row by row, and the flatness ratio of each row is calculated based on the grayscale distribution of pixels. An adaptive shape factor is then determined for each row based on the flatness ratio. A super-Gaussian mathematical model incorporating the adaptive shape factor is constructed, and this model is used to fit the ROI image row by row to generate an ideal background image. The difference intensity between the ideal background image and the ROI image is calculated, and the difference intensity is normalized and nonlinearly mapped to obtain an enhanced difference image. Thresholding is performed on the enhanced difference image, and surface defects on the heat shrink tubing are determined based on the segmentation results.

[0007] This invention calculates the flatness ratio by analyzing the grayscale distribution of each row in the region of interest image, thereby perceiving the geometric morphological characteristics of the heat shrink tubing's cross-section changing from a circular to a flat shape. Based on this, it dynamically adjusts the adaptive shape factor to construct a super-Gaussian mathematical model, allowing the background model's fitting curve to adaptively switch between peaked and flat-topped shapes, following the actual illumination distribution of the tubing. This eliminates structural fitting residuals caused by the mismatch between the tubing's geometric deformation and the fixed model, enabling a more accurate reconstruction of the ideal background image. Furthermore, by combining differential intensity normalization and nonlinear mapping processing, the nonlinear transformation characteristics are used to significantly suppress background halo noise and stretch defect signal intensity, effectively improving the contrast between weak defects and the background. This achieves accurate detection of surface defects on the expanded heat shrink tubing under complex illumination and deformation interference.

[0008] Preferably, cropping the grayscale image of the heat shrink tubing to obtain the region of interest image includes: calculating the horizontal gradient field of the grayscale image of the heat shrink tubing; performing vertical cumulative projection on the horizontal gradient field to obtain a one-dimensional projection sequence; retrieving the extreme points in the one-dimensional projection sequence to determine the coordinates of the left and right edges of the heat shrink tubing; shifting the left edge coordinates to the right by a preset safety margin and shifting the right edge coordinates to the left by a preset safety margin; and cropping the grayscale image of the heat shrink tubing based on the shifted left and right edge coordinates to obtain the region of interest image.

[0009] Preferably, the step of calculating the flatness ratio of a row based on the grayscale distribution of each row of pixels includes: linearly normalizing the grayscale value sequence of the current row in the region of interest image; counting the number of data points with values ​​greater than a statistical threshold in the normalized grayscale value sequence; calculating the proportion of the number of data points to the total number of data points in the normalized grayscale value sequence; and obtaining the flatness ratio of the current row.

[0010] This invention calculates the flatness ratio based on the statistical distribution of normalized grayscale value sequences. By statistically analyzing the proportion of pixels exceeding a specific statistical threshold in the normalized sequence, it can measure the width of the top of the illumination distribution on the surface of the heat shrink tubing. The width of the illumination top is directly related to the cross-sectional geometry of the tubing, so the flatness ratio can reflect the degree to which the tubing in the current row changes from a circular shape to a flat shape. This provides a reliable physical quantitative basis for subsequently constructing a background model that adapts to the actual shape of the tubing.

[0011] Preferably, the adaptive shape factor satisfies the expression: ;in, The adaptive shape factor for the current row; This is the gain coefficient; It is a non-linear correction exponent; This represents the flatness ratio of the current row.

[0012] This invention establishes a mapping relationship between the flatness ratio and the adaptive shape factor by introducing a gain coefficient and a nonlinear correction exponent. By utilizing the adjustment characteristics of the nonlinear function, it ensures that the shape factor dynamically adjusts with the change of the flatness ratio while suppressing noise interference in the low flatness range. This drives the shape parameters of the super-Gaussian mathematical model to smoothly transition between peak and flat-top distributions according to the actual deformation of the heat shrink tubing, eliminating the structural fitting residuals caused by the mismatch between the shape of the super-Gaussian mathematical model and the actual cross-section of the tubing.

[0013] Preferably, the step of fitting the image of the region of interest row by row using a super-Gaussian mathematical model includes: calculating the median gray value of the current row in the image of the region of interest; using the sum of the median gray value and a preset illumination tolerance value as the gray value threshold of the current row; selecting pixels in the current row whose gray values ​​are less than the gray value threshold to form the effective sample set of the current row; substituting the adaptive shape factor of the current row into the super-Gaussian mathematical model, and using the effective sample set of the current row to iteratively optimize the model parameters of the super-Gaussian mathematical model to obtain the optimal model parameters of the current row.

[0014] This invention constructs a grayscale threshold by calculating the grayscale median and combining it with the illumination tolerance value to screen the effective sample set. Based on this effective sample set, the super-Gaussian mathematical model is iteratively optimized. It can actively remove the high-brightness specular reflection data of the heat shrink tubing surface by using the median truncation strategy, preventing the high-brightness outliers from pulling the fitting curve away from the real diffuse reflection background during the parameter optimization process. This ensures that the reconstructed ideal background image accurately reflects the physical illumination distribution of the tubing surface and avoids the inclusion of false reflective features.

[0015] Preferably, generating an ideal background image includes: substituting the optimal model parameters and adaptive shape factor of each row into the super Gaussian mathematical model to generate an ideal background image row by row.

[0016] Preferably, the superGaussian mathematical model satisfies the expression: ;in, For super Gaussian mathematical models, For horizontal coordinate variables; For amplitude parameters; Center position parameter; For scale parameters; An adaptive shape factor; These are the basis parameters; It is the absolute value symbol.

[0017] Preferably, the differential intensity satisfies the expression, including: ;in, Indicates coordinates as The difference intensity of the pixels; Indicates coordinates as The grayscale value of a pixel in an ideal background image; Indicates coordinates as The grayscale value of a pixel in the region of interest image; max is the maximum value function.

[0018] This invention performs a difference operation between the ideal background image and the region of interest image and combines it with a maximum value function for truncation. This forces the negative difference generated in the highlight area to zero, thereby automatically shielding the interference of the axial bright specular reflection stripe of the tube body while extracting the dark defect signal, effectively preventing the normal highlight area from being misjudged as a surface defect.

[0019] Preferably, the step of normalizing and nonlinearly mapping the differential intensities to obtain the enhanced differential image includes: linearly normalizing the differential intensities of pixels to obtain normalized differential intensities of pixels; performing nonlinear mapping on the normalized differential intensities of pixels to obtain enhanced differential intensities of pixels; constructing the enhanced differential image from the enhanced differential intensities of all pixels; the enhanced differential intensities of pixels satisfy the expression: , Indicates coordinates as The difference intensity after pixel enhancement Indicates coordinates as The normalized difference intensity of the pixels, This is the nonlinear enhancement coefficient.

[0020] This invention performs nonlinear mapping on the normalized difference intensity, utilizing the compression effect of the nonlinear function in the low grayscale range to significantly suppress background halo noise caused by the fitting residual. At the same time, it utilizes the preservation or stretching effect of the nonlinear function in the high grayscale range to highlight the real defect signal, thereby effectively increasing the grayscale contrast between weak defects and background noise, and improving the sensitivity and accuracy of identifying small scratches or low-contrast defects.

[0021] Preferably, determining the surface defect of the heat shrink tubing expansion based on the segmentation result includes: performing Otsu threshold segmentation on the enhanced differential image to generate a binarized mask image; calculating the number of pixels in each connected component in the binarized mask image; and determining that the connected component is a surface defect of the heat shrink tubing expansion if the number of pixels in the connected component is greater than a threshold for any connected component.

[0022] The beneficial effects of this invention are as follows: This invention obtains the flatness ratio by performing line-by-line grayscale distribution analysis on the region of interest image, and dynamically adjusts the adaptive shape factor accordingly to construct a super-Gaussian mathematical model. This allows the model's lateral illumination distribution curve to adaptively switch between peaked and flat-topped shapes as the geometry of the heat shrink tubing cross-section changes, thereby eliminating the structural fitting residuals caused by the tubing's transformation from round to flat, and avoiding misjudging the flat area in the center of the tubing as a defect. Simultaneously, this invention employs a grayscale median-based truncation strategy during model fitting to screen the effective sample set, actively removing pixel data from bright specular reflection areas. This prevents outliers from pulling the fitting curve away from the true diffuse background, ensuring the physical realism of the ideal background image. Furthermore, this invention combines differential operation with high-light shielding function and nonlinear mapping mechanism. While eliminating high-light reflective strip interference through truncation processing, it significantly compresses residual halo noise in the background and stretches the signal intensity of weak defects by utilizing the nonlinear characteristics of the power function. This effectively improves the contrast between defects and background, and enables accurate detection of minor scratches, black spots and other defects on the surface of heat shrink tubing under complex lighting and deformation interference. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating the heat shrink tubing expansion surface defect detection method based on image feature recognition in this invention;

[0024] Figure 2 The image shows the RGB image of the heat shrink tubing to be inspected.

[0025] Figure 3 Image of the region of interest;

[0026] Figure 4 This is the ideal background image obtained by the adaptive shape factor in this invention;

[0027] Figure 5An ideal background image obtained using existing technology with a standard Gaussian distribution;

[0028] Figure 6 This is a schematic diagram comparing the grayscale distribution histograms of the ideal background image of the present invention with those of the ideal background image obtained by the prior art using a standard Gaussian distribution.

[0029] Figure 7 This is the enhanced differential image corresponding to the present invention;

[0030] Figure 8 Enhanced difference images corresponding to the standard Gaussian distribution used in existing technologies.

[0031] Figure 9 This is a schematic diagram of the binary image of the defect corresponding to the present invention;

[0032] Figure 10 A schematic diagram of a defect binary image corresponding to the standard Gaussian distribution in existing technology;

[0033] Figure 11 To be Figure 9 A visualization of the detection results where the defective region is mapped onto the original RGB image;

[0034] Figure 12 To be Figure 10 A visualization of the detection results where the defective region is mapped onto the original RGB image. Detailed Implementation

[0035] 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, not all, of the embodiments of the present invention. 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.

[0036] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0037] This invention discloses a method for detecting surface defects in heat shrink tubing based on image feature recognition, referring to... Figure 1 This includes steps S1 to S5:

[0038] S1. Cropping the grayscale image of the heat shrink tubing yields the region of interest image.

[0039] Specifically, an industrial camera is used to acquire images of the heat shrink tubing after the expansion process, obtaining RGB images of the tubing to be inspected. During image acquisition, the shooting angle is constrained by mechanical limiting or vision alignment devices to keep the axis of the heat shrink tubing parallel to the vertical direction of the camera, ensuring that the acquired heat shrink tubing is vertically distributed in the RGB image. If the width of the acquired RGB image is greater than its height, it indicates that the image data is stored horizontally, and the RGB image is rotated 90 degrees to correct it to a vertical orientation. For example, Figure 2 This is the RGB image of the heat shrink tubing to be tested.

[0040] Furthermore, to facilitate subsequent processing, the RGB image of the heat shrink tubing to be inspected is converted into a grayscale image.

[0041] The Scharr edge detection operator is used to perform convolution operations on the grayscale image to calculate the gradient field in the horizontal direction. A vertical accumulation and projection operation is then performed on this horizontal gradient field. Specifically, the gradient field in the horizontal direction is traversed column by column, and the gradient values ​​of all pixels in each column are accumulated to obtain the projected value for that column. All projected values ​​are arranged in column order to form a one-dimensional projection sequence. The two extreme points with the largest values ​​are searched in this one-dimensional projection sequence, and their x-coordinates are marked as the left and right edge coordinates of the heat shrink tubing, respectively.

[0042] Given that blurred halo areas often exist at the edges of optical imaging due to diffraction or Fresnel reflection, direct cropping along the edges would introduce non-diffuse reflection noise. Therefore, this invention shifts the left edge coordinates to the right by a fixed safety margin and the right edge coordinates to the left by a fixed safety margin, thereby determining the effective cropping boundary. In this embodiment, the safety margin is set to 15 pixels. In other embodiments, the implementer can set it according to the average width of the edge halo in the actual imaging environment.

[0043] The grayscale image is cropped based on the translated left and right edge coordinates to obtain a region of interest image containing only the core surface of the pipe. For example, Figure 3 Image of the region of interest.

[0044] It should be noted that the Scharr edge detection operator is used in this embodiment because, compared with conventional edge detection operators, the Scharr edge detection operator has a stronger response capability to weak edges and can effectively capture the boundary line between the heat shrink tubing body and the background. In other embodiments, implementers can also choose other edge detection operators, such as the Sobel operator or the Prewitt operator, according to the actual implementation situation.

[0045] S2. Traverse the image of the region of interest row by row, calculate the flatness ratio of each row based on the grayscale distribution of the pixels in each row, and determine the adaptive shape factor corresponding to each row based on the flatness ratio.

[0046] It should be noted that after acquiring the image of the region of interest (ROI), this invention requires mathematical modeling of its surface illumination distribution to reconstruct an ideal, defect-free background without noise. However, during the production process, heat shrink tubing is subject to random influences from heating temperature and extrusion processes, causing its geometric shape to dynamically fluctuate between a standard cylinder and a flat elliptical cylinder. This change in geometric shape leads to significant differences in the top illumination characteristics of the lateral grayscale distribution contour of the ROI image. Specifically, the grayscale distribution of the standard cylinder is peak-shaped, while that of the flat tube is flat-topped. If a Gaussian model with fixed parameters is used for fitting, when the tube becomes flat, the model cannot fit the illumination distribution area with flat-top characteristics, resulting in large structural residuals that can be misjudged as defects. Therefore, to eliminate the systematic errors caused by geometric deformation, this invention analyzes the local contour features of the ROI image, establishes an adaptive mapping relationship between geometric features and the shape parameters of the mathematical model, and obtains an adaptive shape factor that adapts to the shape of each row of tubes in the ROI image, in order to accurately fit the diffuse background.

[0047] Specifically, the image of the region of interest is traversed row by row. For each row of pixel data, the gray value sequence of the pixels in that row is linearly normalized. The number of data points with values ​​greater than a statistical threshold in the normalized gray value sequence of the pixels in that row is counted. The proportion of the number of such data points to the total number of data points in the normalized gray value sequence of the pixels in that row is calculated as the flatness ratio of that row. The larger the flatness ratio, the wider the flat area at the top of the illumination distribution corresponding to that row, and the closer the heat shrink tubing is to a flat shape at that position.

[0048] It should be noted that the statistical threshold of 0.8 in this embodiment is determined based on the light distribution characteristics of specular reflection on the cylindrical surface. In the normalized illumination model, the region with an amplitude greater than 0.8 concentrates the core energy of the reflected light spot. The width of this region is most sensitive to changes in the cross-sectional geometry. When the tube cross-section is circular, the top illumination distribution is sharp, and the region with an amplitude greater than 0.8 is extremely narrow. When the tube cross-section becomes flat, the top illumination distribution exhibits a flat-top characteristic, and the region with an amplitude greater than 0.8 widens significantly. If the threshold is set too low, such as 0.5, the statistical results are easily affected by the tube diameter; if the threshold is set too high, such as 0.95, the statistical results are easily affected by camera noise. Therefore, this invention selects 0.8 as the statistical threshold to maximize the distinguishability between circular and flat tubes.

[0049] Furthermore, an adaptive shape factor is obtained based on the flatness ratio of each row to fit the cross-sectional shape of the tube in the current row:

[0050]

[0051] in, 1 is the adaptive shape factor of the current row, which serves as the shape index of the subsequent super-Gaussian model and is used to control the flatness of the top of the fitting curve; 2 is the shape index of the baseline Gaussian distribution. When the heat shrink tubing cross-section is a standard circle, its surface light reflection distribution conforms to the standard Gaussian distribution, which corresponds to the state where the shape parameter of the super-Gaussian model is 2. This serves as the physical reference point for shape changes. The gain coefficient determines the dynamic range of the shape factor as a function of flatness, and is determined based on the maximum deformation of the tube. In this embodiment... Setting it to 1.5 means that when the tube is nearly completely flat, the upper limit of the shape factor is limited to 3.5 to avoid excessively high shape exponents causing ringing effects at the edges of the fitted curve. This is a nonlinear correction exponent used to adjust the sensitivity curve of the mapping function. In this embodiment... Setting it to 1.2 utilizes the convexity of the power function to suppress noise interference in the low flatness range corresponding to the near-circular state of the tube, making the system primarily respond to significant morphological changes. In other embodiments, implementers can adjust this parameter according to actual testing needs. When the testing scenario requires higher sensitivity to the initial minor deformation of the heat shrink tubing, it can be appropriately reduced. The value can be set to, for example, 1; when the signal-to-noise ratio of the imaging environment is low and higher stability is required for modeling circular tubes, it can be appropriately increased. The value, for example, is set to 1.5; This represents the flatness ratio of the current row. As the heat shrink tubing cross-section changes from round to flat, the flatness ratio of the current row... Increase, thereby driving the adaptive shape factor of the current row. The value increases monotonically from 2 to 3.5, thus achieving a smooth transition of the model from a peaked Gaussian distribution to a flat-topped super-Gaussian distribution.

[0052] S3. Construct a super Gaussian mathematical model that includes an adaptive shape factor, and use the super Gaussian mathematical model to fit the image of the region of interest line by line to generate an ideal background image.

[0053] It should be noted that the surface of heat shrink tubing is a typical highly reflective curved surface. During imaging, high-brightness specular reflection bands will form along the axis of the tubing. The pixel gray values ​​of these highlight areas are much higher than those of the diffuse background, which are statistically strong outliers. If the least squares method is directly used to fit the region of interest image, the highlight outliers will pull the fitting curve upwards significantly, resulting in a reconstructed background image containing false reflective features, which cannot be used as an ideal difference benchmark. Therefore, this invention actively removes highlight data through a median truncation strategy, forcing the model to reconstruct the physical background only using pixel data from the diffuse region.

[0054] Specifically, a one-dimensional super-Gaussian mathematical model is constructed to describe the ideal illumination distribution on the surface of the heat shrink tubing. This super-Gaussian mathematical model satisfies the expression:

[0055]

[0056] in, For super Gaussian mathematical models, For horizontal coordinate variables; For amplitude parameters; Center position parameter; For scale parameters; An adaptive shape factor; These are the basis parameters; It is the absolute value symbol.

[0057] The pixel data of each row in the region of interest image is traversed and processed. Before fitting the pixel data of each row, the median gray value of the pixels in that row is calculated first, and a gray value threshold is set for that row. Remove rows with grayscale values ​​less than the grayscale threshold. All pixels constitute the effective sample set for that row. A nonlinear optimization algorithm is then used to optimize the undetermined parameters in the hypergaussian mathematical model based on this effective sample set. , , and Iterative optimization is performed. During the optimization process, the adaptive shape factor of the row is substituted as a known quantity into the super-Gaussian mathematical model to obtain the optimal model parameters for the row. This represents the median grayscale value of the pixels in that row. This represents the illumination tolerance value. In this embodiment, The empirical value is 70. In other embodiments, implementers may adjust this parameter according to the light intensity and background noise level in the actual imaging environment.

[0058] The optimal model parameters and adaptive shape factor for each row are substituted into the super Gaussian mathematical model to generate the ideal background image row by row.

[0059] For example, Figure 4 This is the ideal background image obtained by the adaptive shape factor in this invention. Figure 5 This refers to the ideal background image obtained using existing techniques with a standard Gaussian distribution, specifically the ideal background image when the shape exponent of the super-Gaussian model is fixed at 2. Figure 6 This is a schematic diagram comparing the grayscale distribution histograms of the ideal background image of the present invention with those of the ideal background image obtained by the prior art using a standard Gaussian distribution.

[0060] S4. Calculate the difference intensity between the ideal background image and the region of interest image, normalize the difference intensity and perform nonlinear mapping to obtain the enhanced difference image.

[0061] It should be noted that after obtaining the ideal background image, defects can be extracted by differencing the ideal background image with the region of interest image. However, since there is inevitably a small residual between the fitted model and the actual illumination, direct linear difference operations will leave a weak halo error on both sides of the tube edge; at the same time, defects such as small scratches have a low grayscale difference from the background, appearing as weak signals in the difference image, with their grayscale values ​​often only slightly higher than the background halo noise. It is difficult to effectively separate the two using linear processing. Therefore, in order to separate the weak defect signal from the background halo noise, this invention utilizes the nonlinear response characteristics of the power function to construct an energy mapping mechanism. The compression effect of the power function in the low grayscale range significantly suppresses the relatively low amplitude background residual, while its nonlinear stretching effect highlights the relatively high amplitude defect signal.

[0062] Specifically, a difference operation is performed between the ideal background image and the region of interest image to obtain the difference intensity of each pixel:

[0063]

[0064] in, Indicates coordinates as The difference intensity of the pixels; Indicates coordinates as The grayscale value of a pixel in an ideal background image; Indicates coordinates as The grayscale value of a pixel in the region of interest image; max is the maximum value function. Under industrial lighting, the normal surface area of ​​a heat shrink tubing exhibits diffuse reflection characteristics, forming a baseline background brightness. However, surface defects such as scratches and black spots can disrupt the surface smoothness or absorb some incident light, resulting in a reduction in the light flux reflected back to the camera, thus lowering its grayscale value compared to the surrounding background. Conversely, the specular reflection area along the tubing axis directly reflects high-intensity light from the light source into the camera, causing the grayscale value of this area to be much higher than the diffuse background. This invention utilizes the physical law that the brightness of defective areas is lower than the background and the brightness of highlight areas is higher than the background, through... The function forcibly truncates the difference in the highlight area to 0, thereby avoiding misjudging the highlight area as a defect and achieving highlight shielding.

[0065] Furthermore, the differential intensity of the pixels is linearly normalized to map its value range to between 0 and 1, resulting in the normalized differential intensity of the pixels. Then, a non-linear mapping is applied to the normalized differential intensity of the pixels to obtain the enhanced differential intensity of the pixels.

[0066]

[0067] in, Indicates coordinates as The difference intensity after pixel enhancement; Indicates coordinates as The normalized difference intensity of the pixels; This is a nonlinear enhancement coefficient used to adjust the curvature of the energy mapping function to control the degree of background noise suppression. In this embodiment, the nonlinear enhancement coefficient is... When set to 2, the enhanced differential intensity is significantly compressed when the normalized differential intensity is in the low-value range corresponding to the background residual halo. For example, the normalized value... When the value is 0.1, the transformed response value is only When the normalized differential intensity is in the high-value range corresponding to the real defect, the enhanced differential intensity remains at a high level, for example, the normalized value. When the value is 0.95, the transformed response value is In other embodiments, the implementer can set a nonlinear enhancement coefficient based on the contrast difference between the weak defect and the background halo. When it is necessary to improve the detection capability of extremely weak scratches, the coefficient can be appropriately reduced. The value, if set to 1.5, should be increased appropriately when there is strong background halo interference in the imaging environment. The value, for example, is set to 3.

[0068] Furthermore, the enhanced differential intensities of all pixels are used to construct an enhanced differential image.

[0069] For example, Figure 7 This is the enhanced differential image corresponding to the present invention. Figure 8 Enhanced difference images corresponding to the standard Gaussian distribution used in existing technologies.

[0070] S5. Perform threshold segmentation on the enhanced differential image and determine the surface defects of the heat shrink tubing expansion based on the segmentation results.

[0071] Specifically, the enhanced differential image is segmented using the Otsu threshold to generate a binarized mask. Connectivity analysis is then performed on the binarized mask. For any connected component, if the number of pixels contained in the connected component is greater than a threshold, the connected component is considered a defect region. In this embodiment, the threshold is 5 pixels. In other embodiments, the implementer can set the threshold according to the sensor noise level of the actual imaging system and the physical size detection requirements of the minimum defect.

[0072] For example, Figure 9 This is a schematic diagram of the binary image of the defect corresponding to the present invention. Figure 10 This is a schematic diagram of a defect binary image corresponding to a standard Gaussian distribution using existing technology. Figure 11 To be Figure 9 A visualization of the detection results, showing the mapping of the defective region onto the original RGB image, is provided. This is the detection result of the present invention. Figure 12 To be Figure 10 A visualization of the detection results, showing the mapping of defect areas onto the original RGB image, representing the detection results of existing technologies. (Comparison) Figure 11 and Figure 12 It can be seen that the detection results of the present invention effectively suppress background interference and accurately capture the minute defects on the surface of the heat shrink tubing; while the existing technology, due to the inability of the standard Gaussian model used to adapt to the flat-top cross-sectional shape of the heat shrink tubing, produces a significant structural fitting residual in the center of the tubing, resulting in a large area of ​​normal regions being incorrectly identified as defects.

Claims

1. A method for detecting surface defects in heat shrink tubing expansion based on image feature recognition, characterized in that, include: The grayscale image of the heat shrink tubing is cropped to obtain the region of interest image; The image of the region of interest is traversed row by row. The flatness ratio of each row is calculated based on the grayscale distribution of the pixels in each row, and the adaptive shape factor corresponding to each row is determined based on the flatness ratio. A super Gaussian mathematical model incorporating an adaptive shape factor is constructed. The super Gaussian mathematical model is then used to fit the image of the region of interest line by line to generate an ideal background image. The difference intensity between the ideal background image and the region of interest image is calculated, and the difference intensity is normalized and nonlinearly mapped to obtain the enhanced difference image. Threshold segmentation is performed on the enhanced differential image, and the surface defects of the heat shrink tubing expansion are determined based on the segmentation results.

2. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The process of cropping the grayscale image of the heat shrink tubing to obtain the region of interest image includes: Calculate the horizontal gradient field of the grayscale image of the heat shrink tubing; perform vertical cumulative projection on the horizontal gradient field to obtain a one-dimensional projection sequence; retrieve the extreme points in the one-dimensional projection sequence to determine the coordinates of the left and right edges of the heat shrink tubing; shift the left edge coordinates to the right by a preset safety margin, and shift the right edge coordinates to the left by a preset safety margin; crop the grayscale image of the heat shrink tubing based on the shifted left and right edge coordinates to obtain the region of interest image.

3. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The step of calculating the flatness ratio of a row based on the grayscale distribution of each row of pixels includes: Linearly normalize the grayscale value sequence of the current row in the region of interest image; count the number of data points in the normalized grayscale value sequence whose values ​​are greater than a statistical threshold, and calculate the ratio of the number of data points to the total number of data points in the normalized grayscale value sequence to obtain the flatness ratio of the current row.

4. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The adaptive shape factor satisfies the expression: ; in, The adaptive shape factor for the current row; This is the gain coefficient; It is a non-linear correction exponent; This represents the flatness ratio of the current row.

5. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The method of fitting the image of the region of interest line by line using a super-Gaussian mathematical model includes: Calculate the median gray value of the current row in the region of interest image; use the sum of the median gray value and the preset illumination tolerance value as the gray value threshold of the current row; select pixels in the current row whose gray values ​​are less than the gray value threshold to form the effective sample set of the current row; substitute the adaptive shape factor of the current row into the super Gaussian mathematical model, and use the effective sample set of the current row to iteratively optimize the model parameters of the super Gaussian mathematical model to obtain the optimal model parameters of the current row.

6. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 5, characterized in that, Generate the ideal background image, including: The optimal model parameters and adaptive shape factor for each row are substituted into the super Gaussian mathematical model to generate the ideal background image row by row.

7. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, 5, or 6, characterized in that, The super-Gaussian mathematical model satisfies the expression: ; in, For super Gaussian mathematical models, For horizontal coordinate variables; For amplitude parameters; Center position parameter; For scale parameters; An adaptive shape factor; These are the basis parameters; It is the absolute value symbol.

8. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The differential strength satisfies the expression, including: ; in, Indicates coordinates as The difference intensity of the pixels; Indicates coordinates as The grayscale value of a pixel in an ideal background image; Indicates coordinates as The grayscale value of a pixel in the region of interest image; max is the maximum value function.

9. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The process of normalizing and nonlinearly mapping the differential intensity to obtain the enhanced differential image includes: The differential intensity of each pixel is linearly normalized to obtain the normalized differential intensity. This normalized differential intensity is then nonlinearly mapped to obtain the enhanced differential intensity. The enhanced differential intensities of all pixels are used to construct the enhanced differential image. The enhanced differential intensity of each pixel satisfies the following expression: , Indicates coordinates as The difference intensity after pixel enhancement Indicates coordinates as The normalized difference intensity of the pixels, This is the nonlinear enhancement coefficient.

10. The method for detecting surface defects in heat shrink tubing based on image feature recognition according to claim 1, characterized in that, The determination of surface defects on the heat shrink tubing expansion based on the segmentation results includes: The enhanced difference image is segmented using the Otsu threshold to generate a binarized mask image. The number of pixels in each connected component in the binarized mask image is calculated. For any connected component, if the number of pixels in the connected component is greater than the threshold, the connected component is determined to be a surface defect of the heat shrink tubing expansion.

Citation Information

Patent Citations

  • Defective product identification method for heat-shrinkable tube expanding process

    CN114972326A

  • Thermal defect identification method and system for high-voltage switch equipment, and computer equipment

    CN121504849A