Steel plate gap identification method for improved filtering and adaptive edge detection of hull surface image
The method addresses the challenge of accurately identifying steel plate gaps by combining local weighted Gaussian blur and dynamic bilateral filters with adaptive Canny edge detection, achieving improved noise removal and edge detection precision in complex shipboard environments.
Patent Information
- Application Number
- CN202510401415.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-15
AI Technical Summary
The existing image filtering and edge detection technology is difficult to effectively denoise under complex background and uneven lighting conditions and retain detailed information on the gaps of the hull steel plates, resulting in insufficient gap recognition accuracy.
The local weighted Gaussian fuzzy and dynamic bilateral filtering fusion algorithm are used for denoising, combined with adaptive dynamic threshold Canny edge detection and improved Hough transform, edge extraction is performed through local weighted and dynamic threshold technology to adapt to the feature changes in different regions.
It significantly improves image quality, enhances detail presentation, improves the accuracy of recognition of gap contours, solves the problem of gap edge blur, and improves gap recognition effect.
Smart Images

Figure CN120318184A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and particularly to a method for identifying steel plate gaps by improved filtering and adaptive edge detection for hull surface images. Background Art
[0002] The application of image processing technology in the field of machine vision is becoming increasingly widespread, especially playing a key role in object detection, defect recognition, etc. With the advancement of industrial automation and intelligent manufacturing, the detection of steel plate gaps on the hull surface has become an important part of shipbuilding and maintenance processes. In the case of complex backgrounds and uneven lighting conditions, it is particularly important to improve the processing accuracy of hull surface images, and image filtering and edge detection methods are crucial for improving accuracy in practical applications.
[0003] There are many existing image filtering methods, including histogram equalization, Gaussian filtering, median filtering, and bilateral filtering, etc. Among them, Gaussian filtering is a common denoising method that can effectively smooth images and eliminate noise, but it has limited ability in maintaining detail information and sharpening edges, especially difficult in extracting fine structures and contours. Median filtering can better remove salt-and-pepper noise and effectively retain image edge information, but it has poor processing effects on other types of noise and cannot cope with complex noise environments. Bilateral filtering can better maintain the details of images while removing noise, but its high computational complexity and slow processing speed have certain limitations in practical applications, especially performing poorly in scenarios that require real-time processing.
[0004] In terms of edge detection, traditional edge detection algorithms such as Sobel operator, Canny operator, and Laplacian operator, etc. rely on image gradient information to extract edges. Although these methods can effectively extract edges in the case of less noise and higher image quality, in complex environments, especially with uneven lighting and more noise, they are often easily interfered by noise, resulting in inaccurate edge extraction and affecting the accuracy of subsequent processing. In recent years, many improved algorithms have emerged, such as edge detection methods based on adaptive filtering and multi-scale wavelet transform algorithms, etc. These methods have made significant progress in improving noise sensitivity and enhancing detail retention, but still difficult to completely solve the edge recognition problem under complex conditions on the hull surface.
[0005] To further enhance the accuracy of edge detection, the Hough transform is widely used in line or shape detection. In the task of identifying gaps on the hull surface, it can effectively extract potential geometric shapes and has stronger robustness in environments with complex backgrounds and more noise.
[0006] Currently, how to retain the detailed information of the steel plate gap while reducing noise, and how to accurately extract the edge contour of the gap in a complex environment. Existing filtering and edge detection technologies still face challenges in identifying the steel plate gaps on the hull surface.
[0007] When identifying the images of steel plate gaps on the hull, although existing filtering and gap identification technologies have made certain progress, they still face many challenges. The images on the hull surface are usually affected by complex backgrounds and uneven lighting conditions, which severely restrict the effectiveness of traditional image processing methods. Existing filtering algorithms are difficult to effectively retain the detailed features of the steel plate gaps while removing noise when dealing with images with strong noise interference or large lighting changes, often resulting in inaccurate gap identification or loss of some details.
[0008] Edge detection of steel plate gaps has always been a difficult point in image processing. Although traditional edge detection algorithms can extract basic edge information, in complex backgrounds, especially for the identification of low-contrast and fine gaps, the effect is poor. Existing algorithms mostly rely on global gradient information and are difficult to make adaptive adjustments according to the feature changes in local areas. Therefore, when dealing with changing environmental conditions, the edge detection accuracy decreases, especially when the transition between the steel plate surface and the gap boundary is blurred, the accuracy and robustness further decline.
[0009] Under complex backgrounds and changing lighting conditions, how to effectively improve the denoising effect of steel plate surface images and accurately identify gaps remains a bottleneck in technological development. Existing filtering and edge detection methods have not met the requirements of high-precision steel plate gap identification. Especially when facing complex scenes, more refined and robust algorithms are urgently needed to overcome these technical problems. Summary of the Invention
[0010] Object of the Invention: The present invention aims to solve problems such as noise interference, detail loss, and insufficient gap identification accuracy in the images of the steel plate surface on the hull, and proposes an improved filtering and adaptive edge detection method for steel plate gap identification for the images of the hull surface.
[0011] Technical Solution: An improved filtering and adaptive edge detection method for steel plate gap identification for the images of the hull surface, comprising the following steps:
[0012] Step 1: Use a fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering to denoise the image of the hull surface containing steel plate gaps, obtaining a denoised image of the hull surface;
[0013] Step 2: Use an adaptive dynamic threshold Canny edge detection method to perform edge detection on local regions of the denoised image of the hull surface, obtaining a binary image;
[0014] Step 3: Perform edge extraction on the binary image to obtain the steel plate gap image.
[0015] Further, in Step 1, the method of using the fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering to denoise the hull surface image containing the steel plate gap to obtain the denoised hull surface image includes:
[0016] Use the local weighted Gaussian blur algorithm to denoise the hull surface image containing the steel plate gap to obtain the first denoising result;
[0017] Use the dynamic adjustment bilateral filtering algorithm to denoise the hull surface image containing the steel plate gap to obtain the second denoising result;
[0018] Fuse the first denoising result and the second denoising result according to a set ratio to obtain the denoised hull surface image.
[0019] Further, the method of using the local weighted Gaussian blur algorithm to denoise the hull surface image containing the steel plate gap to obtain the first denoising result, the specific operation includes:
[0020] Divide the hull surface image containing the steel plate gap into n small blocks, and dynamically adjust the size of the Gaussian blur kernel according to the local variance of each small block, expressed as:
[0021]
[0022] In the formula, represents the local variance, expressed as:
[0023]
[0024] In the formula, μ B represents the local mean, x i represents the value of the i-th pixel in the block, and n represents the number of pixels in the block;
[0025] Limit the dynamically adjusted Gaussian blur kernel according to the following formula:
[0026] KernelSize = min(KernelSize, KernelSize_max)
[0027] In the formula, KernelSize_max represents the pre-set maximum value of the Gaussian blur kernel;
[0028] Apply the corresponding Gaussian blur kernel of each size to each small block for denoising;
[0029] Merge the denoised small blocks to obtain the first denoising result.
[0030] Furthermore, the hull surface image containing steel plate gaps is denoised using a dynamic adjustment bilateral filtering algorithm to obtain a second denoising result. The specific operations include:
[0031] Use the Sobel operator to calculate the horizontal gradient of the hull surface image containing steel plate gaps to obtain the horizontal gradient;
[0032] Use the Sobel operator to calculate the vertical gradient of the hull surface image containing steel plate gaps to obtain the vertical gradient;
[0033] According to the horizontal gradient and the vertical gradient, use the following formula to calculate the total gradient amplitude of each pixel point on the hull surface image containing steel plate gaps:
[0034]
[0035] where G x (x,y) and G y (x,y) represent the gradient components in the x and y directions respectively, and are defined by the following formula:
[0036]
[0037] According to the total gradient amplitude of each pixel point, calculate the dynamic spatial domain standard deviation σ space :
[0038] σ space = clip(max(σ space_max - G(x,y)×0.5, σ space_min ), σ space_min, σ space_max )
[0039] where σ space_min and σ space_max are the minimum and maximum values of the spatial domain standard deviation respectively. The role of the clip function is to ensure that the calculated σ space is within the interval [σ space_min, , σ space_max ;
[0040] According to the total gradient amplitude of each pixel point, calculate the dynamic value domain standard deviation σ range :
[0041] σ range = clip(max(σ range_max - G(x,y)×0.5, σ range_min ), σ range_min, σ range_max )
[0042] where σ range_min and σrange_max are respectively the minimum and maximum values of the standard deviation of the value range;
[0043] Dynamically adjust the diameter Diameter of the bilateral filter according to the total gradient magnitude of each pixel:
[0044] Diameter = clip(G(x, y) × 1.5, Diameter_min, Diameter_max)
[0045] where Diameter_min and Diameter_max are respectively the minimum and maximum values of the diameter of the bilateral filter;
[0046] Calculate the spatial domain weight according to the dynamic spatial domain standard deviation σ space , where the spatial domain weight represents the spatial distance weighting of the pixel (x, y) relative to the central pixel (x0, y0):
[0047]
[0048] In the formula, σ space is the spatial domain standard deviation, x0 and y0 represent the coordinates of the central pixel, and x and y represent the pixels in the neighborhood;
[0049] Calculate the value range weight according to the dynamic value range standard deviation σ range :
[0050]
[0051] In the formula, σ range is the value range standard deviation, and I(x, y) represents the hull surface image containing the steel plate gap;
[0052] Filter the hull surface image containing the steel plate gap within the dynamically adjusted diameter Diameter of the bilateral filter according to the following formula to obtain the second denoising result:
[0053]
[0054] where I'(x, y) represents the second denoising result; i and j represent the coordinates of a certain pixel in the filtering window, and the summation symbol represents the weighted summation of all pixels within the window.
[0055] Further, fusing the first denoising result and the second denoising result according to a set ratio to obtain the denoised hull surface image, the specific operation includes:
[0056] Perform weighted average on the first denoising result and the second denoising result according to the following formula:
[0057] I Denoised (x, y) = α × Ibilateral (x, y) + (1 - α) × I Gaussian (x, y)
[0058] Wherein, I Denoised (x, y) represents the fused local region, and I bilateral (x, y) represents the second denoising result, and I Gaussian (x, y) represents the first denoising result, and α represents the weight factor;
[0059] Adopt the CLAHE local contrast enhancement method to process I Denoised (x, y), which is expressed as:
[0060] I CLAHE (x, y) = CLAHE(I Denoised (x, y))
[0061] In the formula, I Denoised (x, y) represents the fused local region processed by the CLAHE local contrast enhancement method;
[0062] Merge the fused local region into the hull surface image containing the steel plate gap to obtain the denoised hull surface image.
[0063] Furthermore, in step 2, the adaptive dynamic threshold Canny edge detection method is used to perform edge detection on the local region of the denoised hull surface image to obtain a binary image. The specific operations include:
[0064] Perform Gaussian smoothing on the denoised hull surface image to obtain the Gaussian-smoothed image;
[0065] Calculate the gradient of the Gaussian-smoothed image to obtain the gradient magnitude and direction;
[0066] Perform non-maximum suppression operation according to the obtained gradient magnitude and direction;
[0067] Calculate the gray mean and gray standard deviation of the image after the non-maximum suppression operation;
[0068] According to the gray mean and gray standard deviation of the image, calculate the low threshold low_threshold and high threshold high_threshold according to the following formula:
[0069] low_threshold = max(10, μ f - 0.5·σ f )
[0070] high_threshold = μ f + 0.5·σ f
[0071] Wherein, μ f represents the average gray value of the image, and σ f represents the standard deviation of gray scale;
[0072] Based on the low threshold low_threshold and the high threshold high_threshold, use the Canny operator to calculate the gradient value of the denoised hull surface image, and obtain a binary image through the calculated gradient value.
[0073] Furthermore, perform morphological operations on the obtained binary image to obtain the final binary image;
[0074] The morphological operations include: sequentially performing dilation operation, opening operation, and erosion operation.
[0075] Furthermore, in step 3, the edge extraction of the binary image to obtain the steel plate gap image specifically includes:
[0076] Divide the binary image into blocks, and calculate the edge intensity of each block; according to the edge intensity of each block, adjust the Hough transform threshold of the block;
[0077] Based on polar coordinate transformation, each straight line in each block is represented in polar coordinates as:
[0078] ρ = x × cosθ + y × sinθ
[0079] where ρ is the distance from the straight line to the origin, and θ is the angle between the straight line and the x-axis;
[0080] Through probabilistic Hough transform, each edge point can correspond to a parameter space of a straight line, calculate the parameters of each straight line in the parameter space, and select the straight line with the highest frequency of occurrence as the straight line segment in the image;
[0081] Judge whether they are close enough by calculating the distance between the endpoints of two line segments, and the judgment condition is:
[0082] distance ≤ d min
[0083] where d min is the set maximum distance;
[0084] Calculate the angular difference between two line segments. If it is less than the preset threshold, it is considered that these two straight lines are similar:
[0085] |θ1 - θ2| ≤ θ max
[0086] If two straight lines meet the above two conditions, merge them into one straight line;
[0087] Finally, the result after block processing and line segment merging is output as a line segment in the global coordinate system;
[0088] Through global coordinate transformation, the local coordinates (x1, y1, x2, y2) of the line segments detected in each block are offset and adjusted according to the position of the block, and converted into the coordinates of the entire image:
[0089]
[0090] where i and j are the offsets of the current block.
[0091] Furthermore, the binary image is blocked, and the edge intensity of each block is calculated; according to the edge intensity of each block, the Hough transform threshold of the block is adjusted, specifically including:
[0092] The binary image is blocked, and the edge intensity of each block is calculated according to the following formula:
[0093]
[0094] where edges(x,y) represents the edge intensity of each pixel;
[0095] Calculate the area of the current block:
[0096] block_area = block_width × block_height
[0097] where block_width is the width of the current block and block_height is the length of the current block;
[0098] According to the edge intensity of each block, calculate the local threshold T of the block local :
[0099]
[0100] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0101] (1) The method of the present invention uses a denoising algorithm that fuses local weighted Gaussian blur and dynamic bilateral filtering, fuses proportionally, efficiently removes the noise in the image, and at the same time adaptively adjusts the filtering parameters to specifically improve the noise impact in the local area, avoid the loss of detail information, and significantly improve the image quality and detail presentation;
[0102] (2) The method of the present invention also proposes an adaptive dynamic threshold Canny edge detection algorithm. By dynamically adjusting the low and high thresholds and the convolution kernel size during the edge extraction process, it accurately detects different edge features of the gaps in the hull steel plates. Finally, through the improved Hough transform, the edge information is further analyzed and processed. By introducing the method of local weighting and dynamic threshold, and through block processing and dynamic threshold adjustment, the gaps in the steel plates are extracted. This algorithm can significantly improve the recognition accuracy of the gap contour and effectively solve the problem of blurred gap edges, enhancing the final gap recognition effect when dealing with complex backgrounds and weak gap edges. BRIEF DESCRIPTION OF THE DRAWINGS
[0103] Figure 1 It is the overall framework diagram of a steel plate gap recognition method for improved filtering and adaptive edge detection of hull surface images;
[0104] Figure 2 It is the schematic diagram of bilateral filtering;
[0105] Figure 3 It is the framework diagram of CLAHE;
[0106] Figure 4 It is the flow chart of the improved adaptive dynamic threshold Canny edge detection;
[0107] Figure 5 It is the flow chart of the Hough transform combining local weighting and dynamic threshold. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0108] The technical solution of this embodiment will be further elaborated below in conjunction with the drawings and embodiments.
[0109] As Figure 1 shown, this embodiment proposes a steel plate gap recognition method for improved filtering and adaptive edge detection of hull surface images, which is mainly divided into: First, overall denoising is performed through the fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering, and fusion is carried out in proportion to achieve more effective denoising while retaining important edges and detail information in the image. Then, the image is subjected to edge extraction of local regions through the adaptive dynamic threshold Canny edge detection method, further improving the image quality and providing a clear input image for the accurate recognition of steel plate gaps. Finally, since there are many non-gap noise points after edge detection, through the improved Hough transform, combined with local weighting and dynamic threshold techniques, the noise points are removed and the steel plate gaps in the image are accurately extracted.
[0110] The algorithm of fusing local weighted Gaussian blur and dynamic bilateral filtering consists of two main steps: local weighted Gaussian blur denoising and dynamic adjustment of bilateral filtering denoising. By combining these two methods, taking advantage of their respective strengths and fusing them proportionally, this algorithm achieves better image denoising effects while maximizing the retention of image details and edge information. Further explanations of the algorithm of fusing local weighted Gaussian blur and dynamic bilateral filtering are given below.
[0111] Local weighted Gaussian blur denoising:
[0112] Gaussian blur is a common image smoothing method that performs weighted averaging on an image based on the Gaussian function. The expression of the Gaussian function is as follows:
[0113]
[0114] Among them, G σ (x, y) represents the two-dimensional Gaussian function, where x and y are the coordinates of pixels in the image, and the standard deviation σ is used to control the smoothing degree of the filtering, controlling the smoothing degree of the Gaussian filter. The larger the value, the stronger the smoothing effect.
[0115] In traditional Gaussian blur, the weights of the filter are globally fixed, which may lead to the loss of details during denoising. To avoid this problem, the concept of local weighting is introduced. In different regions of the image, the size of the blur kernel is dynamically adjusted according to the noise intensity and local variance of the region. Different-sized Gaussian kernels are used for filtering in different local regions.
[0116] The image is divided into n small blocks (windows), and the size of the Gaussian blur kernel is dynamically adjusted according to the local variance of each block.
[0117] The formula for calculating the local mean (μ B ) is as follows:
[0118]
[0119] The local variance is calculated as follows:
[0120]
[0121] Among them, x i is the value of the i-th pixel in the block, and n is the number of pixels in the block.
[0122] Based on the size of the local variance, the size of the blur kernel is dynamically adjusted. In regions with larger variances, it indicates that the texture in this region is complex or the noise is stronger, and a smaller Gaussian kernel is used. While in regions with smaller variances, a larger Gaussian kernel is used to ensure the retention of image details. The size of the blur kernel KernelSize is adjusted through the following formula:
[0123]
[0124] In some cases, the calculated blur kernel may be too large, which will cause the image to be over-smoothed and lose important details. Therefore, it is necessary to limit the size of the blur kernel by setting a maximum blur kernel size KernelSize_max. If the calculated blur kernel size exceeds this maximum value, it will be limited to this value.
[0125] KernelSize = min(KernelSize, KernelSize_max)
[0126] By designing to dynamically adjust the size of the Gaussian kernel to achieve the effect of both denoising and retaining details, local weighted Gaussian blur effectively removes noise while retaining the detail information of larger regions.
[0127] Finally, apply Gaussian blur of the corresponding size to each small block for denoising, and merge each small block processed by Gaussian blur together to obtain the final denoised image.
[0128] Dynamic adjustment of bilateral filtering
[0129] Bilateral filtering is a filtering method that can retain edge information during denoising, taking into account two weighted factors: spatial distance and pixel value difference. Its filtering principle is as Figure 2 shown:
[0130] Bilateral filtering is calculated through the following two weight functions:
[0131] Spatial domain weight:
[0132]
[0133] Here, σ space is the standard deviation in the spatial domain, controlling the weight of neighboring pixels. The greater the weight of neighboring pixels, the greater the influence.
[0134] Range weight:
[0135]
[0136] Among them, σ range is the standard deviation in the range domain, controlling the influence of pixel value differences. Regions with smaller pixel value differences will be given higher weights to maintain the color consistency of the image.
[0137] Bilateral filtering does not directly weight all pixels evenly during denoising. Instead, by considering the similarity between pixels (spatial and pixel values), it only weights the pixels in similar regions, thus effectively preserving the edge information of the image. The specific calculation steps are as follows:
[0138]
[0139] Among them, I'(x, y) is the filtered image.
[0140] Use bilateral filtering with dynamically adjusted parameters to denoise the image. To adapt to the texture complexity of different regions, the parameters of bilateral filtering are dynamically adjusted according to the regional gradient magnitude.
[0141] To measure the texture complexity of the image region, the gradient magnitude is used. By calculating the gradients in the horizontal and vertical directions and combining with the Sobel operator, the gradient components of each pixel point in the image are obtained:
[0142] Calculate the horizontal gradient. Use the Sobel operator to calculate the gradient in the horizontal direction of the image to obtain the gradient value of each pixel point in the image in the horizontal direction, that is:
[0143]
[0144] Calculate the vertical gradient. Use the Sobel operator to calculate the gradient in the vertical direction of the image to obtain the gradient value of each pixel point in the image in the vertical direction, that is:
[0145]
[0146] Through calculation, the obtained gradient information can provide the basic direction of edge changes in the image. However, relying solely on the gradient information in the horizontal and vertical directions cannot comprehensively reflect all edge features in the image. Therefore, further combine the gradients in the horizontal and vertical directions, and use the following formula to calculate the total gradient magnitude of each pixel point:
[0147]
[0148] Among them, G x (x, y) and G y (x, y) respectively represent the gradient components of the image in the x and y directions, which are defined by the following formula:
[0149]
[0150] Through these gradient components, the total gradient magnitude of each pixel point can be calculated to evaluate the texture complexity of the image. The larger the gradient magnitude in the local area, the more complex the texture of the area and the relatively stronger the noise.
[0151] Dynamically adjust two important parameters of bilateral filtering according to the gradient magnitude:
[0152] Calculate the dynamic spatial domain standard deviation (σ space ). Control the similarity of pixels in space, and adopt a similar dynamic adjustment strategy:
[0153] σ space = clip(max(σ space_max - G(x, y)×0.5, σ space_min ), σ space_min, σ space_max )
[0154] where G(x, y) is the gradient magnitude of each pixel point, and σ space_min, and σ space_max are the minimum and maximum values of the spatial domain standard deviation respectively. The role of the clip function is to ensure that the calculated σ space is within the interval [σ space_min, , σ space_max .
[0155] Calculate the dynamic range domain standard deviation (σ range ). It is used to control the similarity of pixel values in bilateral filtering. A smaller standard deviation is used in areas with complex textures, and a larger standard deviation is used in simplified areas to adapt to the noise intensity of different areas:
[0156] σ range = clip(max(σ range_max - G(x, y)×0.5, σ range_min ), σ range_min, σ range_max )
[0157] where σ range_min and σ range_max are the minimum and maximum values of the range domain standard deviation respectively.
[0158] Calculate the diameter of bilateral filtering according to the dynamically adjusted gradient magnitude:
[0159] Diameter = clip(G(x, y)×1.5, Diameter_min, Diameter_max)
[0160] The calculation of the diameter depends on the magnitude of the gradient. A higher gradient magnitude means more complex textures and requires a smaller diameter value, while a lower gradient magnitude requires a larger diameter value to adapt to relatively flat areas.
[0161] Fuse local weighted Gaussian blur and dynamic bilateral filtering: Local weighted Gaussian blur is used to process low-texture regions and strong noise, while dynamic bilateral filtering is used to preserve image edges and details. The fusion step aims to synthesize the outputs of two different denoising methods into a final image, leveraging the advantages of each method. This is achieved through weighted averaging:
[0162] I Denoised (x,y) = α × I bilateral (x,y) + (1 - α) × I Gaussian (x,y)
[0163] where, I Denoised (x,y) represents the image obtained by fusing denoising using local weighted Gaussian blur and dynamic bilateral filtering, I bilateral (x,y) represents the image obtained by denoising using dynamic bilateral filtering, I Gaussian (x,y) represents the image obtained by denoising using local weighted Gaussian blur, and α is a weight factor, usually taking values between 0 and 1. In this algorithm, dynamic bilateral filtering performs better in preserving image details, so α = 0.7 is selected, while the result of local weighted Gaussian blur is used to provide a smoothing effect.
[0164] Through weighted averaging, the fused image can achieve a better balance between preserving details and denoising, making the image clear and the noise effectively removed.
[0165] Finally, the denoised local regions need to be merged into the entire image. After each local region undergoes dynamically adjusted bilateral filtering, a denoised result is obtained.
[0166] In the processing of the denoised image, to enhance the visual effect of the image and improve the detail performance, the CLAHE local contrast enhancement method is introduced. By adaptively adjusting the local contrast of the image, the details in the image become clearer, especially for images with complex textures and different brightness regions, such as the small defects and edges in the hull steel plate image. The CLAHE framework is as Figure 3 shown.
[0167] When performing histogram equalization, the contrast of each small block is limited to avoid noise amplification. For each small block, the enhanced value of its local histogram is calculated, and the maximum contrast enhancement threshold parameter clipLimit is set. The histogram frequency limiting method is as follows:
[0168] h B (v) = min(h B (v), clipLimit)
[0169] where, h B (v) represents the histogram frequency in small block B.
[0170] The processed image I of CLAHE CLAHE (x, y) is as follows:
[0171] I CLAHE (x, y) = CLAHE(I Denoised (x, y))
[0172] Here, I Denoised (x, y) represents the image obtained by fusing denoising using local weighted Gaussian blur and dynamic bilateral filtering, and I Denoised (x, y) represents the image processed by CLAHE.
[0173] By this step, the local contrast of the image is enhanced, making the details and edges in the image more clearly visible. Especially when processing the hull steel plate image with complex textures and different brightness regions, the visual effect is effectively improved, and the loss of details or overexposure caused by global contrast enhancement is avoided.
[0174] After denoising, the edges of the hull surface image are more prominent, especially in structural areas such as welds. Traditional edge detection methods may not be able to handle the changes in details and noise in different images due to fixed threshold settings, and their edges are often difficult to separate from the background. To accurately extract these edges, this algorithm proposes an adaptive dynamic threshold Canny edge detection algorithm, which dynamically adjusts the low threshold and high threshold according to the local statistical characteristics of the image to cope with the changes in noise and details in different images.
[0175] The improved adaptive dynamic threshold Canny edge detection process is as Figure 4 shown.
[0176] The Canny edge detection algorithm aims to detect edges through the gray-scale changes in the image. Its basic steps include:
[0177] (1) Gaussian smoothing
[0178] Gaussian smoothing is the first step in Canny edge detection, aiming to reduce the noise in the image. By using a Gaussian filter to smooth the image, the smoothing operation reduces the high-frequency noise in the image, making the subsequent gradient calculation more accurate.
[0179] The mathematical expression of the Gaussian filter is:
[0180]
[0181] Among them, G σ(x, y) represents a two-dimensional Gaussian function, where x and y are the coordinates of pixels in the image, and the standard deviation σ is used to control the smoothness of the filtering, controlling the smoothness of the Gaussian filter. The larger the value, the stronger the smoothing effect.
[0182] When applying Gaussian filtering, the image is convolved with this Gaussian kernel:
[0183]
[0184] where I(x, y) is the original image, * represents the convolution operation, and I smooth (x, y) is the smoothed image.
[0185] (2) Gradient calculation
[0186] After Gaussian smoothing, the gradient of the image is calculated to identify the edges in the image. The calculation of the gradient is usually done through the Sobel operator, which is used to calculate the horizontal and vertical gradients of the image. The mathematical form of the Sobel operator is as follows:
[0187] Horizontal gradient (G x ):
[0188]
[0189] Vertical gradient (G y ):
[0190]
[0191] These two filters calculate the gray-level changes of the image in the horizontal and vertical directions respectively, obtaining the gradient values of each pixel. The magnitude and direction of the image gradient are calculated through the Sobel operator:
[0192] Gradient magnitude G(x, y):
[0193]
[0194] Gradient direction θ(x, y):
[0195]
[0196] (3) Non-maximum suppression
[0197] After obtaining the gradient magnitude and direction of the image, through non-maximum suppression, the edges are refined and the points with lower gradient values are removed. For each pixel, its gradient value is compared with the gradient values of the two adjacent pixels in that direction according to its gradient direction. If the gradient value of this pixel is not the maximum, it is set to zero.
[0198] (4) Double-threshold edge detection
[0199] Use the double - threshold method to determine strong edges, weak edges, and non - edges, and set two different thresholds T low and T high . If G(x,y) > T high , mark it as a strong edge. Strong edges usually represent significant boundaries in the image and are the core part of the final edge map. If G(x,y) < T low , mark it as a non - edge. Non - edge pixels are considered noise or unimportant regions and should be excluded from the edge map. If T low ≤G(x,y)≤T high , mark it as a weak edge. Weak edges usually lie in the boundary regions of edges, and whether to retain them depends on their connection with strong edges.
[0200] In the traditional Canny algorithm, the low - threshold and high - threshold are pre - set constants, which may perform poorly when dealing with different images, especially when the images have different brightness, contrast, or noise. Therefore, an adaptive dynamic threshold method is adopted to dynamically adjust these two thresholds according to the local gray - level distribution of the image.
[0201] (1) Adaptive dynamic threshold calculation
[0202] The algorithm adopts a scheme of dynamically calculating the low - threshold and high - threshold. By calculating the gray - level mean (μ f ) and standard deviation (σ f ) of the image to estimate the gray - level distribution of the image and determine the brightness distribution and noise intensity of the image.
[0203] Calculate the gray - level mean (μ f )
[0204]
[0205] where f(x i ,y i ) represents the gray - level value of the i - th pixel in the image, and N is the total number of pixels in the image.
[0206] Calculate the gray - level standard deviation (σ f )
[0207]
[0208] where the standard deviation σ f represents the gray - level dispersion degree of the image and reflects the noise level of the image.
[0209] According to the mean and standard deviation of the image gray - level, calculate the adaptive low - threshold and high - threshold
[0210] Calculation of low threshold (low_threshold):
[0211] low_threshold = max(10, μ f - 0.5·σ f )
[0212] Among them, 10 is an empirical value to ensure that the low threshold will not be too low, avoiding excessive noise affecting edge detection.
[0213] Calculation of high threshold (high_threshold):
[0214] high_threshold = μ f + 0.5·σ f
[0215] Among them, the high threshold is usually set to be relatively large to retain important edge information in the image.
[0216] After calculating the adaptive low threshold and high threshold, the Canny operator is used to detect the edges of the image, and the edges are identified by calculating the gradient values of the image (i.e., the degree of gray change).
[0217] Gradient calculation: Use the Sobel operator to calculate the gradients of the image in the horizontal and vertical directions to obtain the gradient magnitude and direction of each pixel:[[]]
[0218]
[0219] Among them, G x (x, y) and G y (x, y) are the gradients of the image in the horizontal and vertical directions respectively.
[0220] Non-maximum suppression: According to the calculated gradient direction, use non-maximum suppression to remove pixels with smaller gradient magnitudes and only retain the strong edge parts.
[0221] Adaptive dynamic double-threshold detection: Use the adaptively calculated low threshold and high threshold to classify the pixels in the image that are less than the low threshold as non-edges, the pixels greater than the high threshold as strong edges, and the pixels between the two are judged based on the strong edge information in their adjacent regions.
[0222] To improve the quality of edge detection, post-process the edges output by the Canny operator to achieve noise removal, edge connection, and edges, etc. Morphological operations are adopted, gradually using dilation, opening operation, and erosion to enhance the coherence of the edges and remove small noises.
[0223] The dilation operation connects the broken edges by expanding the pixels in the edge regions of the image. The mathematical expression of the dilation operation:
[0224]
[0225] Among them, S is the input image (edge image), B is the structuring element, which is used to control the size and shape of dilation, and B z is the translation of the structuring element B at position z.
[0226] The result of the dilation operation is to slide the structuring element B in the image. For each position, the maximum value of the pixels in the structuring element is assigned to the corresponding position, thereby increasing the edge region in the image.
[0227] Morphological opening operation is an operation that first performs erosion and then dilation, mainly used to remove small noise and fine objects in the image. The mathematical expression of morphological opening operation:
[0228]
[0229] Among them, S is the input image and B is the structuring element. represents the erosion operation. represents the dilation operation.
[0230] The function of the opening operation is to first remove small noise through erosion, and then restore the coherence of the edge region through dilation. This operation is very effective for removing small isolated noises and small edge breaks.
[0231] To further remove fine noise, by removing the pixels in the edge region, the noise is further reduced and the edge is refined. The mathematical expression of the erosion operation:
[0232]
[0233] Among them, S is the input image (edge image), B is the structuring element, which is usually smaller than the structuring element of the dilation operation and is used to refine the edge. B z is the translation of the structuring element B at position z.
[0234] The effect of the erosion operation is to "erode" the input image through the size and shape of the structuring element B, removing the unimportant edge parts or noises in the image.
[0235] After edge detection, the edges in the image have been clearly shown. Next is to accurately identify and extract the structural features therein, such as welds or other gaps. To improve the accuracy of line detection, this algorithm further proposes an improved Hough transform method.
[0236] The improved Hough transform method optimizes the edge detection ability of the traditional Hough transform by introducing local weighting and dynamic thresholds. When there are extreme local intensity differences in the image, through block processing and dynamic threshold adjustment, the line detection becomes more accurate, and it can better handle noise and local features of the image. The Hough transform process combining local weighting and dynamic thresholds is as Figure 5 shown.
[0237] Divide the image into multiple small blocks, and perform Hough transform on each small block independently. Reduce the interference factors in the global Hough transform and adapt to the edge features of different regions at the same time.
[0238] Based on the image block processing, calculate an adaptive Hough transform threshold for each local small block. Dynamically calculate the edge intensity of each local block and adjust the threshold accordingly.
[0239] For each local block, calculate the total intensity of the edges in the block. The edge intensity edge_strength can be obtained by calculating the sum of all pixel values in the block. Usually, the edge pixel values in the edge image are higher and the background pixel values are lower.
[0240]
[0241] Among them, edges(x,y) represents the edge intensity of each pixel in the image. Usually, the values of edge pixels are higher and the values of background pixels are lower.
[0242] Calculate the area of the current block:
[0243] block_area = block_width × block_height
[0244] Among them, block_width is the width of the current block, and block_height is the length of the current block.
[0245] According to the edge intensity of each block, calculate the local threshold T local , and compare it with the preset minimum value T low and the maximum value T high to ensure that the threshold is within a reasonable range.
[0246]
[0247] Calculate the adaptive threshold:
[0248] T low = max(T local , T low_min )
[0249] T high = min(Tlocal +δ, T low_max )
[0250] where δ is an offset used to adjust the range of the high threshold, and T low_min and T low_max are respectively the preset local minimum and maximum thresholds to avoid detecting many irrelevant noise points and filtering out the edges that should be detected.
[0251] Within each local block, the probabilistic Hough transform is used. Unlike the classical Hough transform that accumulates calculations for each pixel, only two edge points randomly selected from the edge points extracted from the image are used for calculation, and these two points are used to fit a straight line, significantly improving the calculation efficiency.
[0252] The mathematical basis of the Hough transform is based on polar coordinate transformation, representing the straight lines in the image as points in the parameter space. Each straight line is represented in polar coordinates as:
[0253] ρ = x × cosθ + y × sinθ
[0254] where ρ is the distance from the straight line to the origin, and θ is the angle between the straight line and the x-axis. Through the probabilistic Hough transform, each edge point in the image can correspond to a parameter space of a straight line. During detection, the parameters of each straight line in the parameter space are calculated, and the straight line with the highest frequency of occurrence is selected as the straight line segment in the image.
[0255] To reduce the pseudo straight lines or broken line segments in detection, a strategy of merging adjacent line segments is adopted. By setting the maximum distance and angle difference, the straight lines that are close in space and direction are merged.
[0256] For the judgment of the merging condition, it is judged whether they are close enough by calculating the distance between the endpoints of two line segments. The judgment condition is:
[0257] distance ≤ d min
[0258] where d min is the set maximum distance.
[0259] For the judgment of the angle difference, calculate the angle difference between two line segments. If it is less than the preset threshold, it is considered that these two straight lines are close:
[0260] |θ1 - θ2| ≤ θ max
[0261] If two straight lines meet the above conditions, they are merged into one straight line.
[0262] Finally, the result after block processing and line segment merging will be output as line segments in the global coordinate system. By performing global transformation on the coordinates of the line segments detected in each local block, the global line segments of the corresponding image are obtained.
[0263] Through global coordinate transformation, the local coordinates (x1, y1, x2, y2) of each line segment will be offset and adjusted according to the position of the block, and transformed into the coordinates of the entire image:
[0264]
[0265] where i and j are the offsets of the current block.
[0266] The present invention proposes a method for identifying steel plate gaps by improving filtering and adaptive edge detection, which is specifically aimed at the problem of identifying steel plate gaps in hull surface images. This method mainly performs image processing through three steps. First, a fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering is used to remove noise from the image. By dynamically adjusting the filtering parameters, noise can be effectively removed while retaining important edge information in the image, avoiding the loss of details in traditional denoising methods. Second, an adaptive dynamic threshold Canny edge detection algorithm is used, combined with the gray information of the local area of the image, to achieve adaptive edge detection for different regions. The threshold of edge detection is automatically adjusted according to local features, greatly improving the detection accuracy of steel plate gaps under different backgrounds. In complex backgrounds, the problems of false detection and missed detection are effectively avoided. Finally, the edge information is further analyzed and processed through an improved Hough transform. By introducing the method of local weighting and dynamic threshold, through block processing and dynamic threshold adjustment, the line detection is made more accurate, better coping with noise and local features of the image, and accurately extracting the contour features of the steel plate gaps. This method effectively improves the accuracy of steel plate gap identification and can stably identify fine steel plate gaps in hull surface images.
Claims
1. An improved filtering and adaptive edge detection method for steel plate gap recognition in hull surface images, characterized in that: It includes the following steps: Step 1: Use the fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering to denoise the hull surface image containing steel plate gaps, and obtain the denoised hull surface image; Step 2: Use the adaptive dynamic threshold Canny edge detection method to perform edge detection on the local area of the denoised hull surface image to obtain a binary image; Step 3: Extract the edges of the binary image to obtain the steel plate gap image; In Step 1, the use of the fusion algorithm of local weighted Gaussian blur and dynamic bilateral filtering to denoise the hull surface image containing steel plate gaps and obtain the denoised hull surface image includes: Use the local weighted Gaussian blur algorithm to denoise the hull surface image containing steel plate gaps to obtain the first denoising result; Use the dynamically adjusted bilateral filtering algorithm to denoise the hull surface image containing steel plate gaps to obtain the second denoising result; Fuse the first denoising result and the second denoising result according to a set ratio to obtain the denoised hull surface image; In Step 2, the use of the adaptive dynamic threshold Canny edge detection method to perform edge detection on the local area of the denoised hull surface image and obtain a binary image, the specific operations include: Perform Gaussian smoothing on the denoised hull surface image to obtain the Gaussian-smoothed image; Calculate the gradient of the Gaussian-smoothed image to obtain the gradient magnitude and direction; Perform non-maximum suppression operation according to the obtained gradient magnitude and direction; Calculate the gray mean and gray standard deviation of the image after the non-maximum suppression operation; According to the gray mean and gray standard deviation of the image, calculate the low threshold low_threshold and high threshold high_threshold according to the following formula: low_threshold = max(10, μ f - 0.5·σ f ) high_threshold = μ f + 0.5·σ f where μ f represents the average gray value of the image, and σ f represents the standard deviation of gray values; Based on the low threshold low_threshold and high threshold high_threshold, use the Canny operator to calculate the gradient value of the denoised hull surface image, and obtain a binary image through the calculated gradient value.
2. An identification method for steel plate gaps by improved filtering and adaptive edge detection of hull surface images according to claim 1, characterized in that: The use of the local weighted Gaussian blur algorithm to denoise the hull surface image containing steel plate gaps to obtain the first denoising result, the specific operations include: Divide the hull surface image containing steel plate gaps into n small blocks, and dynamically adjust the size of the Gaussian blur kernel according to the local variance of each small block, expressed as: In the formula, represents the local variance, expressed as: where μ B represents the local mean, x i represents the value of the i-th pixel within the block, and n represents the number of pixels within the block; Limit the dynamically adjusted Gaussian blur kernel according to the following formula: KernelSize = min(KernelSize, KernelSize_max) In the formula, KernelSize_max represents the preset maximum value of the Gaussian blur kernel; Apply the corresponding-sized Gaussian blur kernel to each small block for denoising; Merge the denoised small blocks to obtain the first denoising result.
3. An identification method for steel plate gaps by improved filtering and adaptive edge detection for hull surface images according to claim 1, characterized in that: The use of the dynamically adjusted bilateral filtering algorithm to denoise the hull surface image containing steel plate gaps to obtain the second denoising result, the specific operations include: Use the Sobel operator to calculate the horizontal gradient of the hull surface image containing steel plate gaps in the horizontal direction to obtain the horizontal gradient; Use the Sobel operator to calculate the vertical gradient of the hull surface image containing the steel plate gap, obtaining the vertical gradient; According to the horizontal gradient and the vertical gradient, use the following formula to calculate the total gradient amplitude of each pixel point on the hull surface image containing the steel plate gap: where G x (x, y) and G y (x, y) represent the gradient components in the x and y directions respectively, and are defined by the following formula: Calculate the standard deviation σ of the dynamic spatial domain based on the total gradient magnitude of each pixel space : σ space = clip(max(σ space_max -G(x,y)×0.5, σ space_min ), σ space_min, σ space_max ) Among them, σ space_min and σ space_max are the minimum and maximum values of the standard deviation in the spatial domain respectively. The function of the clip function is to ensure that the calculated σ space is within the interval [σ space_min, , σ space_max ; Calculate the standard deviation σ of the dynamic range according to the total gradient magnitude of each pixel range : σ range = clip(max(σ range_max -G(x,y)×0.5, σ range_min ), σ range_min, σ range_max ) where σ range_min and σ range_max are the minimum and maximum values of the standard deviation of the value range, respectively; According to the total gradient amplitude of each pixel point, dynamically adjust the diameter Diameter of the bilateral filter: Diameter = clip(G(x,y)×1.5, Diameter_min, Diameter_max) where Diameter_min and Diameter_max are the minimum and maximum values of the bilateral filter diameter respectively; According to the dynamic spatial domain standard deviation σ space , calculate the spatial domain weight, where the spatial domain weight represents the spatial distance weighting of the pixel (x, y) relative to the central pixel (x0, y0): where σ space is the standard deviation in the spatial domain, x0 and y0 represent the coordinates of the central pixel, and x and y represent the pixels within the neighborhood; According to the dynamic range standard deviation σ range , calculate the range weight: Where, σ range is the standard deviation of the value range, and I(x, y) represents the hull surface image containing the steel plate gap; Within the dynamically adjusted bilateral filter diameter Diameter, filter the hull surface image containing the steel plate gap according to the following formula to obtain the denoising result two: where I'(x,y) represents the denoising result two; i and j represent the coordinates of a certain pixel within the filter window, and the summation symbol represents weighted summation of all pixels within the window.
4. An identification method for steel plate gaps with improved filtering and adaptive edge detection for hull surface images according to claim 1, characterized in that: The above-mentioned fusing the denoising result one and the denoising result two in a set ratio to obtain the denoised hull surface image, the specific operations include: Perform weighted averaging of the denoising result one and the denoising result two according to the following formula: I Denoised (x,y) = α × I bilateral (x,y0 + (1 - α) × I Gaussian (x,y) Among them, I Denoised (x, y) represents the fused local region, and I bilateral (x, y) represents the second denoising result, and I Gaussian (x, y) represents the first denoising result, and α represents the weight factor; Using the CLAHE local contrast enhancement method, process I Denoised (x, y), which is expressed as: I CLAHE (x,y) = CLAHE(I Denoised (x,y)) where I Denoised (x, y) represents the fused local region processed by the CLAHE local contrast enhancement method; Merge the fused local area into the hull surface image containing the steel plate gap to obtain the denoised hull surface image.
5. An identification method for steel plate gaps by improved filtering and adaptive edge detection of hull surface images according to claim 1, characterized in that: Perform morphological operations on the obtained binary image to obtain the final binary image; The morphological operations include: sequentially performing dilation operation, opening operation, and erosion operation.
6. An identification method for steel plate gaps with improved filtering and adaptive edge detection for hull surface images according to claim 1, characterized in that: In step 3, the above-mentioned edge extraction of the binary image to obtain the steel plate gap image, the specific operations include: Divide the binary image into blocks, calculate the edge strength of each block; according to the edge strength of each block, adjust the Hough transform threshold of this block; Based on polar coordinate transformation, each straight line in each block is represented in polar coordinates as: ρ = x×cosθ + y×sinθ where ρ is the distance from the straight line to the origin, and θ is the angle between the straight line and the x-axis; Through probabilistic Hough transform, each edge point can correspond to a parameter space of a straight line, calculate the parameters of each straight line in the parameter space, and select the straight line with the highest occurrence frequency as the straight line segment in the image; Judge whether they are close enough by calculating the distance between the endpoints of two line segments, and the judgment condition: distance≤d min where d min is the set maximum distance; Calculate the angle difference between two line segments, if it is less than the preset threshold, then consider these two straight lines to be similar: |θ1 - θ2| ≤ θ max If two straight lines meet the above two conditions, merge them into one straight line; Finally, the result after block processing and line segment merging is output as a straight line segment in the global coordinate system; Through global coordinate transformation, the local coordinates (x1, y1, x2, y2) of the line segments detected in each block are offset and adjusted according to the position of the block to be transformed into the full-image coordinates: where i and j are the offsets of the current block.
7. An identification method for steel plate gaps by improved filtering and adaptive edge detection for hull surface images according to claim 6, characterized in that: The above-mentioned dividing the binary image into blocks, calculating the edge strength of each block; according to the edge strength of each block, adjusting the Hough transform threshold of this block, specifically includes: Divide the binary image into blocks, and calculate the edge strength of each block according to the following formula: Among them, edges(x, y) represents the edge intensity of each pixel; Calculate the area of the current block: block_area = block_width × block_height where block_width is the width of the current block and block_height is the length of the current block; Calculate the local threshold T of each block based on the edge strength of the block local :
Citation Information
Cited By
Laminating flatness detection method for plastic floor
CN120852361A
Ship water gauge scale denoising algorithm
CN121458573A
SAR image filtering method based on structural strength joint consistency
CN121788360A
Rapid detection method for surface quality of automobile seat
CN122134697A