A target detection method and system for elongated morphology paint sagging defects
Patent Information
- Application Number
- CN202611120961.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-30
AI Technical Summary
[0005]本发明的目的在于提供一种针对细长形态涂料流挂缺陷的目标检测方法及系统,解决了现有技术中指出的上述技术问题
[0047]分析本发明提供的上述一种针对细长形态涂料流挂缺陷的目标检测方法及系统可知,在具体应用时对涂料表面原始图像开展边缘特征预处理,利用边缘检测算子滤除大面积平滑漆面低频背景信息,保留灰度突变的高频边缘细节,有效抑制漆面光照不均、底色纹理均匀变化带来的干扰,大幅突出细长流挂缺陷的线状边缘特征,压缩无效图像运算区域,为后续缺陷精准识别提供高辨识度的待检测图像基底;
Smart Images

Figure CN123015411A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality inspection of waterproofing construction operations, and in particular to a method and system for detecting coating sagging defects in slender shapes. Background Technology
[0002] Large reservoir projects, including dams and water conveyance tunnels, operate under complex environments characterized by high water pressure, high humidity, alternating wet and dry conditions, and water erosion. Structural waterproofing is a crucial process for ensuring the safety of the main reservoir structure, preventing seepage damage, and extending the project's service life. Currently, high-performance waterproof coatings are commonly used in large reservoir construction to provide overall seepage protection for the vertical, sloping, and top surfaces of hydraulic structures. These coatings possess excellent properties such as waterproofing, corrosion resistance, seepage resistance, and erosion resistance, making them suitable for the unique construction environment of hydraulic engineering projects. However, in actual construction, factors such as unstable temperature and humidity during open-air reservoir construction, the gravity of vertical and sloping surfaces, deviations in coating viscosity ratios, improper control of spraying pressure and gun speed, and excessively thick single-coat thickness can easily cause thin, elongated, or wavy drip defects in the waterproof coating.
[0003] Studies have found that sagging defects in waterproof coatings are a typical elongated type of defect in hydraulic engineering coatings. These defects can cause uneven coating thickness, insufficient film density, and discontinuous coating breaks, significantly reducing the seepage prevention and protection performance of hydraulic structures. During service, they can easily lead to localized water seepage, coating peeling, and corrosion of the substrate structure, severely damaging the overall seepage prevention system of the reservoir and posing a structural seepage safety risk. Furthermore, the coating work on reservoir hydraulic structures involves a wide area, large sloping surface, complex on-site textures, and uneven lighting. Sagging defects often appear as weak, elongated, dark lines with low contrast to the normal coating background and fragmented edges, making them easily confused with paint stains, localized color differences, and slight textures, greatly complicating accurate defect detection.
[0004] Currently, traditional methods for detecting sagging in waterproof coatings for reservoirs mainly rely on manual visual inspection, which is inefficient, prone to subjective errors, and has a high rate of missed or false detections of fine, elongated sagging defects. This makes it unsuitable for the rapid quality inspection needs of large-area hydraulic coatings. Furthermore, existing conventional image detection technologies mostly employ fixed windows and general bounding box detection methods, primarily designed for detecting blocky blank areas (paint voids). They struggle to specifically identify fine, elongated sagging defects, suffer from weak background interference suppression, easily obscuring fine sagging features, poor scale adaptability, and insufficient ability to distinguish between genuine and fake defects, ultimately failing to accurately extract the complete outline of fine, elongated sagging in hydraulic coatings. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for detecting coating sagging defects in slender shapes, thereby solving the aforementioned technical problems pointed out in the prior art.
[0006] This invention provides a method for detecting coating sagging defects with slender shapes, the specific operation method including:
[0007] The original image of the coating surface is acquired, and the original image is preprocessed to obtain the image to be detected;
[0008] The process involves: extracting initial contours of potential flow defects from the image to be detected; creating a sliding window from the initial contours of the flow defects as an initial square window; adjusting the side length of the initial square window based on the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; constructing a square neighborhood window for each pixel in each of the image sub-blocks of multiple sizes; extracting initial candidate seed points based on the probability of the gray values of the pixels within the square neighborhood window; selecting growth starting points for the initial candidate seed points and growing them to obtain polygonal regions.
[0009] The polygonal region is considered as a slender coating sagging defect, and the detection results of the slender coating sagging defect are sent to the host computer monitoring system.
[0010] Preferably, the initial contour of potential sag defects is extracted from the image to be detected, and the specific operation steps are as follows:
[0011] For each pixel in the image to be detected, calculate the gradient magnitude and gradient direction; for each pixel, filter the neighboring pixels and calculate the difference in gradient magnitude; if the difference in gradient magnitude is less than or equal to a preset threshold for similar magnitude ratio, then the neighboring pixel is regarded as the connected pixel of the pixel, forming a connected region;
[0012] The x-coordinates and y-coordinates of the minimum and maximum values are determined for the connected region, and the minimum bounding rectangle is further determined; the aspect ratio of the length and width is calculated based on the minimum bounding rectangle; if the aspect ratio is greater than a preset ratio threshold, the connected region is determined to be the initial outline of a potential sag defect.
[0013] Preferably, the initial contour sliding window of the sag defect is used as an initial square window; the side length of the initial square window is adjusted according to the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; a square neighborhood window is constructed for each pixel in the image sub-blocks of multiple sizes; initial candidate seed points are extracted according to the probability of the gray values of the pixels within the square neighborhood window. The specific operation steps are as follows:
[0014] The initial contour of the flow defect in the image to be detected is obtained as the target region. A preset square window is used to slide the target region as the initial square window. The gray value mean of all pixels in the initial square window is calculated as the window gray value mean. The standard deviation of the gray values of all pixels and the window gray value mean is calculated as the window gray standard deviation.
[0015] A first grayscale standard deviation threshold and a second grayscale standard deviation threshold are preset. If the grayscale standard deviation of the window is greater than the first grayscale standard deviation threshold, the side length of the initial square window is adjusted and reduced. The grayscale standard deviation of the window is recalculated with the adjusted and reduced initial square window, and the adjustment and reduction operation is repeated until the recalculated grayscale standard deviation of the window is less than or equal to the first grayscale standard deviation threshold. The final adjusted and reduced initial square window is used as the first size sub-block.
[0016] If the window's grayscale standard deviation is less than the second grayscale standard deviation threshold, the side length of the initial square window is adjusted and enlarged. The grayscale standard deviation of the window is recalculated using the adjusted and enlarged initial square window, and this adjustment and enlargement operation is repeated until the recalculated window grayscale standard deviation is greater than or equal to the second grayscale standard deviation threshold. The finally adjusted and enlarged initial square window is used as the third-size sub-block. If the window's grayscale standard deviation is greater than or equal to the second grayscale standard deviation threshold and less than or equal to the first grayscale standard deviation threshold, the initial square window is used as the second-size sub-block. All adjacent sub-blocks of the same type are merged to obtain multi-size image sub-blocks.
[0017] Using each pixel within an image sub-block as the center, construct square neighborhood windows corresponding to the size of the image sub-block; count the frequency of grayscale values of each pixel within each square neighborhood window, and calculate the probability of occurrence of each grayscale value within each square neighborhood window, which is used as the probability quality function value of that pixel's grayscale value; calculate the local entropy value of the center pixel within the square neighborhood window based on the probability quality function values of all pixel grayscale values within the square neighborhood window; select the pixel with the minimum local entropy value within the image sub-block as the initial candidate seed point for that image sub-block.
[0018] Preferably, the initial candidate seed point is selected as the growth starting point of the region, and a polygon region is obtained by growth. The specific operation steps are as follows:
[0019] The coordinates and grayscale values of the initial candidate seed points are determined. Adjacent seed point pairs are selected based on these coordinates and grayscale values. The strain compatibility coefficient of the adjacent seed point pairs is calculated based on their grayscale values. The adjacent seed point pairs are then selected into a first candidate set based on the strain compatibility coefficient. The initial candidate seed point with the minimum local entropy value in the first candidate set is used as the starting point for region growth. Growth is performed on adjacent pixels to obtain the target segmentation region. A binary mask is applied to the target segmentation region to select a set of target edge pixels. Polygonal regions are extracted from the target edge pixel set.
[0020] Preferably, the coordinates and grayscale values of the initial candidate seed points are determined, adjacent seed point pairs are selected based on the coordinates and grayscale values, and the strain compatibility coefficient of the adjacent seed point pairs is calculated based on the grayscale values of the adjacent seed point pairs. The specific operation steps are as follows:
[0021] Determine the coordinates and grayscale values of the initial candidate seed points, and calculate the Euclidean distance between two random initial candidate seed points; if the Euclidean distance is less than a preset distance threshold, then the two initial candidate seed points corresponding to the Euclidean distance are regarded as adjacent seed point pairs.
[0022] The coordinate position and gray value corresponding to the first initial candidate seed point in the adjacent seed point pair are extracted as the first coordinate and the first gray value, and the coordinate position and gray value of the second initial candidate seed point are extracted as the second coordinate and the second gray value. The reciprocal of the Euclidean distance between the first coordinate and the second coordinate is used as the coordinate proximity metric. The coordinate proximity metric is normalized to obtain the normalized coordinate proximity metric. The absolute difference between the first gray value and the second gray value is calculated, and the reciprocal of the absolute difference is used as the gray similarity metric. The gray similarity metric is normalized to obtain the normalized gray similarity metric. The weighted product of the normalized coordinate proximity metric and the normalized gray similarity metric is calculated as the strain compatibility coefficient of the adjacent seed point pair.
[0023] Preferably, the adjacent seed point pairs are selected into a first candidate set based on the strain compatibility coefficient; the initial candidate seed point with the minimum local entropy value in the first candidate set is used as the starting point for region growth, and growth is performed on adjacent pixels to obtain the target segmentation region. The specific operation steps are as follows:
[0024] A preset compatibility screening threshold is set; if the strain compatibility coefficient corresponding to the adjacent seed point pair is greater than the compatibility screening threshold, the adjacent seed point pair is marked to form a first candidate set; unmarked adjacent seed point pairs are assigned to a second candidate set.
[0025] For each initial candidate seed point in the second candidate set, calculate the average strain compatibility coefficient with the initial candidate seed points in the first candidate set; if the average strain compatibility coefficient is greater than the compatibility screening threshold, then move the initial candidate seed point of the second candidate set into the first candidate set.
[0026] The initial candidate seed point with the minimum local entropy value in the first candidate set is selected as the starting point for region growth. The gray-level difference is calculated by traversing adjacent pixels in the adjacent region with the starting point as the center. If the gray-level difference is less than the preset gray-level growth threshold, the adjacent pixel is used as the growth pixel. The growth pixel is used as the new starting point for region growth. The adjacent pixels are traversed again with the new starting point as the center. This process is repeated until the adjacent pixels can no longer be used as the new starting point for region growth, thus forming an independent segmented region.
[0027] All initial candidate seed points are used to obtain independent segmentation regions, and all independent segmentation regions are merged to obtain the target segmentation region.
[0028] Preferably, a binary mask is applied to the target segmentation region to filter the target edge pixel set; polygon regions are extracted from the target edge pixel set, and the specific operation steps are as follows:
[0029] A binarized mask is applied to the target segmentation region to extract corresponding local image patches from the image to be detected. The gradient magnitude and direction of pixels in each local image patch are calculated, and first-level and second-level edge points are selected to generate a target edge pixel set. A minimum bounding box (MBC) is extracted from the target edge pixel set, and its morphological and directional features are calculated. The local image patch is input into a pre-trained feature extraction network to output a global statistical feature map. The morphological and directional features are then combined with the global statistical feature map to generate a multi-dimensional feature map. Multiple initial horizontal anchor boxes with different aspect ratios and scales are preset for the multi-dimensional feature map. These initial horizontal anchor boxes are rotated clockwise to extract target candidate boxes. Target candidate boxes are cropped from the original image to extract the target mask image. An initial skeleton point sequence is extracted from the non-zero pixels in the target mask image. A sliding window is used to extract an ordered skeleton sequence. The true direction and actual length of the ordered skeleton sequence are calculated to generate a polygonal region.
[0030] Preferably, a binarized mask is applied to the target segmentation region to extract corresponding local image patches from the image to be detected; the gradient magnitude and gradient direction of the pixels in the local image patches are calculated, and first-level edge points and second-level edge points are selected to generate a target edge pixel set; the minimum bounding box is extracted from the target edge pixel set, and morphological and directional features are calculated for the minimum bounding box; the local image patches are input into a pre-trained feature extraction network to output a global statistical feature map, and the morphological and directional features are combined with the global statistical feature map to generate a multi-dimensional feature map. The specific operation steps are as follows:
[0031] A binarized mask is applied to the target segmentation region, and corresponding local image patches are extracted from the image to be detected based on the target segmentation region of the binarized mask. A Sobel operator is used to perform convolution operations on the local image patches, and the gradient components of each pixel in the local image patch are calculated in the horizontal and vertical directions. The gradient magnitude and gradient direction of each pixel are calculated based on the gradient components in the horizontal and vertical directions. If the gradient magnitude of a pixel is greater than the gradient magnitudes of its left and right adjacent pixels, then the pixel is considered an edge candidate point.
[0032] A high edge threshold and a low edge threshold are preset; if the gradient magnitude of the edge candidate point is greater than the high edge threshold, then the edge candidate point is regarded as a first-level edge point; if the gradient magnitude of the edge candidate point is greater than the low edge threshold and less than the high edge threshold, then the edge candidate point is regarded as a second-level edge point; the first-level edge points and the second-level edge points are used to generate a target edge pixel set; the edge points with minimum and maximum x-coordinates and minimum and maximum y-coordinates in the target edge pixel set are selected to generate a minimum bounding rectangle enclosing the target edge pixel set.
[0033] Extract the length of the long side and the length of the short side of the minimum circumscribed rotating rectangle, and calculate the length ratio as a shape feature; determine the long side direction vector and the horizontal unit vector based on the length of the long side of the minimum circumscribed rotating rectangle, and calculate the included angle as a direction feature;
[0034] The local image patch is input into a pre-trained feature extraction network, which outputs a global statistical feature map. The global statistical feature map, morphological features, and orientation features are input into a pre-constructed multimodal feature fusion module, which outputs a multidimensional feature map.
[0035] Preferably, multiple initial horizontal anchor boxes with different aspect ratios and scales are preset for the multidimensional feature map. The initial horizontal anchor boxes are rotated clockwise to extract target candidate boxes. The specific operation steps are as follows:
[0036] For each pixel in the multidimensional feature map, multiple initial horizontal anchor frames with different aspect ratios and scales are preset. Using the center pixel of each initial horizontal anchor frame as the rotation center and the direction feature as the rotation reference angle, each initial horizontal anchor frame is rotated to generate an initial rotated anchor frame, and the tilt angle of each initial rotated anchor frame is calculated. The absolute angle difference between the tilt angle of each initial rotated anchor frame and the direction feature is calculated, and the frames are sorted in descending order. The first k initial rotated anchor frames with the largest absolute angle differences are selected as the candidate anchor frame set.
[0037] A preset angle range and angle step size are defined; the center pixel of the candidate anchor frame in the candidate anchor frame set is used as the rotation center, and multiple rotation operations are performed within the angle range of the directional feature according to the angle step size to obtain multiple micro-rotation windows; the gray-scale variance value of the internal pixels of each micro-rotation window is calculated, and the micro-rotation window with the minimum gray-scale variance value is selected as the adaptive selection area corresponding to the candidate anchor frame;
[0038] Calculate the tilt angle of the adaptive selection area and the absolute difference between the tilt angle and the direction feature; if the absolute difference is less than a preset angle matching threshold, it is determined that the adaptive selection area matches the direction feature, and the adaptive selection area is identified as the target candidate box.
[0039] Preferably, the target candidate box is cropped from the original image to extract the target mask image; an initial skeleton point sequence is extracted from the non-zero pixels of the target mask image; a sliding window is applied to the initial skeleton point sequence to extract an ordered skeleton sequence; the true direction and actual length of the ordered skeleton sequence are calculated to generate a polygonal region. The specific operation steps are as follows:
[0040] The target candidate box is cropped from the original image and binarized to obtain the target mask image; all non-zero pixels in the target mask image are extracted to construct the flow defect connected component;
[0041] Scan each row of pixels in the connected domain of the sag defect, record the coordinates of the leftmost and rightmost pixels in each row, and calculate the coordinates of the midpoint of the row; arrange the midpoint coordinates of all rows of pixels to form an initial skeleton point sequence;
[0042] A sliding window is applied to the initial skeleton point sequence. For each sliding window, the average coordinate of all initial skeleton points is calculated and used as the position coordinate of the window center point to form a central skeleton. All initial skeleton points contained in the central skeleton are extracted, and the skeleton point with the smallest ordinate and the smallest abscissa is selected as the starting endpoint. Starting from the starting endpoint, all initial skeleton points are traversed, and all adjacent initial skeleton points are stored in an ordered skeleton sequence in ascending order of ordinate and abscissa.
[0043] Calculate the direction angle of the line connecting adjacent initial skeleton points along the ordered skeleton sequence to obtain a local direction angle sequence, and select the direction angle of the line connecting the line with the maximum frequency as the true direction.
[0044] Starting from the coordinate position of the starting endpoint, calculate the straight-line distance between adjacent initial skeleton points along the actual direction for the ordered skeleton sequence, and calculate the sum of all straight-line distances as the actual length;
[0045] Based on the actual direction and actual length, a polygonal region of the flow defect connected domain is generated.
[0046] Compared with the prior art, the embodiments of the present invention have at least the following technical advantages:
[0047] Analysis of the above-mentioned target detection method and system for elongated coating sagging defects provided by the present invention shows that, in specific applications, edge feature preprocessing is performed on the original image of the coating surface, and the edge detection operator is used to filter out low-frequency background information of large areas of smooth paint surface, while retaining high-frequency edge details with gray-scale abrupt changes. This effectively suppresses the interference caused by uneven illumination of the paint surface and uniform changes in background color texture, greatly highlights the linear edge features of elongated sagging defects, compresses the invalid image operation area, and provides a highly recognizable image base for subsequent accurate defect identification.
[0048] Furthermore, the method first performs initial coarse localization of the flow defect contour to narrow the target detection range and reduce the overall computational overhead. Then, through an adaptive sliding window mechanism, the window size is dynamically adjusted based on the local grayscale uniformity. Small windows are used to preserve subtle flow features in textured and detailed defect areas, while large windows are used in flat background areas to improve computational efficiency, achieving refined segmentation of multi-scale image sub-blocks. This method combines neighborhood grayscale probability distribution to screen stable and reliable initial candidate seed points, effectively avoiding interference from noise points and speckles. Adaptive segmentation of the defect area is completed through growth of compliant seed point regions, resulting in a polygonal defect area with regular boundaries and complete shape. This effectively distinguishes between point-like stains, blocky impurities, and slender flow defects, significantly reducing the probability of missed and false detections.
[0049] Furthermore, the segmented polygonal regions are identified as elongated paint sagging defects, and the detection results are fed back to the coating control system in real time. This enables targeted adjustments to key process parameters such as spraying pressure, paint viscosity, and gun speed, forming a closed-loop control system for defect detection, status identification, and process correction. This invention effectively improves the identification stability and detection accuracy of elongated paint sagging defects, suppresses the recurrence of coating sagging defects at the source, and significantly improves the appearance quality of the finished paint. It is suitable for automated detection and intelligent production control of elongated defects on various industrial coating surfaces. Attached Figure Description
[0050] Figure 1 This is a flowchart of the main process of a target detection method for coating sagging defects with slender shapes, as described in Example 1.
[0051] Figure 2 This is a flowchart of the initial candidate seed points for a target detection method for elongated coating sagging defects, as described in Example 1.
[0052] Figure 3 This is a schematic diagram of the initial outline of a potential sagging defect in a target detection method for elongated coating sagging defects according to Example 1.
[0053] Figure 4 This is a schematic diagram of the window side length adjustment in a target detection method for elongated coating sagging defects according to Example 1.
[0054] Figure 5 This is a flowchart of the target segmentation region for a target detection method for elongated coating sagging defects in Example 1.
[0055] Figure 6 This is a flowchart of a polygonal region in an embodiment of a target detection method for elongated coating sagging defects.
[0056] Figure 7 This is an overall flowchart of a target detection method for coating sagging defects with slender shapes, as described in Example 1.
[0057] Figure 8 This is a schematic diagram of a micro-rotating window used in a target detection method for elongated coating sagging defects, as described in Example 1.
[0058] Figure 9 This is a flowchart of a target detection system for coating sagging defects with slender shapes, as described in Example 2.
[0059] Labels: Acquisition module 10; Analysis module 20; Identification module 30. Detailed Implementation
[0060] The technical solution of the present invention will now be clearly and completely described 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.
[0061] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings.
[0062] Example 1
[0063] like Figure 1 As shown, this invention provides a target detection method for coating sagging defects with slender shapes. The specific operation method includes:
[0064] S10: Acquire an original image of the coating surface, and preprocess the original image to obtain the image to be detected;
[0065] It should be noted that after acquiring the original image of the coating surface, an appropriate edge detection algorithm (such as the Canny operator, Sobel operator, etc.) is selected to process the image. This operation filters out large areas of smooth background (low-frequency information) and retains only edge details with drastic gray-level changes (high-frequency edge information), thus obtaining a detection image that highlights edge features.
[0066] S20: Extract the initial contour of potential flow defects from the image to be detected; slide a window through the initial contour of the flow defects to form an initial square window; adjust the side length of the initial square window according to the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; construct a square neighborhood window for each pixel in the image sub-blocks of multiple sizes; extract initial candidate seed points according to the probability of the gray values of the pixels within the square neighborhood window; select the growth starting point for the region of the initial candidate seed points and grow them to obtain a polygonal region;
[0067] It should be noted that the above steps first roughly locate the initial outline of the drip to narrow down the processing range, and then generate multi-scale sub-blocks by window scaling. Small windows are used to capture subtle defects in areas with messy textures, while large windows are used in flat paint areas to improve processing efficiency, balancing detail preservation and computing speed. Seed points are selected based on the probability of neighborhood grayscale distribution to ensure that the seed points are located in the grayscale stable area of the defect. The next step is to completely segment the defect area through region growing and fit a polygonal outline with complete boundaries, which can distinguish between dot-like stains, blocky spots and thin drips, and reduce the probability of missed or false defects.
[0068] S30: The polygonal region is regarded as a slender coating sagging defect. The detection result of the slender coating sagging defect is sent to the host computer monitoring system so that the host computer monitoring system can provide feedback to the system to adjust the coating.
[0069] It should be noted that the above steps rely on the polygonal region shape to directly determine the paint sagging defect. The detection results are transmitted back to the coating equipment in real time. The staff or control system can adjust the process parameters such as paint viscosity, spraying pressure, and gun speed based on the feedback data to reduce the generation of sagging defects from the source, realize the detection of coating defects and closed-loop control of the process, and improve the surface quality of the finished paint product.
[0070] like Figure 2 As shown, specifically, in step S20, the initial contour of potential flow defects is extracted from the image to be detected; a sliding window of the initial contour of the flow defects is used as an initial square window; the side length of the initial square window is adjusted according to the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; a square neighborhood window is constructed for each pixel in the image sub-blocks of multiple sizes; initial candidate seed points are extracted according to the probability of the gray values of the pixels within the square neighborhood window; the starting point for the growth of the region is selected from the initial candidate seed points, and the region is grown to obtain a polygonal region. The specific operation steps are as follows:
[0071] S21: Calculate the gradient magnitude and gradient direction for each pixel in the image to be detected;
[0072] For each pixel, the difference in gradient magnitude is calculated by filtering neighboring pixels.
[0073] If the difference in gradient magnitude is less than or equal to a preset threshold for the similarity of magnitude (i.e., the value range is 5% to 20%, preferably 10% to 15%), then the neighboring pixel is taken as the connected pixel of the pixel, forming a connected region.
[0074] For the connected region, determine the x-coordinates of the minimum and maximum values and the y-coordinates of the minimum and maximum values, and further determine the minimum bounding rectangle;
[0075] The aspect ratio of the length and width is calculated based on the minimum bounding rectangle. If the aspect ratio is greater than a preset threshold (i.e., the value ranges from 3 to 15, preferably 5 to 10, dimensionless), then the connected region is determined to be the initial contour of a potential sag defect (i.e., a slender linear target, such as...). Figure 3As shown; when there is only one initial contour of potential sag defects, this initial contour is directly used as the target region in step S22; when there are multiple, each initial contour is used as the target region in turn, and subsequent sliding window operations are performed independently on each target region; wherein, the initial contour of potential sag defects is represented as the connected region that meets the geometric constraints of a slender linear target in terms of morphological features (the aspect ratio is greater than the ratio threshold), but has not yet been verified by subsequent region growth and contour refinement, so it is marked as a candidate-level initial contour; this initial contour is used to narrow the target search range of subsequent sliding window and region growth, rather than the final detection conclusion).
[0076] It should be noted that the above steps, through pixel-by-pixel gradient magnitude and neighborhood gradient difference, construct continuous connected regions based on the principle of similar pixel magnitudes, effectively aggregating target pixels with consistent texture features and eliminating interference from discrete noise pixels. This step, by constructing the minimum bounding rectangle of the connected regions and calculating the aspect ratio, accurately filters the initial contours of flow defects with linear and strip-like features using slender morphological features. This effectively distinguishes between blocky stains, dotted spots, and slender flow defects, achieving preliminary accurate coarse localization of flow defect targets, significantly narrowing the target range for subsequent fine detection, and reducing unnecessary computation. The calculation of gradient magnitude and gradient direction is as follows: the Sobel operator is used to calculate the gradient magnitude and gradient direction, and the horizontal convolution kernel of the Sobel operator... Convolution kernel in the vertical direction ; for images and , Perform convolution operations separately to obtain the horizontal gradient components. gradient components in the vertical direction : Further calculations using gradient components: ; ;in, For the first in the image to be detected Line 1 The grayscale values of the column pixels, The gradient component is in the horizontal direction. For vertical gradient star distribution, For gradient magnitude, The gradient direction;
[0077] S22: Obtain the initial outline of the sag defect in the image to be detected as the target region, and slide the target region with a preset square window as the initial square window;
[0078] The mean gray value of all pixels in the initial square window is calculated as the window mean gray value; the standard deviation of the gray values of all pixels from the window mean gray value is calculated as the window gray standard deviation (i.e., the degree of deviation of the gray value of each pixel in the window from this average value, and this overall deviation is quantified (i.e., the window gray standard deviation), which reflects the roughness or uniformity of the texture inside the window; the larger the value, the more drastic the change in brightness and darkness inside the window; the smaller the value, the flatter and more uniform the gray value inside the window).
[0079] A first grayscale standard deviation threshold (the threshold is the same as the threshold value) and a second grayscale standard deviation threshold are preset (that is, the first grayscale standard deviation threshold (i.e., the value range is 50~100 (image grayscale range 0~255), preferably 70~85) is greater than the second grayscale standard deviation threshold (i.e., the value range is 10~30 (image grayscale range 0~255), preferably 15~25)).
[0080] If the window's grayscale standard deviation is greater than the first grayscale standard deviation threshold, the side length of the initial square window is adjusted and reduced (i.e., the side length of the initial square window is reduced to half of its original side length). The grayscale standard deviation of the window is recalculated using the adjusted and reduced initial square window, and the adjustment and reduction operation is repeated until the recalculated window grayscale standard deviation is less than or equal to the first grayscale standard deviation threshold. The finally adjusted and reduced initial square window is used as the first size sub-block (that is, as the side length of the initial square window is reduced with each reduction, the number of pixels inside also decreases; this also indicates that if the window's grayscale standard deviation is greater than the high threshold, it means that there are too many details and messy textures in the current window, and it is not suitable for overall processing; at this time, the side length of the window is reduced to half of its original size (the area is reduced to one-quarter), such as... Figure 4 As shown, the grayscale mean square error is recalculated using a smaller window. If the mean square error is still greater than the high threshold after shrinking, it is continued to shrink until it drops below the high threshold. The area covered by the final determined small window is marked as the first-size sub-block (applicable to fine detail areas, i.e., small-sized sub-blocks).
[0081] If the window's grayscale standard deviation is less than the second grayscale standard deviation threshold, the side length of the initial square window is adjusted and enlarged (i.e., the side length of the currently processed window is doubled). The window's grayscale standard deviation is recalculated using the adjusted and enlarged initial square window, and this adjustment and enlargement operation is repeated until the recalculated window's grayscale standard deviation is greater than or equal to the second grayscale standard deviation threshold. The finally adjusted and enlarged initial square window is used as the third-size sub-block (that is, as the side length of the initial square window increases with each expansion, the total number of pixels inside also increases; this also indicates that if the window...). If the grayscale standard deviation is less than the low threshold, it indicates that the current window is very flat and lacks variation, and a larger area can be merged. At this time, the window side length is expanded to twice the original (the area is expanded to four times), and the grayscale standard deviation is recalculated using the expanded window. If it is still less than the low threshold after expansion, it is expanded again until the standard deviation rises above the low threshold. The area covered by the finally determined large window is marked as the third-size sub-block (applicable to flat background areas, i.e., large-size sub-blocks)). That is, the second grayscale standard deviation threshold is the low standard deviation threshold, and the first grayscale standard deviation threshold is the high standard deviation threshold.
[0082] If the grayscale standard deviation of the window is greater than or equal to the second grayscale standard deviation threshold and less than or equal to the first grayscale standard deviation threshold, then the initial square window is taken as the second-size sub-block (that is, if the grayscale standard deviation of the window is between the low threshold and the high threshold, it means that the texture uniformity of the current window is moderate, neither too rough nor too flat, and there is no need to adjust the size; at this time, the area currently covered by the window is directly marked as the second-size sub-block (applicable to the transition area, that is, the medium-sized sub-block)).
[0083] All adjacent sub-blocks of the same type are merged to obtain multi-sized image sub-blocks (i.e., all marked first-size, second-size, and third-size sub-blocks within the target area are collected; a merging operation is performed on adjacent sub-blocks with the same marking type; and sub-blocks that still have overlapping areas after merging are deduplicated according to a preset priority rule to generate the multiple image sub-blocks with scale differences; wherein, the priority rule is as follows: when a first-size sub-block overlaps with a second-size or third-size sub-block, the first-size sub-block area is retained, and the larger size or second-size sub-block area of the overlapping part is discarded; when a second-size sub-block overlaps with a third-size sub-block, the second-size sub-block area is retained, and the third-size sub-block area of the overlapping part is discarded; for overlapping sub-blocks of the same size type, the sub-block area that was merged first is retained according to the coordinate order).
[0084] It should be noted that the above steps employ a sliding window scale adjustment mechanism for the initial target area of the drip defect. The window size is adjusted by quantifying the local texture uniformity based on the window's grayscale standard deviation. For areas with messy textures and drastic grayscale fluctuations, the window size is reduced to preserve the details of local, subtle defect textures. For background areas with flat grayscale and uniform textures, the window size is expanded to achieve rapid and homogeneous fusion of a large area of background. For transitional texture areas, a medium window size is maintained. Through iterative adjustment and merging of similar sub-blocks using multi-scale windows, the steps achieve differentiated block representation of the fine defect area, transitional area, and flat background area. This addresses the limitation of fixed-scale windows being unable to simultaneously adapt to complex textures and flat backgrounds, providing a scale-adapted image sub-block basis for subsequent local feature quantification analysis.
[0085] S23: Using each pixel within an image sub-block as the center, construct a square neighborhood window corresponding to the size of the image sub-block (i.e., for each selected pixel, construct a square neighborhood window centered on that pixel that matches the size of the analysis window; if the current sub-block belongs to the first size sub-block, the neighborhood window is correspondingly smaller; if it belongs to the third size sub-block, the neighborhood window is correspondingly larger; the purpose of doing this is to make the neighborhood range adapt to the local texture scale).
[0086] The frequency of grayscale values of each pixel within each square neighborhood window is counted, and the probability of occurrence of each grayscale value within each square neighborhood window is calculated as the probability mass function value of that pixel's grayscale value (that is, the ratio of the frequency of each grayscale level to the total number of pixels in the window is the probability of that grayscale level appearing in the window. This step converts absolute frequencies into relative probabilities, making the data comparable between windows of different sizes).
[0087] The local entropy value of the center pixel within the square neighborhood window is calculated by multiplying the probability mass function values corresponding to the grayscale values of all pixels within the window by their natural logarithms and taking the opposite of each value. The final value obtained by summing all the processed results is the local entropy value of the center pixel within the square neighborhood window. The local entropy value reflects the degree of disorder in the grayscale distribution within the window. The entropy is determined by the degree or richness of information. If the grayscale distribution within a window is uniform (e.g., all are the same grayscale), the entropy value will be very low; if the grayscale variation within a window is diverse (containing many different grayscale values), the entropy value will be very high. The natural logarithm ln, which is the logarithm with the mathematical constant e (Euler's number) as its base, is widely used in probability theory. It is calculated by multiplying the information content of each grayscale value (i.e., −ln(probability)) by the probability of that grayscale value occurring (weighted), and then summing the weighted information content of all grayscale values to obtain the average information content of the entire window, which is the entropy. The formula is: Where L is the total number of grayscale values (for an 8-bit grayscale image, L=256), and g represents the grayscale index (0 ≤ g ≤ L-1). The probability mass function value of grayscale value g appearing within the square neighborhood window; when When = 0, define =0; In this formula, the natural logarithm (base e) is used for calculation, and the unit of local entropy is nat; In this invention, local entropy is only used for relative ranking comparison (selecting the minimum value) among pixels within the same image sub-block, and is not used as a measure of absolute information content; If a logarithm with another base (such as base 2) is used, since the logarithms of different bases differ by only a constant multiple (base-changing formula), the entropy values of all pixels are multiplied by the same constant factor, and the ranking result of the entropy values is not changed. Therefore, the difference in the choice of base does not affect the implementation effect of this invention).
[0088] The pixels with the minimum local entropy value within the image sub-block are selected as the initial candidate seed points for that image sub-block.
[0089] It should be noted that the above steps construct a neighborhood window of matching size according to the scale of each image sub-block, count the frequency of gray-level distribution within the window and calculate the probability quality function, and further solve the local entropy value of each pixel to quantify the complexity and information richness of the gray-level distribution in the local region. This step selects the pixel with the minimum entropy value in each sub-block as the initial candidate seed point, which can accurately locate the core pixel position with stable gray-level and strong feature consistency inside the flow defect area, and avoids selecting edge noise points with complex texture and strong noise interference as growth seeds, effectively improving the accuracy and stability of subsequent regional growth and ensuring that the seed point has good regional representativeness.
[0090] S24: Determine the coordinates and grayscale values of the initial candidate seed points; filter adjacent seed point pairs based on the coordinates and grayscale values; calculate the strain compatibility coefficient of adjacent seed point pairs based on their grayscale values; filter the adjacent seed point pairs into the first candidate set based on the strain compatibility coefficient; use the initial candidate seed point with the minimum local entropy value in the first candidate set as the starting point for region growth; grow adjacent pixels to obtain the target segmentation region; apply a binary mask to the target segmentation region and filter the target edge pixel set; extract polygonal regions from the target edge pixel set.
[0091] It should be noted that the above steps construct a strain compatibility coefficient by using the coordinates of adjacent seed points and grayscale features, select high-quality seed points with high feature matching to construct a candidate set, and eliminate interfering seed points with large feature differences and no homology. Next, neighborhood region growth is performed using the optimal low-entropy seed point as the starting point to fully fit the real region of the flow defect, forming an accurate target segmentation region. The next step uses binary masking to extract the complete edge pixel set and completes polygon region fitting output, ultimately obtaining a precise segmentation contour of the flow defect with regular boundaries, complete region, and no noise interference. This step effectively solves the problems of over-growing, under-growing, and strong randomness in seed point selection in traditional region growth, significantly improving the completeness and edge accuracy of flow defect segmentation.
[0092] like Figure 5 As shown, specifically, in step S24, the coordinate positions and gray values of the initial candidate seed points are determined; adjacent seed point pairs are filtered based on the coordinate positions and gray values; the strain compatibility coefficient of the adjacent seed point pairs is calculated based on the gray values of the adjacent seed point pairs; the adjacent seed point pairs are filtered into the first candidate set based on the strain compatibility coefficient; the initial candidate seed point with the minimum local entropy value in the first candidate set is used as the starting point for region growth, and adjacent pixels are grown to obtain the target segmentation region; a binary mask is applied to the target segmentation region to filter the target edge pixel set; polygon regions are extracted from the target edge pixel set. The specific operation steps are as follows:
[0093] S241: Determine the coordinates and grayscale values of the initial candidate seed points, and calculate the Euclidean distance between two random initial candidate seed points (i.e., only seed points that are sufficiently close in coordinates are considered to be potentially related, while seed points that are far apart do not participate in subsequent compatibility calculations).
[0094] If the Euclidean distance is less than a preset distance threshold (i.e., the value range is 10~50 pixels, preferably 20~30 pixels), then the two initial candidate seed points corresponding to the Euclidean distance are regarded as adjacent seed point pairs.
[0095] Extract the coordinate position and gray value corresponding to the first initial candidate seed point in the adjacent seed point pair as the first coordinate and the first gray value, and extract the coordinate position and gray value of the second initial candidate seed point as the second coordinate and the second gray value;
[0096] It should be noted that the above steps screen the spatial distance relationship of the initial candidate seed points, constrain the seed point pairing range with the Euclidean distance threshold, construct adjacent seed point pairs only for spatially nearby seed points, discard redundant calculations of distant invalid seed points, screen out discrete and isolated interference seeds from the spatial dimension, ensure that the seed points participating in the subsequent compatibility determination have a spatial relationship basis, effectively reduce the amount of subsequent feature calculations, and improve the rationality and relevance of seed point pairing;
[0097] S242: The reciprocal of the Euclidean distance between the first and second coordinates is used as the coordinate proximity metric; and the coordinate proximity metric is normalized to obtain the normalized coordinate proximity metric (i.e., the Euclidean distance has been calculated in the above steps and will not be calculated again; using the already calculated straight-line distance between the two seed points, the smaller the Euclidean distance, the closer the two points are in space; convert this Euclidean distance into a proximity score, the shorter the distance, the higher the proximity score; the longer the distance, the lower the proximity score. After obtaining the preliminary score, normalize the score to compress it into a uniform numerical range (such as between 0 and 1), so that the scores between different seed point pairs are comparable. The normalized result is called the normalized coordinate proximity metric).
[0098] Calculate the absolute difference between the first grayscale value and the second grayscale value. Use the reciprocal of this absolute difference as the grayscale similarity measure. Normalize this grayscale similarity measure to obtain a normalized grayscale similarity measure (i.e., take the first and second grayscale values and calculate their absolute difference; the smaller the grayscale difference, the closer the brightness of the two points, and the greater the probability that they belong to the same defect area). Convert this grayscale difference into a similarity score; the smaller the difference, the higher the similarity score; the larger the difference, the lower the similarity score. Similarly, normalize this score to a uniform numerical range. The normalized result is called the normalized grayscale similarity measure. The normalization step involves performing Min-Max normalization on the coordinate proximity measure, linearly mapping the coordinate proximity measure to... The interval is used as the normalized coordinate proximity metric; the Min-Max normalization formula is: Where x is the coordinate proximity metric of the current seed point pair. and These are the minimum and maximum values of the coordinate neighbors for all seed point pairs; the normalization of the gray-level similarity metric is adjusted in the same way.
[0099] The weighted product of the normalized coordinate proximity metric and the normalized grayscale similarity metric is calculated and used as the strain compatibility coefficient of the adjacent seed point pair. (This involves combining the normalized coordinate proximity metric and the normalized grayscale similarity metric, assigning weights to each metric, and then multiplying the two weighted values (or performing other fusion operations) to obtain the final comprehensive score (i.e., the strain compatibility coefficient). This comprehensive score is the strain compatibility coefficient corresponding to the adjacent seed point pair. This strain compatibility coefficient comprehensively reflects the degree of coordination and consistency between the two seed points in terms of both space and grayscale. The higher the coefficient, the more likely the two seed points belong to the same flow defect region. Specifically, the normalized coordinate proximity metric is calculated.) Similarity metric to normalized grayscale The weighted sum of these factors, taken as the strain compatibility coefficient C for the adjacent seed point pairs, is calculated using the following formula: ;in, Spatial proximity weighting coefficient, This refers to the gray-scale similarity weighting coefficient. and All are pre-defined positive real numbers that satisfy... ,and ; and The value of is determined according to the following rules: when the lighting conditions on the surface of the coating to be tested are uniform and the background color of the paint is consistent, the reliability of the grayscale feature is high. When the lighting conditions on the surface of the coating to be tested are uneven, shadows are present, or the base color of the paint changes gradually, the reliability of grayscale features decreases. Therefore, the weight of spatial proximity features should be increased. Under normal lighting conditions, the default setting is... In the above weighted summation fusion method, and All are dimensionless normalized values (the range of values is 1000). ,1]), therefore the weighted sum The dimensionless range of values is This facilitates subsequent compatibility filtering with preset threshold values (range). (to make a direct comparison).
[0100] It should be noted that the above steps construct quantitative evaluation indicators from two dimensions: spatial proximity and gray-level similarity. The spatial Euclidean distance and gray-level difference are converted and normalized to unify the dimensional range of the two types of features and avoid the evaluation imbalance caused by dimensional differences. The steps calculate the strain compatibility coefficient through weighted fusion, which comprehensively characterizes the spatial distribution correlation of seed points and the consistency of gray-level features. It accurately quantifies the degree of matching of seed points belonging to the same sag defect area, realizes the digital and standardized judgment of seed point correlation characteristics, and avoids the limitations of single feature judgment.
[0101] S243: A preset compatibility screening threshold (i.e., a value ranging from 0.6 to 0.9, preferably 0.75 to 0.85, dimensionless); if the strain compatibility coefficient corresponding to the adjacent seed point pair is greater than the compatibility screening threshold, the adjacent seed point pair is marked to form a first candidate set; unmarked adjacent seed point pairs are assigned to a second candidate set (i.e., each strain compatibility coefficient is compared with the preset compatibility screening threshold; if the strain compatibility coefficient is higher than the threshold, it indicates that the two initial candidate seed points are closely related, and the two initial candidate seed points are marked as reserved and assigned to the first candidate set; if the strain compatibility coefficient is equal to or lower than the threshold, it indicates that the two initial candidate seed points are distantly related, and they are marked as pending and assigned to the second candidate set).
[0102] For each initial candidate seed point in the second candidate set, the average strain compatibility coefficient is calculated with that of the initial candidate seed points in the first candidate set.
[0103] If the average strain compatibility coefficient is greater than the compatibility screening threshold, the initial candidate seed point of the second candidate set is moved to the first candidate set; if the average strain compatibility coefficient is less than or equal to the compatibility screening threshold, the initial candidate seed point of the second candidate set is removed (that is, for each undetermined seed point in the second candidate set, the average strain compatibility coefficient between it and all retained seed points in the first candidate set is calculated, and then this average value is compared with the screening threshold. If the average value is greater than the threshold, it means that although the undetermined point has a general relationship with some points, it is still compatible with most of the retained points as a whole, so it is moved from the second candidate set to the first candidate set and converted to the retained class; if the average value is less than or equal to the threshold, it means that the point is incompatible with all the retained points and is an isolated point, so it is marked as the removal class).
[0104] It should be noted that the above steps complete the initial classification of seed point pairs by fixing the compatibility threshold, dividing the highly correlated first candidate set and the undetermined second candidate set. Then, the average compatibility between the seed points in the second candidate set and the seed points in the first candidate set is used for secondary verification to complete the iterative screening and classification of the undetermined seed points. This hierarchical screening mechanism can effectively absorb marginally correlated seeds, remove isolated noise seeds, and retain defective effective seed points to the maximum extent. It completely solves the problems of strong randomness, erroneous retention of noisy points, and erroneous removal of effective points in traditional seed screening, and ensures the purity and integrity of the seed point set.
[0105] S244: Select the initial candidate seed point with the minimum local entropy value in the first candidate set as the starting point for region growth, and calculate the gray level difference by traversing adjacent pixels in the adjacent domain with the starting point for region growth as the center.
[0106] If the grayscale difference is less than the preset grayscale growth threshold (i.e., the value range is 5~20 grayscale levels (image grayscale range 0~255), preferably 8~12), then the adjacent pixel is taken as the growth pixel.
[0107] The grown pixel is used as the new starting point for region growth. The adjacent pixels are traversed from the new starting point for region growth. This process is repeated until the adjacent pixels can no longer be used as the new starting point for region growth, thus forming an independent segmented region.
[0108] All initial candidate seed points are used to obtain independent segmented regions, and all independent segmented regions are merged to obtain the target segmented region. (That is, because sag defects are usually continuous elongated strips, the same defect may be grown into several adjacent small regions by multiple seed points. The merging operation can reassemble these fragments into a complete defect region. The final merged overall region is the target segmented region. The target segmented region serves as the coarse localization region for sag defects, improving the localization accuracy of defect boundaries. The specific operation involves processing each candidate seed point in the first candidate set...) Centered on the seed point, the system iterates through its four (or eight) neighboring pixels, calculating the grayscale difference between each neighboring pixel and the current growth starting point. If this grayscale difference is less than a preset grayscale growth threshold (ranging from 5 to 20 grayscale levels, preferably 8 to 12), the neighboring pixel is included in the growth region and used as a new growth starting point to continue expanding outwards. This expansion operation is repeated until all boundary neighboring pixels of the current growth region fail to meet the condition that the grayscale difference is less than the threshold, thus forming a growth region composed of a seed point. The generated independent segmented regions Perform the above operation on each seed point in the first candidate set, generating a total of M independent segmentation regions {R1, R2, ..., (M equals the total number of seed points in the first candidate set); then, according to the conflict resolution rules specified in S244 (the smaller the local entropy value, the higher the priority to occupy the pixel), all independent segmented regions are merged to generate the final target segmented region).
[0109] It should be noted that the above steps take the low-entropy high-quality seed points in the first candidate set as the starting point for growth, and rely on the neighborhood gray-level difference threshold to constrain the growth range of the region. The pixel growth is completed iteratively step by step, which accurately matches the gray-level distribution characteristics of the sag defect and effectively avoids the problems of over-growing regions invading the background and under-growing regions missing the defect region. The steps integrate the fragmented segmented regions of the same sag defect into a complete and connected target segmented region through multiple sub-independent region merging mechanisms, which completely restores the continuous shape of the long strip sag defect and greatly improves the integrity of the defect region segmentation.
[0110] S245: Perform binarization masking on the target segmentation region to extract corresponding local image patches from the image to be detected; calculate the gradient magnitude and gradient direction of the pixels in the local image patches, filter first-level edge points and second-level edge points, and generate a target edge pixel set; extract the minimum bounding rectangle from the target edge pixel set, and calculate the morphological and directional features of the minimum bounding rectangle; input the local image patches into a pre-trained feature extraction network to output a global statistical feature map, and combine the morphological and directional features with the global statistical feature map to generate a multi-dimensional feature map; preset multiple initial horizontal anchor boxes with different aspect ratios and scales for the multi-dimensional feature map, rotate the initial horizontal anchor boxes clockwise, and extract target candidate boxes; crop the target candidate boxes from the original image and extract the target mask image; extract the initial skeleton point sequence from the non-zero pixels in the target mask image; slide a window through the initial skeleton point sequence to extract an ordered skeleton sequence; calculate the true direction and actual length of the ordered skeleton sequence to generate a polygonal region.
[0111] It should be noted that the above steps involve using a binary mask to extract effective local image patches from the segmented region, combining gradient features for hierarchical filtering to accurately obtain multi-level edge pixel sets, and relying on the minimum bounding rectangle to extract defect morphology and orientation features. A deep learning feature extraction network is used to output global statistical features, and multi-dimensional features are integrated to construct a complete feature representation system. Affine transformations of anchor frames at multiple scales and aspect ratios are used to adapt to flow defects of arbitrary direction and scale, accurately locking the defect target region. Finally, the skeleton sequence is optimized to extract the true direction and actual extension length of the defect, fitting and generating a precise polygonal defect region, outputting a flow defect contour with regular boundaries, realistic shape, and accurate scale, significantly improving the fine segmentation and morphology detection capabilities of flow defects in complex coating backgrounds.
[0112] like Figure 6 , 7As shown, specifically, in step S245, a binarized mask is applied to the target segmentation region to extract the corresponding local image patch in the image to be detected; the gradient magnitude and gradient direction of the pixels in the local image patch are calculated, and first-level edge points and second-level edge points are selected to generate a target edge pixel set; the minimum bounding bounding rectangle is extracted from the target edge pixel set, and the morphological and directional features are calculated for the minimum bounding bounding rectangle; the local image patch is input to a pre-trained feature extraction network to output a global statistical feature map, and the morphological and directional features are combined with the global statistical feature map to generate a multi-dimensional feature map; multiple initial horizontal anchor boxes with different aspect ratios and scales are preset for the multi-dimensional feature map, and the initial horizontal anchor boxes are rotated clockwise to extract target candidate boxes; the target candidate boxes are cropped from the original image to extract the target mask image; the initial skeleton point sequence is extracted from the non-zero pixels in the target mask image; the initial skeleton point sequence is slid-windowed to extract an ordered skeleton sequence; the true direction and actual length of the ordered skeleton sequence are calculated to generate a polygonal region. The specific operation steps are as follows:
[0113] S2451: Perform a binarization mask on the target segmentation region, and extract the corresponding local image patch from the image to be detected based on the target segmentation region of the binarization mask (i.e., extract the coordinate positions and gray values of all pixels in the target segmentation region generated in the above steps; then, construct a binarization mask that completely corresponds to the shape of the region (white inside the region and black outside the region); using the target segmentation region of the binarization mask, extract the small image patch covered by the mask from the image to be detected as a local image patch, the purpose of which is to focus all subsequent processing on the defect region and eliminate background interference).
[0114] The Sobel operator is used to perform convolution operation on the local image patch, and the gradient components of each pixel in the local image patch in the horizontal and vertical directions are calculated respectively.
[0115] The gradient magnitude and gradient direction of each pixel are calculated based on the gradient components in the horizontal and vertical directions. (That is, the Sobel operator (an edge detection convolution kernel) is used to operate on local image blocks. The image is scanned with convolution kernels in the horizontal and vertical directions to obtain the gradient change components of each pixel in the horizontal and vertical directions. Then, based on these two components, two values are calculated for each pixel: one is the gradient magnitude (reflecting the strength of the edge at that point), and the other is the gradient direction (reflecting the orientation angle of the edge at that point)).
[0116] If the gradient magnitude of a pixel is greater than the gradient magnitude of its left and right adjacent pixels, then the pixel is considered an edge candidate point.
[0117] A high edge threshold (i.e., a grayscale gradient amplitude range of 100~200, preferably 150~180) and a low edge threshold (i.e., a grayscale gradient amplitude range of 30~80, preferably 40~60 (and the low edge threshold < the high edge threshold)) are preset; if the gradient amplitude of the edge candidate point is greater than the high edge threshold, then the edge candidate point is regarded as a first-level edge point;
[0118] If the gradient magnitude of the candidate edge point is greater than the low edge threshold and less than the high edge threshold, then the candidate edge point is designated as a secondary edge point. The primary edge point and the secondary edge point are used to generate a target edge pixel set (i.e., only those pixels with the largest gradient magnitude in the gradient direction are retained, while those with non-largest magnitudes are suppressed to make the edges thinner and clearer; then, two thresholds, a high threshold and a low threshold, are set; points with gradient magnitudes greater than the high threshold are determined as primary edge points (confirmed as true edges), and points between the low threshold and the high threshold are determined as secondary edge points (which may be edges or noise); finally, the primary edge points and all secondary edge points connected to the primary edge points are retained to form the target edge pixel set).
[0119] For the edge points (i.e., first-level edge points or second-level edge points) with minimum and maximum x coordinates and minimum and maximum y coordinates in the target edge pixel set, generate the minimum bounding rectangle that encloses the target edge pixel set.
[0120] Extract the length of the long side and the length of the short side of the minimum circumscribed rotating rectangle, and calculate the length ratio as a morphological feature;
[0121] Based on the length of the long side of the minimum circumscribed rotating rectangle, determine the long side direction vector and the horizontal unit vector, and calculate the included angle as the direction feature (i.e., within the minimum circumscribed rotating rectangle, first identify which side is the long side (i.e., the side whose length is greater than the other side); then, establish a direction vector along this long side from one end to the other, with the starting point of this vector being the first endpoint of the long side and the ending point being the second endpoint of the long side; this vector represents the main extension direction of the sag defect; where the first endpoint is the left endpoint of the long side, which is also the starting point; in the image coordinate system, define a standard horizontal to the right reference vector; this vector is characterized by a length of 1 (unit vector) and a direction strictly pointing to the right of the image, serving as the reference baseline for all angle measurements; the long side direction vector and the horizontal to the right unit vector are placed in the same coordinate system, and calculate the angle traversed by rotating counterclockwise from the horizontal to the right direction to the long side direction, which reflects the degree of directional deviation between the two, serving as the direction feature; the calculation formula is to extract the long side direction vector of the minimum circumscribed rotating rectangle). Horizontal unit vector The directional features The calculation formula is: ;in, The range of values is ,when This indicates that the defect is oriented horizontally. The time indicates that the defect is oriented towards the vertical direction, clockwise. The time indicates that the defect's direction is biased towards the counterclockwise side of the vertical direction; in this scheme, all directional angles adopt the undirected directional angle representation method, and the value range is uniformly standardized as [-90°, 90°]. That is, before any directional angle θ participates in the calculation, the following normalization process is performed: if θ > 90°, then θ = θ - 180°; if θ < -90°, then θ = θ + 180°; if θ ∈ [-90°, 90°], then it remains unchanged; this normalization process ensures that +89° and -91° (actually only 2° apart) are uniformly mapped to adjacent regions close to ±90°, avoiding statistical discrepancies caused by the periodicity of angles).
[0122] The local image patch is input into a pre-trained feature extraction network, which outputs a global statistical feature map. (That is, the local image patch is fed into a pre-trained feature extraction network (such as a convolutional neural network); this network processes the image through multiple convolutional layers (extracting local patterns) and pooling layers (compressing spatial size and expanding receptive field) alternately, and finally outputs a deep spatial feature map; the deep spatial feature map contains rich deep semantic information of the defect region; at the same time, two pooling operations are performed on the deep spatial feature map, one is global average pooling (calculating the global average value of each channel), and the other is global max pooling (extracting the maximum response value of each channel); the results of these two pooling operations are concatenated end to end along the channel dimension to form a global statistical feature map).
[0123] The global statistical feature map, morphological features, and orientation features are input into a pre-constructed multimodal feature fusion module, which outputs a multidimensional feature map. This multimodal feature fusion module first expands the scalar values of morphological and orientation features to a feature map with the same spatial size as the global statistical feature map, enabling element-wise operations. Then, the expanded morphological feature map, orientation feature map, and deep spatial feature map are concatenated along the channel dimension to form a comprehensive feature map that integrates deep semantics and geometric orientation information, ultimately outputting a multidimensional feature map with orientation awareness. Specifically, the multimodal feature fusion module operates by denoting the global statistical feature map as... Its spatial dimensions are The number of channels is C; the morphological features (aspect ratio scalar) and directional features (tilt angle scalar) are expanded in dimension: by copying and filling, the two scalar values are each expanded to The feature maps are denoted as follows: and ;Will , and Concat the data along the channel dimension to obtain... The initial fusion feature map; the initial fusion feature map is then passed sequentially through a... A convolutional layer (output channels C, stride 1, padding 1) and a batch normalization layer, followed by a ReLU activation function, result in an output dimension of C. Multidimensional feature map This multidimensional feature map As the feature map basis for the preset initial horizontal anchor boxes in step S2452, it directly replaces the end feature map of the original deep learning network and is used for subsequent anchor box classification and regression calculations.
[0124] It should be noted that the above steps involve using a binarized mask to extract local image patches of the defect, completely removing irrelevant paint background, reducing the scope of subsequent calculations, and minimizing computational overhead for invalid pixels. The Sobel operator is used to calculate the horizontal and vertical gradient components of the image, converting the gradient magnitude and direction. Non-maximum suppression is then used to compress the edge width. Next, a double-threshold layer is used to divide the first and second-level edge points, retaining only valid second-level edges connected to the first-level edges, eliminating discrete gray-level abrupt noise, and obtaining a clean and continuous set of target edge pixels. A minimum bounding rectangle is generated based on the edge coordinates, extracting aspect ratio morphological features and long-side angle features to accurately quantify the slender shape and overall tilting trend of the spill defect. The local image patch is input into a pre-trained convolutional network, and global averaging and max pooling are used to concatenate the data to obtain a global statistical feature map. Then, through dimensional expansion and channel concatenation, geometric shape, direction, and deep semantic information are fused to generate a comprehensive multi-dimensional feature map, simultaneously considering both the geometric attributes of the defect's appearance and deep texture features, providing multi-dimensional judgment criteria for anchor box matching.
[0125] S2452: Preset multiple initial horizontal anchor boxes with different aspect ratios and scales for each pixel on the multidimensional feature map;
[0126] Extract the center pixel of each initial horizontal anchor frame and determine its horizontal and vertical coordinates, width, and height.
[0127] Using the center pixel of each initial horizontal anchor frame as the rotation center and the direction feature as the rotation reference angle, each initial horizontal anchor frame is rotated (i.e., rotated around the center point; the rotation direction depends on the direction feature of step S2451 above: if greater than 0, rotate clockwise; if less than 0, rotate counterclockwise; if equal to 0, rotate horizontally; since the sagging defect on the paint surface is a thin, elongated line shape with arbitrary tilt direction, and conventional horizontal anchor frames can only adapt to horizontal or vertical targets, using horizontal anchor frames to select tilted sagging will result in a large number of background pixels within the anchor frame, diluting the defect feature and reducing the positioning accuracy; therefore, it is necessary to perform a rotation transformation on the initial horizontal anchor frame to align it with the true direction of the sagging defect, thereby improving the selection quality of the defect area and the subsequent detection accuracy), generating initial rotating anchor frames, and calculating the tilt angle of each initial rotating anchor frame (i.e., the tilt angle is also the direction feature, calculated in the same way as the direction feature calculation method: first obtain the long side direction vector and the horizontal unit vector of the initial horizontal anchor frame, and then calculate the included angle as the tilt angle of the initial rotating anchor frame);
[0128] Calculate the absolute angle difference between the tilt angle of each initial rotating anchor frame and the directional feature, and sort them in descending order. Select the first k initial rotating anchor frames with the smallest absolute angle difference as the candidate anchor frame set (that is, select the first k initial rotating anchor frames with the smallest absolute angle difference, the purpose of which is to coarsely screen and remove those anchor frames whose angles obviously do not conform to the target orientation. Specifically, calculate the absolute angle difference between the tilt angle of each initial rotating anchor frame and the directional feature, sort them in ascending order according to the absolute angle difference, and select the first k initial rotating anchor frames with the smallest absolute angle difference as the candidate anchor frame set; where the value of k is determined by the rule: k = min(total number of initial rotating anchor frames × 20%, 50), that is, take the smaller value between 20% and 50 of the total number of initial rotating anchor frames, and k is at least 3; the technical basis of this value rule is: while ensuring that enough angle candidate samples are covered to retain the optimal matching angle, invalid anchor frames with excessive angle deviation (lower ranking of angle difference) are filtered out, and the computational load of subsequent micro-rotation operations is controlled within a preset acceptable range).
[0129] The preset angle range (i.e., the value range is ±10°~±20°, preferably ±15°) and angle step size (i.e., the value range is 0.5°~3°, preferably 1°~2°).
[0130] Using the center pixel of the candidate anchor frame in the candidate anchor frame set as the rotation center, multiple rotation operations are performed within the angle range of the directional feature according to the angle step size to obtain multiple micro-rotation windows (that is, although the directional feature can reflect the macroscopic direction of the sag defect, due to factors such as edge pixel discretization, minimum bounding rectangle fitting error, and the bending of the defect itself, there is a deviation of ±5°~15° between the directional feature and the actual defect direction. If the directional feature angle is directly used as the final selection angle, there is still a significant misalignment between the anchor frame and the actual defect contour, resulting in a large number of background pixels mixed in within the selection area; therefore, it is necessary to perform a fine search within the neighborhood of the directional feature angle with a small angle step size, and find the angle that best fits the actual defect direction by successively micro-rotating traversal).
[0131] For each micro-rotation window, the grayscale variance of its internal pixels is calculated. The micro-rotation window with the minimum grayscale variance is selected as the adaptive selection region corresponding to that candidate anchor frame. (That is, for each candidate anchor frame in the candidate anchor frame set, with the center point of the anchor frame as the rotation center, multiple micro-rotation operations are performed within a range of ±15 degrees of the directional feature angle, according to a preset small angle step size (e.g., rotating 1 or 2 degrees each time). Figure 8 As shown; with each rotation, the dispersion (variance) of grayscale values of all pixels within the current rotation frame is calculated; the micro-rotation window with the smallest internal grayscale variance among all micro-rotation results is selected as the adaptive selection area corresponding to the candidate anchor frame; since the grayscale inside the sag defect is usually relatively uniform, the smallest variance means that the selection area best fits the defect body and has the least background interference; where, the adaptive selection area is represented by the position of the rotation window with the most uniform internal pixel grayscale distribution during the process of the candidate anchor frame's angle fine-tuning around the center pixel, that is, the selection posture with the highest proportion of sag defect pixels and the lowest proportion of background paint pixels within the selection area; the grayscale distribution inside the sag defect is relatively uniform, while there is a grayscale difference between the defect and the background. When the angle of the rotation window is consistent with the actual direction of the defect, the background interference inside the window is minimized, and the grayscale variance value is minimized).
[0132] Calculate the tilt angle of the adapted selection area and the absolute difference between the tilt angle and the direction feature (i.e., the direction feature of the original smallest circumscribed rectangle of the adapted selection area). If the absolute difference is less than a preset angle matching threshold (i.e., the value range is 5°~15°, preferably 8°~12°), then the adapted selection area is determined to match the direction feature, and the adapted selection area is determined as the target candidate box. (i.e., calculate the tilt angle of the adapted selection area and calculate the absolute difference between the tilt angle and the direction feature extracted in step S2451; if the absolute difference is less than the preset angle matching threshold, then the adapted selection area is determined to match the direction feature, indicating that the angle of the selection area is consistent with the target direction height, the match is determined to be successful, and the adapted selection area is officially determined as the final target candidate box; if the difference is greater than the threshold, it indicates that the adapted selection area does not match the direction feature, the match is determined to be unsuccessful, and it is not adopted).
[0133] It should be noted that the above steps involve deploying initial horizontal anchor frames of multiple scales and aspect ratios on the multi-dimensional feature map, and performing affine rotation with the frame center as the rotation reference and the defect direction features as the reference to generate rotating anchor frames that fit the tilted flow. This step uses the difference between the anchor frame tilt angle and the main defect direction to coarsely screen and remove invalid anchor frames with excessive orientation deviation, thus reducing the number of candidate samples. Small-range multi-angle micro-rotation traversal is performed on the remaining candidate anchor frames, and the window with the smallest gray-level variance within the frame is selected as the adaptation region. This fully fits the characteristics of uniform gray-level inside the flow and significant differences in background gray-level, locking in the selection range with the lowest background ratio and the highest defect fit. A secondary verification of the angle matching threshold is added to retain only the adaptation frames that highly match the main defect direction, accurately outputting the target candidate frames that fit the actual tilt angle of the flow and have no extra background at the boundaries, solving the problem that fixed horizontal anchor frames cannot adapt to tilted flow and that the frames are mixed with a large amount of background interference.
[0134] S2453: Crops out the target candidate box from the original image and performs a binarization mask to obtain the target mask image (i.e., after masking, the normal paint background has been removed, and only defective pixels are retained).
[0135] Extract all non-zero pixels from the target mask image and construct the flow defect connected component;
[0136] Scan each row of pixels in the connected domain of the sag defect, record the coordinates of the leftmost and rightmost pixels in each row, and calculate the midpoint coordinates of the pixels in that row; arrange the midpoint coordinates of all rows of pixels to form an initial skeleton point sequence (i.e., scan the connected domain of the defect row by row in order from top to bottom; for each row currently scanned, find the pixels belonging to the defect region from left to right in that row, and record the coordinates of the first defect pixel (leftmost) and the last defect pixel (rightmost) in that row; then, take the midpoint between the leftmost and rightmost points to calculate the midpoint coordinates of that row; each row will have a midpoint, and arrange the midpoint coordinates of all rows in order of row number from top to bottom to form an initial skeleton point sequence; for slender sag defects, the intersection line of each row with the defect region is basically a continuous line segment, and take the midpoint of the line segment as the representative point of that row, and these midpoints strung together approximately constitute the longitudinal center line of the defect).
[0137] A sliding window is applied to the initial skeleton point sequence. For each sliding window, the average coordinates of all initial skeleton points are calculated and used as the position coordinates of the window's center point, forming the central skeleton (i.e., a fixed-size sliding window is set (e.g., the window contains 5 consecutive points); starting from the beginning of the sequence, the window slides sequentially along the sequence. At each position, the average coordinates of all points within the window are taken, and this average value is used to replace the original coordinates of the point in the center of the window; the window slides point by point, replacing each point until the entire sequence is processed; after smoothing, local jitter and burrs in the skeleton point sequence are eliminated, resulting in a smoother central skeleton; since irregular protrusions or depressions may exist at the defect edges, taking the midpoint of each row will cause local wobbling; the sliding window averaging is equivalent to softening the skeleton lines, making them closer to the actual defect direction).
[0138] Extract all initial skeleton points contained in the central skeleton, select the skeleton point with the smallest ordinate value and the smallest abscissa value as the starting point, traverse all initial skeleton points from the starting point, and store all adjacent initial skeleton points in an ordered skeleton sequence in order of ordinate value from smallest to largest and abscissa value from smallest to largest.
[0139] The direction angles of the lines connecting adjacent initial skeleton points are calculated along the ordered skeleton sequence to obtain a local direction angle sequence. The direction angles of the lines with the highest frequency are selected as the true direction (i.e., the direction angles of the lines connecting adjacent initial skeleton points are calculated along the ordered skeleton sequence). The local orientation angle sequence is obtained. The range of values for each direction angle is: Histogram statistics are performed on the local orientation angle sequence, and the size of the angle interval is set to... ,Will The area is evenly divided into 36 intervals, with the specific interval boundaries as follows: The range of each interval: ,in The range of the 36th interval: [85, (Including the right endpoint); Count the frequency of local orientation angles within each interval, select the interval with the highest frequency, and take the median angle of that interval as the true orientation. : ;in, The interval number with the highest frequency; the size of the above intervals is selected. (rather than) The technical basis for (or even smaller granularity) is that the actual direction of sagging defects usually exists between locally adjacent segments. The minute fluctuations (originating from discretization errors in the skeleton point extraction process and the natural curvature of defect edges) are addressed by employing... The statistical interval can effectively filter out the aforementioned local fluctuation noise and avoid excessively fine-grained division (such as...). This causes the true principal direction to be submerged by local random fluctuations; at the same time, The interval granularity corresponds to the full angular range ( Dividing the particle into 36 equal parts, experimental verification showed that the estimation error of the true orientation at this particle size does not exceed [a certain value]. This meets the accuracy requirements for detecting paint sagging defects; simultaneously, the direction angle of the connecting line mentioned above is calculated by sequentially traversing adjacent skeleton point pairs along the ordered skeleton sequence ( For each pair of adjacent points, calculate the direction angle of the line connecting the two points. =arctan(Δy / Δx), where , ;right After performing the above normalization process, the points are mapped to the range of [-90°, 90°] to obtain the local orientation angle between adjacent skeleton point pairs. After all adjacent point pairs have been calculated, a local orientation angle sequence {θ1, θ2, ..., θ3, θ4, θ5, θ6, θ7, θ8, θ9, θ1, θ2, ..., θ1, θ2 ...3, θ4, θ5, θ6, θ7, θ8, θ9, θ1, θ2 Each angle in this sequence has been normalized to match the orientation features in S2451. The domains of definition are completely consistent, ensuring a unified coordinate system benchmark for subsequent histogram frequency statistics.
[0140] Starting from the coordinate position of the starting endpoint, calculate the straight-line distance between adjacent initial skeleton points along the actual direction for the ordered skeleton sequence, and calculate the sum of all straight-line distances as the actual length;
[0141] Based on the actual direction and actual length, a polygonal region of the connected domain of the sag defect is generated (which also determines the location of the sag defect); let the skeleton point sequence be P = p1, p2, ..., pn, the actual direction be θ, and the actual length be L; calculate the average width w of the sag defect (estimated by dividing the area of the non-zero pixels within the target candidate box, Area, by L, i.e., w = Area / L); traverse sequentially along the skeleton sequence, for each skeleton point... Calculate its normal direction =θ + 90°; in Extend each side along the normal direction by a distance of w / 2 to obtain the left boundary point li and the right boundary point ri; connect all left boundary points. Form the left contour line and connect all the right boundary points. This forms the right contour line, which closes at both ends, ultimately generating a closed polygonal region.
[0142] It should be noted that the above steps involve cropping the target candidate box and generating a binary mask to completely separate the defect pixels from the paint background, constructing a pure connected domain for the sagging defect; extracting the midpoints of the defect intervals line by line to stitch together the initial skeleton sequence, quickly outlining the central axis of the defect; using a fixed sliding window to smooth the mean of the skeleton coordinates to eliminate skeleton jitter and burr distortion caused by edge bumps, resulting in a smooth and continuous central skeleton; statistically analyzing the local direction angles of each segment along the ordered skeleton sequence, taking the angle with the highest frequency as the true main direction of the defect, avoiding interference from local minor bends on the overall direction determination; accumulating the distance between adjacent skeleton points to obtain the actual extension length of the defect, and combining the main direction and skeleton coordinates to fit a complete polygonal defect area, which can accurately output the coordinates, overall length, tilt direction, and closed contour of the sagging defect, facilitating subsequent defect size measurement and defect level determination, and significantly improving the contour integrity and quantification accuracy of coating sagging defect detection;
[0143] Example 2
[0144] like Figure 9 As shown, the present invention also provides a target detection system for coating sagging defects with slender shapes, including: a data acquisition module 10, an analysis module 20, and an identification module 30;
[0145] The acquisition module 10 is used to acquire original images of the coating surface, and preprocess the original images to obtain images to be detected.
[0146] The analysis module 20 is used to extract the initial contour of potential flow defects from the image to be detected; slide a window of the initial contour of the flow defects as an initial square window; adjust the side length of the initial square window according to the gray value of the pixels in the initial square window to generate image sub-blocks of multiple sizes; construct a square neighborhood window for each pixel in the image sub-blocks of multiple sizes; extract initial candidate seed points according to the probability of the gray value of the pixels in the square neighborhood window; select the growth starting point of the region for the initial candidate seed points, and grow to obtain a polygonal region;
[0147] The identification module 30 is used to identify the polygonal region as a slender coating drip defect and send the detection result of the slender coating drip defect to the host computer monitoring system.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; those skilled in the art can modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting coating sagging defects in slender shapes, characterized in that, Specific operating methods include: The original image of the coating surface is acquired, and the original image is preprocessed to obtain the image to be detected; The process involves: extracting initial contours of potential flow defects from the image to be detected; creating a sliding window from the initial contours of the flow defects as an initial square window; adjusting the side length of the initial square window based on the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; constructing a square neighborhood window for each pixel in each of the image sub-blocks of multiple sizes; extracting initial candidate seed points based on the probability of the gray values of the pixels within the square neighborhood window; selecting growth starting points for the initial candidate seed points and growing them to obtain polygonal regions. The polygonal region is considered as a slender coating sagging defect, and the detection results of the slender coating sagging defect are sent to the host computer monitoring system.
2. The target detection method for coating sagging defects with slender shapes according to claim 1, characterized in that, The initial contours of potential flow defects are extracted from the image to be detected. The specific operation steps are as follows: For each pixel in the image to be detected, calculate the gradient magnitude and gradient direction; for each pixel, filter the neighboring pixels and calculate the difference in gradient magnitude; if the difference in gradient magnitude is less than or equal to a preset threshold for similar magnitude ratio, then the neighboring pixel is regarded as the connected pixel of the pixel, forming a connected region; For the connected region, determine the x-coordinates of the minimum and maximum values and the y-coordinates of the minimum and maximum values, and further determine the minimum bounding rectangle; calculate the aspect ratio of the length and width based on the minimum bounding rectangle; If the aspect ratio is greater than a preset ratio threshold, the connected region is determined to be the initial outline of a potential sag defect.
3. The target detection method for coating sagging defects with slender shapes according to claim 2, characterized in that, The initial contour sliding window of the sag defect is used as an initial square window; the side length of the initial square window is adjusted according to the gray values of the pixels within the initial square window to generate image sub-blocks of multiple sizes; a square neighborhood window is constructed for each pixel in the image sub-blocks of multiple sizes; initial candidate seed points are extracted according to the probability of the gray values of the pixels within the square neighborhood window. The specific operation steps are as follows: The initial outline of the flow defect in the image to be detected is obtained as the target region. A preset square window is used to slide the target region as the initial square window. The gray value of all pixels in the initial square window is calculated as the window gray value. Calculate the standard deviation of the gray values of all pixels from the mean gray value of the window as the standard deviation of the window gray value; Preset a first grayscale standard deviation threshold and a second grayscale standard deviation threshold; If the standard deviation of the window grayscale is greater than the first grayscale standard deviation threshold, the side length of the initial square window is adjusted and reduced. The grayscale standard deviation of the window is recalculated with the adjusted and reduced initial square window, and the adjustment and reduction operation is repeated until the recalculated grayscale standard deviation of the window is less than or equal to the first grayscale standard deviation threshold. The final adjusted and reduced initial square window is used as the first size sub-block. If the window's grayscale standard deviation is less than the second grayscale standard deviation threshold, the side length of the initial square window is adjusted and enlarged. The grayscale standard deviation of the window is recalculated using the adjusted and enlarged initial square window, and this adjustment and enlargement operation is repeated until the recalculated window grayscale standard deviation is greater than or equal to the second grayscale standard deviation threshold. The finally adjusted and enlarged initial square window is used as the third-size sub-block. If the window's grayscale standard deviation is greater than or equal to the second grayscale standard deviation threshold and less than or equal to the first grayscale standard deviation threshold, the initial square window is used as the second-size sub-block. All adjacent sub-blocks of the same type are merged to obtain multi-size image sub-blocks. Using each pixel within an image sub-block as the center, construct square neighborhood windows corresponding to the size of the image sub-block; count the frequency of grayscale values of each pixel within each square neighborhood window, and calculate the probability of occurrence of each grayscale value within each square neighborhood window, which is used as the probability quality function value of that pixel's grayscale value; calculate the local entropy value of the center pixel within the square neighborhood window based on the probability quality function values of all pixel grayscale values within the square neighborhood window; select the pixel with the minimum local entropy value within the image sub-block as the initial candidate seed point for that image sub-block.
4. The target detection method for coating sagging defects with slender shapes according to claim 3, characterized in that, The initial candidate seed point is selected as the starting point for growth, and the polygon region is obtained through growth. The specific operation steps are as follows: The coordinates and grayscale values of the initial candidate seed points are determined. Adjacent seed point pairs are selected based on these coordinates and grayscale values. The strain compatibility coefficient of the adjacent seed point pairs is calculated based on their grayscale values. The adjacent seed point pairs are then selected into a first candidate set based on the strain compatibility coefficient. The initial candidate seed point with the minimum local entropy value in the first candidate set is used as the starting point for region growth. Growth is performed on adjacent pixels to obtain the target segmentation region. A binary mask is applied to the target segmentation region to select a set of target edge pixels. Polygonal regions are extracted from the target edge pixel set.
5. The target detection method for coating sagging defects with slender shapes according to claim 4, characterized in that, The coordinates and grayscale values of the initial candidate seed points are determined. Adjacent seed point pairs are then selected based on these coordinates and grayscale values. The strain compatibility coefficient between adjacent seed point pairs is calculated based on their grayscale values. The specific steps are as follows: Determine the coordinates and grayscale values of the initial candidate seed points, and calculate the Euclidean distance between two random initial candidate seed points; if the Euclidean distance is less than a preset distance threshold, then the two initial candidate seed points corresponding to the Euclidean distance are regarded as adjacent seed point pairs. The coordinate position and gray value corresponding to the first initial candidate seed point in the adjacent seed point pair are extracted as the first coordinate and the first gray value, and the coordinate position and gray value of the second initial candidate seed point are extracted as the second coordinate and the second gray value; the reciprocal of the Euclidean distance between the first coordinate and the second coordinate is used as the coordinate proximity metric; and the coordinate proximity metric is normalized to become the normalized coordinate proximity metric. Calculate the absolute difference between the first gray value and the second gray value, take the reciprocal of the absolute difference as the gray similarity measure, and normalize the gray similarity measure to obtain the normalized gray similarity measure. The weighted product of the normalized coordinate proximity metric and the normalized grayscale similarity metric is calculated and used as the strain compatibility coefficient of the adjacent seed point pair.
6. The target detection method for coating sagging defects with slender shapes according to claim 5, characterized in that, The adjacent seed point pairs are selected into the first candidate set based on the strain compatibility coefficient; the initial candidate seed point with the minimum local entropy value in the first candidate set is used as the starting point for region growth, and growth is performed on adjacent pixels to obtain the target segmentation region. The specific operation steps are as follows: A preset compatibility screening threshold is set; if the strain compatibility coefficient corresponding to the adjacent seed point pair is greater than the compatibility screening threshold, the adjacent seed point pair is marked to form the first candidate set. Unlabeled adjacent seed point pairs are assigned to the second candidate set; For each initial candidate seed point in the second candidate set, the average strain compatibility coefficient is calculated with that of the initial candidate seed points in the first candidate set. If the average strain compatibility coefficient is greater than the compatibility screening threshold, then the initial candidate seed point of the second candidate set is moved to the first candidate set; The initial candidate seed point with the minimum local entropy value in the first candidate set is selected as the starting point for region growth. The gray-level difference is calculated by traversing adjacent pixels in the adjacent region with the starting point as the center. If the gray-level difference is less than the preset gray-level growth threshold, the adjacent pixel is used as the growth pixel. The growth pixel is used as the new starting point for region growth. The adjacent pixels are traversed again with the new starting point as the center. This process is repeated until the adjacent pixels can no longer be used as the new starting point for region growth, thus forming an independent segmented region. All initial candidate seed points are used to obtain independent segmentation regions, and all independent segmentation regions are merged to obtain the target segmentation region.
7. The target detection method for coating sagging defects with slender shapes according to claim 6, characterized in that, A binary mask is applied to the target segmentation region to filter the target edge pixel set; polygon regions are extracted from the target edge pixel set, and the specific operation steps are as follows: A binarized mask is applied to the target segmentation region to extract corresponding local image patches from the image to be detected. The gradient magnitude and gradient direction of the pixels in the local image patches are calculated, and first-level edge points and second-level edge points are selected to generate a target edge pixel set. The minimum bounding box of the target edge pixel set is extracted, and the morphological and directional features of the minimum bounding box are calculated. The local image patches are input into a pre-trained feature extraction network to output a global statistical feature map. The morphological and directional features are then combined with the global statistical feature map to generate a multi-dimensional feature map. Multiple initial horizontal anchor boxes with different aspect ratios and scales are preset for the multidimensional feature map. The initial horizontal anchor boxes are rotated clockwise to extract target candidate boxes. The target candidate box is cropped from the original image, and the target mask image is extracted; the initial skeleton point sequence is extracted from the non-zero pixels of the target mask image; A sliding window is used to extract an ordered skeleton sequence from the initial skeleton point sequence; the true direction and actual length of the ordered skeleton sequence are calculated to generate a polygonal region.
8. The target detection method for coating sagging defects with slender shapes according to claim 7, characterized in that, A binarized mask is applied to the target segmentation region to extract corresponding local image patches from the image to be detected. The gradient magnitude and direction of each pixel in the local image patch are calculated, and first-level and second-level edge points are selected to generate a target edge pixel set. A minimum bounding box (MBC) is extracted from the target edge pixel set, and morphological and directional features are calculated for the MBC. The local image patch is input into a pre-trained feature extraction network to output a global statistical feature map. The morphological and directional features are then combined with the global statistical feature map to generate a multi-dimensional feature map. The specific operation steps are as follows: A binarized mask is applied to the target segmentation region, and corresponding local image patches are extracted from the image to be detected based on the target segmentation region of the binarized mask. A Sobel operator is used to perform convolution operations on the local image patches, and the gradient components of each pixel in the local image patch are calculated in the horizontal and vertical directions. The gradient magnitude and gradient direction of each pixel are calculated based on the gradient components in the horizontal and vertical directions. If the gradient magnitude of a pixel is greater than the gradient magnitudes of its left and right adjacent pixels, then the pixel is considered an edge candidate point. A high edge threshold and a low edge threshold are preset; if the gradient magnitude of the edge candidate point is greater than the high edge threshold, then the edge candidate point is regarded as a first-level edge point; if the gradient magnitude of the edge candidate point is greater than the low edge threshold and less than the high edge threshold, then the edge candidate point is regarded as a second-level edge point; the first-level edge points and the second-level edge points are used to generate a target edge pixel set; the edge points with minimum and maximum x-coordinates and minimum and maximum y-coordinates in the target edge pixel set are selected to generate a minimum bounding rectangle enclosing the target edge pixel set. Extract the length of the long side and the length of the short side of the minimum circumscribed rotating rectangle, and calculate the length ratio as a shape feature; determine the long side direction vector and the horizontal unit vector based on the length of the long side of the minimum circumscribed rotating rectangle, and calculate the included angle as a direction feature; The local image patch is input into a pre-trained feature extraction network, which outputs a global statistical feature map. The global statistical feature map, morphological features, and orientation features are input into a pre-constructed multimodal feature fusion module, which outputs a multidimensional feature map.
9. The target detection method for coating sagging defects with slender shapes according to claim 8, characterized in that, Multiple initial horizontal anchor boxes with different aspect ratios and scales are preset for the multidimensional feature map. The initial horizontal anchor boxes are rotated clockwise to extract target candidate boxes. The specific operation steps are as follows: For each pixel in the multidimensional feature map, multiple initial horizontal anchor frames with different aspect ratios and scales are preset. Using the center pixel of each initial horizontal anchor frame as the rotation center and the direction feature as the rotation reference angle, each initial horizontal anchor frame is rotated to generate an initial rotated anchor frame, and the tilt angle of each initial rotated anchor frame is calculated. The absolute angle difference between the tilt angle of each initial rotated anchor frame and the direction feature is calculated, and the frames are sorted in descending order. The first k initial rotated anchor frames with the largest absolute angle differences are selected as the candidate anchor frame set. A preset angle range and angle step size are defined; using the center pixel of the candidate anchor frame in the candidate anchor frame set as the rotation center, multiple rotation operations are performed within the angle range of the directional feature according to the angle step size to obtain multiple micro-rotation windows. For each micro-rotation window, the gray-level variance of the internal pixels is calculated, and the micro-rotation window with the minimum gray-level variance is selected as the adaptive selection area corresponding to the candidate anchor box. Calculate the tilt angle of the selected area and the absolute difference between the tilt angle and the directional feature; If the absolute difference is less than the preset angle matching threshold, the adaptive selection area is determined to match the directional feature, and the adaptive selection area is identified as the target candidate box.
10. The target detection method for coating sagging defects with slender shapes according to claim 9, characterized in that, The target candidate box is cropped from the original image, and the target mask image is extracted; an initial skeleton point sequence is extracted from the non-zero pixels of the target mask image; a sliding window is applied to the initial skeleton point sequence to extract an ordered skeleton sequence; the true direction and actual length of the ordered skeleton sequence are calculated to generate a polygonal region. The specific operation steps are as follows: The target candidate box is cropped from the original image and binarized to obtain the target mask image; all non-zero pixels in the target mask image are extracted to construct the flow defect connected component; Scan each row of pixels in the connected domain of the sag defect, record the coordinates of the leftmost and rightmost pixels in each row, and calculate the coordinates of the midpoint of the row; arrange the midpoint coordinates of all rows of pixels to form an initial skeleton point sequence; A sliding window is applied to the initial skeleton point sequence. For each sliding window, the average coordinate of all initial skeleton points is calculated and used as the position coordinate of the window center point to form a central skeleton. All initial skeleton points contained in the central skeleton are extracted, and the skeleton point with the smallest ordinate and the smallest abscissa is selected as the starting endpoint. Starting from the starting endpoint, all initial skeleton points are traversed, and all adjacent initial skeleton points are stored in an ordered skeleton sequence in ascending order of ordinate and abscissa. Calculate the direction angle of the line connecting adjacent initial skeleton points along the ordered skeleton sequence to obtain a local direction angle sequence, and select the direction angle of the line connecting the line with the maximum frequency as the true direction. Starting from the coordinate position of the starting endpoint, calculate the straight-line distance between adjacent initial skeleton points along the actual direction for the ordered skeleton sequence, and calculate the sum of all straight-line distances as the actual length; Based on the actual direction and actual length, a polygonal region of the flow defect connected domain is generated.
