Steel pipe crack detection system based on image enhancement

Through image smoothing, weight and detail calculation, image fusion and contrast optimization, weighted crack details are generated, which solves the problem of accurate identification of steel pipe crack detection in complex backgrounds in existing technologies and improves the reliability and accuracy of detection.

CN120689307AInactive Publication Date: 2025-09-23JIANGXI HONGRUIMA STEEL PIPE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510782304.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-09-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies have difficulty in accurately distinguishing cracks on the surface of steel pipes from background noise under complex backgrounds, resulting in missed detections or false detections. Existing overall enhancement methods have difficulty in highlighting crack features.

Method used

Through image smoothing, weight and detail calculation, image fusion and contrast optimization, weighted crack details are generated and target intensity mapping rules are constructed to enhance the local targeting and visibility of crack features.

Benefits of technology

The reliability and accuracy of steel pipe crack detection are improved, the false recognition rate is reduced, and the detection stability in complex backgrounds and different lighting conditions is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120689307A_ABST
    Figure CN120689307A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image enhancement, in particular to a steel pipe crack detection system based on image enhancement, which comprises an image smoothing processing module, an original steel pipe surface image reading intensity values of all pixels and tissue intensity values to form an original pixel set, setting a guide filter based on the original pixel set, and carrying out image enhancement on the original steel pipe surface image; and filtering the original pixel set as a guide image and an input image at the same time to obtain a smooth basic image. According to the method, the intensity information of all the pixels is extracted from the original steel pipe surface image, and the pixel intensity value is taken as the guide image to be synchronously filtered with the input image, so that the background interference in the image can be reduced, and the smooth basic image with clear details can be obtained; and then taking the standard deviation of each pixel neighborhood as a key feature, generating a weight factor in a targeted manner, enhancing the expression of crack detail features in a local differentiation manner, and highlighting the difference between a crack region and a background region.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image enhancement, and in particular to a steel pipe crack detection system based on image enhancement. Background Art

[0002] The field of image enhancement technology mainly involves improving and optimizing image quality to enhance the clarity and visibility of targets or details in the image, making it easier for human eyes to recognize or computers to automatically analyze.

[0003] In practical applications, existing technologies focus on overall image clarity and visibility, but lack local specificity when performing global image enhancement. This makes it difficult to accurately distinguish subtle defects like cracks from background noise, especially in complex industrial environments. This can cause crack features to become blurred or masked by background details, leading to missed or false detections. For example, when a steel pipe surface has uneven lighting, rust, or other complex textures, existing global enhancement methods struggle to fully highlight local crack features. While image quality may improve, crack features remain difficult to effectively identify and extract. Therefore, improvements are needed. Summary of the Invention

[0004] The purpose of the present invention is to solve the shortcomings of the prior art and propose a steel pipe crack detection system based on image enhancement.

[0005] In order to achieve the above objectives, the present invention adopts the following technical solutions: A steel pipe crack detection system based on image enhancement includes:

[0006] An image smoothing processing module reads the intensity values ​​of all pixels from the original steel pipe surface image, organizes the intensity values ​​into an original pixel set, sets a guided filter based on the original pixel set, and filters the original pixel set as a guided image together with the input image to obtain a smoothed basic image;

[0007] The weight and detail calculation module reads all pixel values ​​of the original steel pipe surface image, calculates the standard deviation within the neighborhood of each pixel point, obtains a local standard deviation value, obtains a detail weight based on the local standard deviation value, subtracts the corresponding pixel value of the smoothed basic image from the pixel value of the original steel pipe surface image to obtain the original detail, and applies the detail weight to the original detail to generate a weighted crack detail;

[0008] An image fusion construction module is configured to fuse the weighted crack details with the smoothed base image to obtain preliminary fused pixel data, and based on the preliminary fused pixel data, traverse each pixel to calculate the standard deviation distribution of the fused image;

[0009] The contrast optimization output module analyzes the standard deviation value of each position in the standard deviation distribution of the fused image, determines the stretching transformation amplitude according to the standard deviation value, forms a target intensity mapping rule, and outputs an optimized contrast steel pipe image based on the target intensity mapping rule.

[0010] Preferably, the step of obtaining the smoothed basic image is:

[0011] Read the intensity values ​​of all pixels one by one from the original steel pipe surface image, extract the intensity values ​​corresponding to each pixel one by one and organize them into an original pixel set to obtain an original pixel set;

[0012] Based on the original pixel set, by analyzing the spatial distribution characteristics and local variation trends of the intensity values ​​of each pixel in the original pixel set, setting the radius parameter and the regularization coefficient of the guided filter to obtain a filter parameter set;

[0013] Based on the filter parameter set, the original pixel set is used as a guide image and an input image at the same time, and pixel intensity value filtering in the spatial domain is performed on the original pixel set to obtain a smooth basic image.

[0014] Preferably, the steps for obtaining the local standard deviation value are:

[0015] All pixel values ​​are read from the original steel pipe surface image, and the position of each pixel in the image coordinate system and its corresponding pixel intensity value are paired and sorted to form a set of original pixel positions and intensity values, thereby obtaining a set of original pixel positions and intensity values;

[0016] Based on the original pixel position and intensity value set, a fixed-size neighborhood window is defined according to the coordinate position of each pixel point in the image and the intensity values ​​of all pixels in the window are extracted. The discrete degree of the pixel intensity value in the neighborhood window is calculated to obtain the intensity distribution within the neighborhood range of each pixel point.

[0017] Based on the intensity distribution within the neighborhood of each pixel, the standard deviation is calculated point by point to obtain the local standard deviation value.

[0018] Preferably, the steps of obtaining the weighted crack details are:

[0019] Based on the local standard deviation value, the intensity values ​​of all pixel positions in the original steel pipe surface image and the intensity values ​​of the smoothed basic image at the corresponding positions are extracted, the intensity difference of each pixel is calculated and combined with the gradient amplitude of the corresponding pixel to obtain a gradient modulation difference set;

[0020] According to the gradient modulation difference set, the maximum absolute value of the gradient modulation difference of all pixels is counted as a normalization factor, and a detail weight value is calculated for each pixel;

[0021] Based on the detail weight value, the intensity difference of each pixel of the original steel pipe surface image is multiplied by the detail weight value of the corresponding position, and all calculation results are superimposed pixel by pixel to construct a brightness expression of the crack feature to generate weighted crack details.

[0022] Preferably, the steps of obtaining the preliminary fused pixel data are:

[0023] Calling the pixel intensity value of each pixel position in the weighted crack detail and synchronously calling the pixel intensity value of the corresponding position in the smoothed basic image, using the pixel position as an index, pairing and combining them one by one to form a pixel intensity value comparison set, thereby obtaining a pixel intensity value comparison set;

[0024] Based on the pixel intensity value comparison set, linear superposition and fusion of intensity values ​​are performed pixel by pixel, and the pixel intensity values ​​of the weighted crack details and the smoothed basic image at each pixel position are superimposed in a fixed ratio to obtain a fused pixel intensity initial value set;

[0025] Based on the fused initial pixel intensity value set, each pixel position is traversed in sequence, the initial pixel intensity values ​​are organized according to the spatial order of the image, and are recombined to form a complete image data matrix to obtain preliminary fused pixel data.

[0026] Preferably, the steps for obtaining the standard deviation distribution of the fused image are:

[0027] Based on the preliminary fused pixel data, traverse each pixel position, extract the intensity value of each pixel position, and calculate the pixel intensity fluctuation within the local neighborhood to obtain a basic data set of local intensity distribution;

[0028] Calculating the standard deviation value within the local area pixel by pixel based on the basic data set of the local intensity distribution to generate a standard deviation value set corresponding to each pixel position;

[0029] Based on the standard deviation value set, all pixel positions in the image are traversed in sequence, and the standard deviation value of each pixel is sorted and summarized to form a standard deviation distribution of the fused image.

[0030] Preferably, the steps of obtaining the target intensity mapping rule are:

[0031] Based on the standard deviation distribution of the fused image, a set of local standard deviation values ​​of all pixels is collected, and the standard deviation value of each pixel position is extracted to obtain a complete set of standard deviation values;

[0032] Calculating a stretch transformation amplitude for each pixel position based on the complete set of standard deviation values;

[0033] Based on the stretch transformation amplitude, a target intensity mapping rule is obtained.

[0034] Preferably, the steps for obtaining the contrast-optimized steel pipe image are:

[0035] Based on the target intensity mapping rule, adjusting the intensity value of each pixel position according to the transformation amplitude defined in the target intensity mapping rule to obtain an updated pixel intensity data set;

[0036] According to the updated pixel intensity data set, traverse each pixel position and adjust the intensity value to obtain a pixel value set with optimized contrast;

[0037] Based on the contrast-optimized pixel value set, the intensity value of each pixel point is reorganized according to the image position and synthesized into complete image data, and the contrast-optimized steel pipe image is output.

[0038] Compared with the prior art, the advantages and positive effects of the present invention are:

[0039] In the present invention, by extracting the intensity information of all pixels from the original steel pipe surface image, and using the pixel intensity value as a guide image to perform filtering processing synchronously with the input image, the background interference in the image can be reduced, and a smooth and detailed basic image can be obtained; then the standard deviation of each pixel neighborhood is used as the key feature, and a weight factor is generated in a targeted manner to enhance the expression of crack detail features in a local differentiated manner, highlighting the difference between the crack area and the background area; further based on the fusion calculation of pixel data and the standard deviation distribution analysis, a target intensity mapping rule is constructed, and the pixel intensity is adjusted by stretching transformation to improve the overall contrast and visual effect of the steel pipe image, make the crack features more prominent, reduce the false recognition rate, and improve the reliability and accuracy of the detection results. At the same time, it also enhances the detection stability and robustness under complex backgrounds and different lighting conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a system flow chart of the present invention. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0042] See also Figure 1 The present invention provides a technical solution: a steel pipe crack detection system based on image enhancement includes:

[0043] The image smoothing processing module reads the intensity values ​​of all pixels from the original steel pipe surface image, organizes the intensity values ​​into the original pixel set, sets the guided filter based on the original pixel set, and uses the original pixel set as the guided image and the input image for filtering to obtain a smoothed basic image;

[0044] The weight and detail calculation module reads all pixel values ​​of the original steel pipe surface image, calculates the standard deviation within the neighborhood of each pixel point, obtains the local standard deviation value, obtains the detail weight based on the local standard deviation value, subtracts the corresponding pixel value of the smoothed base image from the pixel value of the original steel pipe surface image to obtain the original detail, and applies the detail weight to the original detail to generate weighted crack details;

[0045] The image fusion construction module fuses the weighted crack details with the smoothed base image to obtain preliminary fused pixel data. Based on the preliminary fused pixel data, each pixel is traversed to calculate the standard deviation distribution of the fused image.

[0046] The contrast optimization output module analyzes the standard deviation value of each position in the standard deviation distribution of the fused image, determines the stretching transformation amplitude according to the standard deviation value, forms the target intensity mapping rule, and outputs the contrast-optimized steel pipe image based on the target intensity mapping rule.

[0047] The steps to obtain the smoothed base image are:

[0048] Read the intensity values ​​of all pixels one by one from the original steel pipe surface image, extract the intensity values ​​corresponding to each pixel one by one and organize them into an original pixel set to obtain an original pixel set;

[0049] Based on the original pixel set, by analyzing the spatial distribution characteristics and local variation trends of the intensity values ​​of each pixel in the original pixel set, the radius parameter and regularization coefficient of the guided filter are set to obtain the filter parameter set;

[0050] Based on the filter parameter set, the original pixel set is used as the guide image and the input image at the same time, and the pixel intensity value of the original pixel set is filtered in the spatial domain to obtain a smooth basic image.

[0051] Specifically, from the original steel pipe surface image data, the image data is usually a two-dimensional matrix, in which each element represents a pixel at the corresponding spatial position, and its value is the intensity value of the pixel. For example, for an 8-bit grayscale image with a width of W and a height of H, its intensity value range is 0 to 255. These intensity values ​​are read sequentially pixel by pixel, for example, starting from the first pixel in the upper left corner of the image, all pixels are traversed in a row-first or column-first manner until the last pixel in the lower right corner. For each accessed pixel, its specific intensity value is extracted, and these intensity values ​​are collected to form a one-dimensional array or list. This array or list is the original pixel set, and its length is equal to W multiplied by H. It completely contains the original brightness information of all pixels in the image, thereby obtaining the original pixel set.

[0052] Based on the original pixel set obtained in the previous steps, the pixel intensity values ​​in the set are statistically analyzed. First, the average intensity value and intensity standard deviation of the entire original pixel set are calculated to grasp the overall brightness distribution and contrast. For example, if the average intensity value is 120 and the global standard deviation is 50, it means that the overall brightness of the image is moderate but there is a certain contrast. Then, in order to understand the local change trend, the original pixel set is remapped back to its two-dimensional spatial structure, and for each pixel, a neighborhood window is defined, such as a 5x5 pixel window. The average and standard deviation of the pixel intensity in the window are calculated to obtain the local average intensity and local standard deviation of each pixel. By comparing the local standard deviation with the global standard deviation and analyzing the distribution of the local standard deviation, the complex texture areas and smooth areas in the image are identified. For example, areas where the local standard deviation is significantly higher than the global standard deviation may indicate the presence of cracks or noise. The radius parameter of the guide filter is set according to the detail scale you want to smooth. If you want to smooth out texture or noise whose size is less than or equal to a specific value, for example, by analyzing the distribution of local standard deviations, it is found that the average size of noise or irrelevant textures corresponds to a width of approximately 3 to 5 pixels. In this case, the radius parameter can be set to 3. The radius parameter determines the neighborhood size considered by the filter when calculating the local linear model. The setting of the regularization coefficient depends on the requirements for edge preservation and the noise level of the image. For example, first estimate the average noise variance of the image. You can select several recognized smooth areas in the image, calculate the variance of the pixel intensities in these areas, and take their average as the estimated value of the noise variance. For example, if the estimated average noise variance is 25.0 (the square of the intensity unit), the regularization coefficient can be set to the noise variance value, that is, 25.0. Or, based on experience, for images with an intensity range of 0 to 255, an initial regularization coefficient can be set to a small proportion of the maximum possible variance of the image, such as 0.01×(255-0) 2≈6.5, but it is more adaptive based on noise estimation. Setting a higher regularization coefficient will make the image smoother, but may blur details. A lower one will retain more details but may also retain noise. The radius parameter and regularization coefficient calculated in this way are organized together to obtain a set of filter parameters.

[0053] Based on the previously determined filter parameter set including the radius parameter and the regularization coefficient, and the original pixel set as the processing object, the original pixel set here acts as both a guide image and an input image, which means that the filtering process will use the structural information of the image itself to guide the smoothing operation. For each pixel point in the original pixel set, the mean and variance of the pixel intensity in the local neighborhood window determined by the radius parameter are calculated, and these local statistics and the regularization coefficient are used to calculate the linear transformation coefficient a of the guide filter. k and b k , which is calculated specifically as follows: for the window ω centered at pixel k k , coefficient a k By formula Calculate, where It is in the window k The variance of the pixel intensity corresponding to the original pixel set is the regularization coefficient obtained from the filter parameter set, and the coefficient b k Then through b k =μ k -a k μ k Calculate, where μ k It is in the window k The mean value of the pixel intensity corresponding to the original pixel set in the local window ω is ω, because each pixel i may be contained in multiple different local windows ω. k Therefore, the final filtered output value q i is calculated by all windows covering pixel i k P i +b k (In this particular application, the guide image P i Same as the input image, that is, the pixel I in the original pixel set i , so it is a k I i +b k ) is averaged, that is, for each pixel i, its output value , where |ω i | is the number of windows that contain pixel i, or more precisely, the output value q i Calculated as in and By traversing all pixels in the original pixel set and applying this filter calculation, the resulting new set of pixel intensities constitutes the smoothed base image.

[0054] The steps to obtain the local standard deviation value are:

[0055] All pixel values ​​are read from the original steel pipe surface image, and the position of each pixel in the image coordinate system and its corresponding pixel intensity value are paired and sorted to form a set of original pixel positions and intensity values, thereby obtaining a set of original pixel positions and intensity values;

[0056] Based on the original pixel position and intensity value set, a fixed-size neighborhood window is defined according to the coordinate position of each pixel point in the image and the intensity values ​​of all pixels in the window are extracted. The discrete degree of the pixel intensity value in the neighborhood window is calculated to obtain the intensity distribution within the neighborhood range of each pixel point.

[0057] Based on the intensity distribution within the neighborhood of each pixel, the standard deviation is calculated point by point to obtain the local standard deviation value.

[0058] Specifically, from the original steel pipe surface image, the image is regarded as a two-dimensional grid composed of pixels, where each pixel has a specific position in the image coordinate system, usually expressed as an (x, y) pair, where x represents the column index in the horizontal direction and y represents the row index in the vertical direction. At the same time, each pixel is also associated with a pixel intensity value, that is, the brightness information of the point. For example, in a grayscale image with a width of W and a height of H, the value of x ranges from 0 to W-1, and the value of y ranges from 0 to H-1. The pixel intensity value may be between 0 and 255. Systematically traverse each pixel in the image, for example, using a scanning order from top to bottom and from left to right, and read its coordinates (x i ,y i ) and the corresponding pixel intensity value I i , each pair of such position information and intensity information is combined into a data unit, such as a structure or tuple containing a coordinate pair and an intensity value, such as ((x i ,y i ),I i ), and collect and organize such data units of all pixels to form a set. Each element in the set uniquely identifies a pixel and its brightness. This set is the original pixel position and intensity value set, which completely records the spatial position of each pixel in the image and its corresponding light intensity information, and obtains the original pixel position and intensity value set.

[0059] Based on the original pixel position and intensity value set obtained in the previous step, for each pixel in the set, the position information in the image coordinate system recorded by it is used, such as the pixel point P c Located at coordinate (xc ,y c ), a fixed-size neighborhood window is delineated around it. The size of the neighborhood window is a preset constant, for example, a square area of ​​5x5 pixels. The selection of the 5x5 window size is based on the consideration of the surface texture of the typical steel pipe and the size of the potential crack features. The size needs to be balanced between being able to capture enough local information to reflect the texture changes and not being too large to blur small features or cross the boundaries of different regions. For example, a 3x3 window may be too sensitive to isolated noise points, while a 9x9 window may smooth out the details of small cracks. For the current center pixel (x c ,y c ), whose 5x5 neighborhood window will cover the coordinates (x c -2,y c -2) to (x c +2,y c +2), when extracting the intensity values ​​of all pixels in the window, it is necessary to deal with the image boundary situation, that is, when the neighborhood window part exceeds the actual boundary of the image, the strategy of copying the boundary pixels is adopted, that is, if a coordinate (x w ,y w ) exceeds the image range (e.g. x w <0 or x w ≥W or y w <0 or y w ≥H, where W and H are the width and height of the image respectively), the pixel intensity value at this coordinate is set to the distance (x w ,y w ) the intensity value of the nearest valid pixel, collect the intensity values ​​of all 25 pixels (after boundary processing) in this 5x5 neighborhood window, and form a one-dimensional list or array containing 25 intensity values. This list or array is the center pixel (x c ,y c ) is used to obtain the intensity distribution within the neighborhood corresponding to each pixel point. This operation is performed for each pixel point in the original pixel position and intensity value set, so that the intensity distribution within the neighborhood corresponding to each pixel point is obtained for each pixel point.

[0060] Based on the intensity distribution within the neighborhood of each pixel point generated in the above steps, the intensity distribution here specifically refers to the set of intensity values ​​of all pixels in a fixed-size neighborhood around each pixel point (for example, the aforementioned 5x5 neighborhood). For each pixel point, its corresponding intensity distribution data is processed independently to calculate the local standard deviation of the central pixel point. The calculation process first calculates the arithmetic mean of the intensity value set in the neighborhood (for example, a list of 25 intensity values). Then, for each intensity value in the neighborhood, the difference between it and the arithmetic mean just obtained is calculated, and this difference is squared to obtain the square difference. Then, The squared differences of all pixels in the neighborhood are accumulated and then divided by the total number of pixels in the neighborhood (for example, for a 5x5 neighborhood, the total number is 25) or the total number minus one (if an unbiased estimate of the sample standard deviation is used) to obtain the variance of the pixel intensities in the neighborhood. Finally, the arithmetic square root of the variance is taken, and the result is the local standard deviation value of the central pixel. This calculation process is repeated for all pixels in the image, and each pixel will obtain a corresponding local standard deviation value. These values ​​together constitute a local standard deviation map of the same size as the original image, where the value at each position reflects the degree of intensity change in the neighborhood of the corresponding position in the original image, and the local standard deviation value is obtained.

[0061] The steps to obtain weighted crack details are:

[0062] Based on the local standard deviation value, the intensity values ​​of all pixel positions in the original steel pipe surface image and the intensity values ​​of the smoothed basic image at the corresponding positions are extracted. The intensity difference of each pixel is calculated and combined with the gradient amplitude of the corresponding pixel to obtain the gradient modulation difference set;

[0063] According to the gradient modulation difference set, the maximum absolute value of the gradient modulation difference of all pixels is counted as the normalization factor, and the detail weight value is calculated for each pixel. The calculation formula is:

[0064]

[0065] Among them, W d Represents the detail weight value of the d-th pixel position, R d represents the intensity value of the dth pixel of the original steel pipe surface image, S d Represents the intensity value of the dth pixel of the smoothed base image, G d Represents the gradient magnitude of the dth pixel in the image, L d Indicates the value of the d-th pixel in the local standard deviation normalization result, L max Represents the maximum value of the local standard deviation normalized value in the entire image, N factor Represents the maximum absolute value of the gradient modulation difference of all pixels, in units of I2 / X;

[0066] Based on the detail weight value, the intensity difference of each pixel in the original steel pipe surface image is multiplied by the detail weight value of the corresponding position. All calculation results are superimposed pixel by pixel to construct the brightness expression of the crack feature and generate weighted crack details.

[0067] Specifically, based on the local standard deviation value of each pixel point calculated in the previous step, and combined with the original steel pipe surface image and the smoothed basic image, first, for each pixel position in the original steel pipe surface image, its original intensity value is extracted. The original intensity value is directly read from the digital image data representing the steel pipe surface obtained by the image acquisition device. For example, for pixel point d, its intensity value in the original steel pipe surface image is R d At the same time, in the smoothed basic image generated in the previous step, the smoothed intensity value corresponding to the same pixel position in the original steel pipe surface image is extracted and expressed as S d , then calculate the difference between these two intensity values, namely D d =R d -S d , this difference D d It reflects the detail information of the original image that is removed or weakened during the smoothing process. Subsequently, in order to quantify the edge strength at each pixel, it is necessary to calculate the gradient amplitude G of the corresponding pixel in the original steel pipe surface image. d This is usually done by applying a standard gradient operator, such as the Sobel operator, which is to apply the Sobel convolution kernel in the horizontal and vertical directions in the 3×3 neighborhood of each pixel point d, for example, the horizontal kernel and vertical core Perform convolution operation with the pixel intensity value in the neighborhood to obtain the horizontal gradient component G xd and the vertical gradient component G yd , and then calculate Get the gradient amplitude of the point, and finally, the intensity difference D calculated previously d and the gradient magnitude G at that point d Perform pixel-by-pixel multiplication, that is, calculate GM d =D d ·G d , this product GM d It is called gradient modulation difference because it uses gradient information to modulate the intensity difference, emphasizing those areas with significant intensity differences and strong edge features. The gradient modulation difference GM calculated from all pixel positions is d Collectively, they form a gradient modulation difference set.

[0068] formula: The benefit of the formula is that it can adaptively calculate a detail weight for each pixel in the image, which takes into account the original detail intensity, edge saliency and texture complexity of the pixel in the local area. d -S d )·G d |Magnified with high intensity difference (R d -S d Represents the difference between the original image and the smoothed image, that is, the details) and high gradient (G d represents the edge strength), which is usually a feature of defects such as cracks, divided by the normalization factor N factor Make the item have a relatively consistent scale, the denominator The suppression of local texture complexity is introduced, L d Represents the local standard deviation. Its value is larger in areas with rich texture or more noise. This item can reduce the weight of these non-crack areas to avoid misjudging texture as crack. The square operation enhances this suppression effect, and adding 1 ensures that the denominator is non-zero and greater than or equal to 1. The final square root operation adjusts the dynamic range of the weight, making the weight distribution smoother.

[0069] R d The parameter acquisition step is as follows: it represents the intensity value of the dth pixel in the original steel pipe surface image. This value is the result of the sensor recording the light energy corresponding to the physical space point d under specific exposure and lighting conditions when the image acquisition directly shoots the steel pipe surface and converting it into a digital signal. For an 8-bit grayscale image, the range of this intensity value is usually 0 to 255, where 0 represents pure black and 255 represents pure white. In the processing flow, this value is directly read from the file or memory storing the original image data. For example, for the pixel point d at the image coordinate (125, 240), its R d The value can be 192;

[0070] S d The step of obtaining the parameter is as follows: it represents the intensity value of the d-th pixel in the smoothed base image. The smoothed base image is the image obtained by applying the guided filter to the original steel pipe surface image in the previous step of this application. The filtering process is designed to remove noise and irrelevant subtle textures in the original image while retaining the main edge structure. Therefore, S d is the original intensity value R d The intensity value of the corresponding position calculated by a specific smoothing algorithm (such as guided filtering) is also directly read from the generated smoothed basic image data. For example, for the above R d The pixel point d with the same coordinates (125, 240) is in the smoothed base image Sd The value is 185;

[0071] G d The parameter acquisition steps are as follows: , which represents the gradient amplitude of the dth pixel in the image. This value is calculated by applying the gradient operator to the original steel pipe surface image. Taking the Sobel operator as an example, first define the 3×3 convolution kernels in the horizontal and vertical directions, respectively. and For pixel point d, the pixel intensity values ​​in its 3×3 neighborhood are compared with K x and K y Perform convolution to obtain the horizontal gradient component G xd and the vertical gradient component G yd , then the gradient amplitude calculation formula is: For example, if the pixel d and its neighborhood G xd =30 and G yd =40, then

[0072] N factor The steps to obtain the parameters are as follows: it represents the maximum value of the absolute value of the gradient modulation difference of all pixels. First, the gradient modulation difference of each pixel in the image needs to be calculated, that is, (R d -S d )·G d , then take its absolute value |(R d -S d )·G d |, traverse all the pixels in the image and find the largest of these absolute values, which is N factor , the calculation formula is: For example, after calculating the entire image, it is found that all |(R d -S d )·G d Among the values ​​of |, the maximum value is 3000, then N factor =3000;

[0073] L d The steps to obtain the parameters are as follows: it represents the value of the dth pixel in the local standard deviation normalization result. First, it is necessary to obtain the original local standard deviation value LSD of each pixel in the image. d (This is the output of the previous step) These values ​​are then normalized to map their range to the usual [0, 1] interval. The normalization calculation formula is: Among them LSD min is the minimum value of the original local standard deviation in the entire image, LSD maxIt is the maximum value of the original local standard deviation in the entire image. Before performing this calculation, it is necessary to traverse the LSD values ​​of all pixels to determine the LSD min and LSD max For example, if the original local standard deviation LSD of a pixel d is d =15, and the LSD of the entire image min =2 and LSD max =22, then

[0074] L max The parameter acquisition steps are as follows: it represents the maximum value of the normalized local standard deviation in the entire image, and the normalized local standard deviation L of all pixels is calculated. d (As above, its value is usually in the range [0, 1]) max These L d The maximum value among the values ​​is calculated as: If normalization is performed strictly by mapping the original maximum value to 1 and the original minimum value to 0, and there is at least one pixel in the image whose original local standard deviation reaches the global maximum LSD max And not equal to LSD min , then L max The value of will be 1.0, for example, according to the aforementioned L d If there are non-repeated maximum and minimum values ​​in the data, then L max =1.0;

[0075] Calculation process:

[0076] The parameter values ​​are set as follows, which are examples obtained based on the above steps:

[0077] For a specific pixel d:

[0078] R d =192;

[0079] S d =185;

[0080] G d =50;

[0081] Statistics or calculations from the entire image:

[0082] N factor =3000;

[0083] The normalized local standard deviation for this particular pixel d is:

[0084] L d =0.65;

[0085] Normalized local standard deviation maximum over the entire image:

[0086] L max =1.0;

[0087] First, calculate the absolute value of the gradient modulation difference:

[0088] |(R d -S d )·G d |=|(192-185)·50|=|7·50|=|350|=350;

[0089] Next, calculate the normalized gradient modulation difference (part of the numerator):

[0090]

[0091] Then, calculate the local standard deviation penalty term in the denominator:

[0092]

[0093] Calculate the complete:

[0094]

[0095] Since N factor =3000>0, the first case of applying the formula:

[0096]

[0097] The result shows that the detail weight value W of pixel d d This value is about 0.28639, which is in the range of 0 to 1 and represents the confidence or emphasis of the pixel being identified as part of the crack. The numerical result of 0.28639 means that the pixel has certain crack characteristics (because its original details and gradient are not zero), but because its local standard deviation is relatively large (L d =0.65, indicating that it is in a relatively complex texture area), its weight is significantly suppressed. If the value is close to 1, it indicates that the pixel is very likely to be part of a crack and is located in a relatively smooth background. If the value is close to 0, it indicates that the pixel does not have crack characteristics or is located in an extremely complex texture area.

[0098] Based on the detail weight value of each pixel position calculated in the above steps, and the pixel intensity value of the original steel pipe surface image and the corresponding pixel intensity value of the smoothed basic image are retrieved, for each pixel point d, its original detail is first calculated, that is, the intensity value R of the original steel pipe surface image at that point d Subtract the corresponding intensity value S of the smoothed base image at this point d, and get the difference D d =R d -S d , the difference D d Represents the potential crack information that may be suppressed during the smoothing process. Then, the detail weight value W corresponding to the pixel d is obtained. d The weight value is calculated based on the gradient modulation difference and the local standard deviation, and is used to evaluate the possibility that the pixel point belongs to the real crack detail. Then, the calculated intensity difference D d And the corresponding detail weight value W d Perform dot multiplication operation, that is, calculate WD pixel by pixel d =D d W d , this product WD d It is the weighted crack detail intensity, which enhances the detail information of pixels that are considered to be cracks (high weight) and suppresses the detail information of non-crack areas (low weight). The weighted crack detail intensity WD calculated from all pixels is d Arrange and combine them according to their original spatial positions in the image to form a new image. Each pixel value of the image is the WD at the corresponding position. d , this new image is the final generated weighted crack detail.

[0099] The steps to obtain the preliminary fusion pixel data are:

[0100] The pixel intensity value of each pixel position in the weighted crack detail is called, and the pixel intensity value of the corresponding position in the smoothed basic image is synchronously called. The pixel positions are used as indexes, and the pixel intensity value comparison sets are formed by pairing and combining them one by one to obtain the pixel intensity value comparison set.

[0101] Based on the pixel intensity value comparison set, linear superposition fusion of intensity values ​​is performed pixel by pixel, and the pixel intensity values ​​of the weighted crack details and the smoothed basic image at each pixel position are superimposed in a fixed ratio to obtain the fused pixel intensity initial value set;

[0102] Based on the fused initial pixel intensity value set, each pixel position is traversed in turn, the initial pixel intensity values ​​are organized according to the spatial order of the image, and recombined to form a complete image data matrix to obtain preliminary fused pixel data.

[0103] Specifically, the weighted crack detail image data generated in the above steps and the smoothed basic image data generated earlier are called, and for each pixel position in the weighted crack detail image, such as the pixel point with coordinates (x, y), its pixel intensity value is read. This value is called WD(x, y), which represents the weighted intensity of the crack feature at that point. At the same time, for the smoothed basic image, the pixel intensity value at the same pixel position (x, y) is synchronously called, called S(x, y), which represents the smooth background or basic structure information of the image. This is performed for all pixel positions in the image, from (0, 0) to (W-1, H-1) (where W is the image width and H is the image height). A double call operation ensures that each pixel position obtains two corresponding intensity values, one from the weighted crack detail image and the other from the smoothed base image. Then, using the two-dimensional coordinates (x, y) of each pixel as a common index, the two intensity values ​​WD(x, y) and S(x, y) are paired to form a combination unit containing two intensity values, such as a tuple (WD(x, y), S(x, y)). Collecting such paired combination units of all pixel positions constitutes a structured set. Each element in this set contains the crack detail intensity and smoothed background intensity at a specific pixel position. This set is the pixel intensity value comparison set.

[0104] Based on the pixel intensity value comparison set obtained in the previous step, the set provides a pair of intensity values ​​for each pixel position (x, y) in the image, namely the weighted crack detail intensity value WD(x, y) and the smoothed basic image intensity value S(x, y). The linear superposition and fusion processing of the intensity values ​​is performed independently on each pixel point. This fusion process follows a fixed proportional rule. Specifically, a proportional coefficient λ is set for the weighted crack detail intensity value WD(x, y) WD , and set another scaling factor λ for the intensity value S(x,y) of the smoothed base image S , these two proportional coefficients λ WD and λ S is a predetermined fixed value. Its setting is mainly based on the experimental evaluation and optimization of the crack enhancement effect of a large number of steel pipe images. For example, by testing a sample set of steel pipe images containing cracks of different types and severity, the performance of the fused images under different ratio coefficient combinations in terms of crack visibility, background noise suppression, and overall visual effect is compared. Experienced image analysts or quantitative image quality evaluation indicators are used to judge and select the optimal ratio combination. A proven setting is to set λ to WD Set to 1.0, and SSet to 1.0, which means that the complete weighted crack details are directly superimposed on the complete smooth base image, and the initial value of the fused pixel intensity F(x,y) is calculated by WD WD(x,y)+λ S ·S(x,y) is obtained, which is WD(x,y)+S(x,y) in this case. Since WD(x,y) represents details or differences, its value may be positive or negative (although it may have been processed to a positive value in the aforementioned weighting process or its influence is mainly on the increase of brightness), and S(x,y) is usually within the standard image intensity range (for example, 0 to 255), the superimposed F(x,y) value may exceed this range. Therefore, after calculating the superposition result, truncation processing is required to set all F(x,y) values ​​less than 0 to 0 and all F(x,y) values ​​greater than 255 to 255 to ensure that the fused intensity value is still within the valid display and storage range. This linear superposition and truncation operation is performed on all pixel pairs in the pixel intensity value comparison set, and the resulting set is the fused pixel intensity initial value set.

[0105] Based on the set of fused pixel intensity initial values ​​obtained in the above steps, this set contains the new intensity values ​​of each pixel position in the image after linear superposition and truncation, but these intensity values ​​may still be stored in the form of a list or unstructured set, in which each element is associated with its corresponding pixel coordinates. In order to form an image that can be processed or displayed later, it is necessary to reorganize these fused pixel intensity initial values ​​into a two-dimensional data matrix with a standard image space structure. The specific operation is to traverse all possible pixel positions of the image in turn, for example, starting from the coordinate (0,0), and access the most pixel positions of the image in a row-first (that is, first traverse all columns of the first row, then all columns of the second row, and so on) or column-first scanning order. For each pixel position (x, y) currently traversed, the initial fusion intensity value F(x, y) corresponding to the coordinate is searched and extracted from the fused pixel intensity initial value set. Then, the extracted intensity value F(x, y) is placed in a new two-dimensional array (i.e., the image data matrix) at the position corresponding to (x, y). The dimension of this new two-dimensional array is exactly the same as the width W and height H of the original steel pipe surface image. By performing this search, extraction, and placement operation on all pixel positions, the new two-dimensional array is gradually filled, and finally the conversion from a discrete intensity value set to a structured image data matrix is ​​completed. The completely filled two-dimensional array is the preliminary fused pixel data.

[0106] The steps to obtain the standard deviation distribution of the fused image are:

[0107] Based on the preliminary fusion pixel data, traverse each pixel position, extract the intensity value of each pixel position, and calculate the pixel intensity fluctuation within the local neighborhood to obtain the basic data set of local intensity distribution;

[0108] Based on the basic data set of local intensity distribution, the standard deviation value in the local area is calculated pixel by pixel, and the standard deviation value set corresponding to each pixel position is generated;

[0109] Based on the standard deviation value set, all pixel positions in the image are traversed in turn, and the standard deviation value of each pixel is sorted and summarized to form the standard deviation distribution of the fused image.

[0110] Specifically, based on the preliminary fused pixel data obtained in the above steps, the data is a complete image data matrix, in which each element represents the intensity value of the corresponding pixel position after fusion. In order to analyze the local characteristics of the fused image, it is first necessary to traverse each pixel position in the preliminary fused pixel data matrix. For example, for an image with a width of W and a height of H, traverse all coordinates (x, y), where x ranges from 0 to W-1 and y ranges from 0 to H-1. At each currently traversed pixel position (x c ,y c ), extract its own intensity value FPD(x c ,y c ), and a fixed-size local neighborhood is defined around the point. For example, a 5x5 pixel square window is selected as the neighborhood. The selection of the window size is based on the need to strike a balance between effectively capturing the intensity variation details around the pixel point and avoiding smoothing out useful information due to a too large window. A 5x5 window can usually provide enough data samples for the subsequent standard deviation calculation. At the same time, for typical steel pipe surface image features, it will not span too large a heterogeneous area. This 5x5 neighborhood will cover the area from the coordinate (x c -2,y c -2) to (x c +2,y c +2), when extracting the intensity values ​​of all pixels in this window, if the window area exceeds the boundary of the preliminary fused pixel data, the boundary pixel replication filling strategy is adopted, that is, the virtual pixel points beyond the boundary will be assigned the intensity value of the nearest real pixel point within the boundary, and the intensity values ​​of all 25 pixels in this 5x5 neighborhood window (after boundary processing) are collected to form a one-dimensional list or array containing these intensity values. This list is the center pixel (x c ,y c), perform this neighborhood intensity value extraction operation on each pixel point in the preliminary fused pixel data, and finally obtain a set, in which each element is a list of neighborhood intensity values ​​corresponding to the original pixel point. This set is the basic data set of local intensity distribution.

[0111] According to the basic data set of local intensity distribution generated for each pixel in the preliminary fusion pixel data in the previous step, each data in the set is a list containing the intensity values ​​of all pixels in the local neighborhood (for example, 5x5 neighborhood) of the corresponding central pixel. Next, for each central pixel, use its corresponding neighborhood intensity value list to calculate the standard deviation value in the local area. The calculation process of the standard deviation strictly follows its statistical definition. First, calculate the arithmetic mean of all intensity values ​​in the neighborhood intensity value list to obtain the average intensity of the local neighborhood. Then, for each intensity value in the list, calculate the difference between it and the local average intensity just obtained, and square this difference to obtain the intensity value of each neighborhood pixel. The squared deviation of the degree relative to the local mean is then accumulated, and the sum of all these squared deviation values ​​is calculated. The sum is then divided by the total number of pixels in the neighborhood (for example, for a 5x5 neighborhood, the number is 25; if an unbiased estimate of the sample standard deviation is used, the sum is divided by the number minus 1, which is 24) to obtain the variance of the local area. Finally, the positive square root of the calculated variance is taken, which is the standard deviation value in the local area corresponding to this central pixel. This series of calculation steps is performed for each neighborhood intensity list in the basic data set of the local intensity distribution, and a corresponding local standard deviation value is generated for each pixel position in the image. These calculated standard deviation values ​​together constitute the set of standard deviation values ​​corresponding to each pixel position.

[0112] Based on the standard deviation value set corresponding to each pixel position calculated and generated in the above steps, this set contains the local standard deviation values ​​corresponding to each pixel point in the preliminary fused pixel data. These values ​​reflect the change or fluctuation degree of the fused image intensity in the neighborhood around each pixel point. In order to form a structured data representation that can intuitively represent the spatial distribution of the standard deviation of the entire image, it is necessary to organize and summarize this standard deviation value set. The specific operation is to create a new two-dimensional data matrix with the same dimensions as the width W and height H of the original preliminary fused pixel data (and the steel pipe surface image). Then, all pixel positions in the image are traversed in turn. For example, For example, starting from the coordinate (0,0), scan row by row to (W-1,H-1). For each currently accessed pixel coordinate (x,y), extract the previously calculated local standard deviation value corresponding to the coordinate (x,y) from the set of standard deviation values ​​corresponding to each pixel position, and store this extracted standard deviation value in the corresponding (x,y) position in the newly created two-dimensional data matrix. By performing this extraction and assignment operation on all pixel positions, the new two-dimensional data matrix is ​​gradually filled, and finally the local standard deviation of each position in the image is completely recorded. This filled two-dimensional data matrix is ​​the standard deviation distribution of the formed fused image.

[0113] The steps for obtaining the target intensity mapping rule are:

[0114] Based on the standard deviation distribution of the fused image, the set of local standard deviation values ​​of all pixels is collected, and the standard deviation value of each pixel position is extracted to obtain a complete set of standard deviation values;

[0115] Based on the complete set of standard deviation values, the stretch transformation amplitude of each pixel position is calculated using the following formula:

[0116]

[0117] Among them, A d is the stretch transformation amplitude of the d-th pixel position, σ d is the standard deviation of the d-th pixel position, σ i is the set of standard deviation values ​​of all pixels in the image, n is the total number of pixels in the image, Is the maximum value of the standard deviation of all pixels, used to standardize the stretch transformation amplitude; if max j =0, then the stretch transformation amplitude A d Set to 1;

[0118] Based on the stretch transformation amplitude, the target intensity mapping rule is obtained.

[0119] Specifically, based on the standard deviation distribution of the fused image finally formed in the above steps, the distribution is essentially a two-dimensional data matrix whose dimension is consistent with the original image, and each matrix element stores the local standard deviation value of the corresponding pixel position. First, it is necessary to convert or organize this two-dimensional distribution data into a one-dimensional set, that is, to collect the local standard deviation values ​​of all pixels in the distribution. The specific operation is to traverse each element in the standard deviation distribution matrix of the fused image, for example, in order from top to bottom and from left to right, and extract the local standard deviation value σ recorded at each pixel position (x, y) one by one. (x,y) , and add these extracted standard deviation values ​​to a list or array. This list or array constitutes the original set containing the local standard deviation values ​​of all pixels in the image. Subsequently, in order to ensure the accuracy and consistency of subsequent calculations, the data in this original set is finally sorted to ensure that each pixel position has a clear standard deviation value corresponding to it, and this set can be easily indexed and queried by subsequent steps. For example, it can be organized into a one-dimensional array containing n elements, where n is the total number of pixels in the image, and the d-th element of the array is the standard deviation value of the d-th pixel, thereby obtaining a complete set of standard deviation values.

[0120] formula: The usefulness of the formula is that it calculates a normalized stretch transformation magnitude A for each pixel d in the image d , which reflects the local standard deviation σ of the point d The relative significance of the standard deviation energy distribution of the entire image, the numerator The local standard deviation of a single pixel is combined with the overall standard deviation energy of the image where it is located (given by Representation, which can be regarded as a measure of the Euclidean norm or energy of the standard deviation vector) is combined to give the local standard deviation a global context weight, and the denominator The maximum value of the weighted local standard deviation in the entire image is calculated, and the normalization of the stretch transformation amplitude is achieved through the ratio of the two, so that A d The value of is between 0 and 1 (when the denominator is non-zero). This design ensures that the magnitude of the stretch transformation varies according to the actual content of the pixel neighborhood (given by σ d The standard deviation is reflected) and its position in the global change, so that the contrast can be adjusted more adaptively. For areas with larger standard deviations (usually corresponding to areas with richer details or more drastic contrast changes in the image), the A d The larger the value, the stronger the contrast stretching is obtained in the subsequent steps, and the special case processing (when the denominator is 0, that is, all σ j When both are 0, A d=1) ensures that in the extreme case of a completely flat image (without any texture or details), the system can still give a definite and uniform transformation amplitude, avoiding division by zero errors;

[0121] σ d The parameter acquisition step is as follows: , which represents the standard deviation value of the d-th pixel position. This value comes directly from the "complete standard deviation value set" generated in the previous step. Each element in the set is the local standard deviation of the neighborhood of the corresponding pixel point in the image. It is calculated after performing local neighborhood analysis on the "preliminary fused pixel data" and reflects the degree of pixel intensity change in the area around the pixel point. For example, for a specific pixel point d in the image, its corresponding σ d The value is 15.0;

[0122] σ i The parameter acquisition step is that it represents the set of standard deviation values ​​of all pixels in the image, which is the "complete standard deviation value set" itself that is finally output by the above steps. This set contains the local standard deviation value of each pixel in the image (from the 1st to the nth), that is, {σ1,σ2,…,σ n}, these values ​​together describe the statistical characteristics of the texture and detail distribution of the entire image. For example, for a micro image containing only 9 pixels, its σ i The collection is

[0123] {5.0,8.2,12.1,6.5,15.0,9.3,7.8,10.4,11.7};

[0124] The steps to obtain the n parameter are as follows: it represents the total number of pixels in the image. This value is directly determined by the size of the processed image. If the image width is W pixels and the height is H pixels, then the total number of pixels n = W × H. This information can be obtained when the image is loaded. For example, a steel pipe surface image with a width of 200 pixels and a height of 150 pixels has a total number of pixels n = 200 × 150 = 30,000;

[0125] Calculation process:

[0126] Take a small image containing n = 4 pixels as an example, and its “complete set of standard deviation values” {σ i} is {σ1=10.0, σ2=20.0, σ3=5.0, σ4=15.0}.

[0127] Calculate the stretch transformation amplitude A at each pixel position d .

[0128] First, calculate the constant term

[0129]

[0130] make

[0131] Next, calculate the denominator max j (|σ j |·C). Due to the standard deviation σ j non-negative, |σ j |=σ j .

[0132] Need to calculate σ for each pixel j C:

[0133] For pixel 1 (j=1): σ1·C=10.0·27.38612788=273.8612788;

[0134] For pixel 2 (j=2): σ2·C=20.0·27.38612788=547.7225576;

[0135] For pixel 3 (j=3): σ3·C=5.0·27.38612788=136.9306394;

[0136] For pixel 4 (j=4): σ4·C=15.0·27.38612788=410.7919182;

[0137] So, max j (σ j ·C)=547.7225576.

[0138] This value is greater than 0, so the first case of the formula is used.

[0139] Now calculate A for each pixel d :

[0140] For pixel 1 (d=1, σ1=10.0):

[0141]

[0142] For pixel 2 (d=2, σ2=20.0):

[0143]

[0144] For pixel 3 (d=3, σ3=5.0):

[0145]

[0146] For pixel 4 (d=4, σ4=15.0):

[0147]

[0148] The result shows that the stretching transformation amplitude A of each pixel d is a value between 0 and 1 (in this case, if all σ j is 0, then A d =1), which reflects the ratio of the local standard deviation of the pixel to the maximum local standard deviation in the image (because the constant C cancels out in the numerator and denominator unless C is 0). For example, A2 = 1.0 means that the local standard deviation of pixel 2 is the largest in the image, so its stretch transformation amplitude is also the largest, while A3 = 0.25 means that the local standard deviation of pixel 3 is relatively small, and its stretch transformation amplitude is also correspondingly small. d The set of values ​​constitutes the pixel-by-pixel stretch transformation magnitude.

[0149] The stretch transformation amplitude A calculated for each pixel position d in the image based on the above steps d , these amplitude values ​​together form a parameter map of the same size as the image, where each value A d (usually between 0 and 1) indicates the degree or weight by which the corresponding pixel position should be stretched in the subsequent contrast enhancement operation. Next, it is necessary to construct or define the target intensity mapping rule based on these stretching transformation amplitudes. This rule will determine how to map the original intensity value in the preliminary fused pixel data to the new intensity value after the final optimized contrast. The target intensity mapping rule is not a single global transformation, but can be based on the A of each pixel. d The value is locally adaptively adjusted. For example, an intensity transformation function T(I in ), whose parameters (such as gain, bias or control points of nonlinear transformation) are about A d Function, for A d For pixels with larger values ​​(indicating a larger standard deviation of their neighborhood and richer details), the mapping rule will apply a stronger contrast stretch, such as a steeper mapping curve or a larger gain factor, while for A d For pixels with smaller values ​​(indicating smoother neighborhoods), the mapping rule will use a gentler transformation to avoid amplifying noise. Therefore, the target intensity mapping rule can be understood as a set of lookup tables or a set of parameterized functions, where each pixel d is associated with a pixel corresponding to A. d The specific intensity mapping method determined.

[0150] The steps to obtain the contrast-optimized steel pipe image are:

[0151] Based on the target intensity mapping rule, the intensity value of each pixel position is adjusted according to the transformation amplitude defined in the target intensity mapping rule to obtain an updated pixel intensity data set;

[0152] According to the updated pixel intensity data set, each pixel position is traversed and the intensity value is adjusted to obtain a pixel value set with optimized contrast;

[0153] Based on the contrast-optimized pixel value set, the intensity value of each pixel point is reorganized according to the image position and synthesized into complete image data, and the contrast-optimized steel pipe image is output.

[0154] Specifically, based on the target intensity mapping rule obtained in the above steps, the rule provides a stretching transformation amplitude A for each pixel position d in the preliminary fused pixel data. d , and at the same time call the preliminary fused pixel data, which contains the current intensity value I of each pixel position d , according to the transformation amplitude A defined in the target intensity mapping rule d , for each pixel position the intensity value I d Adjustment is performed by a local adaptive contrast enhancement transformation, for example, the new intensity value I′ d The calculation of I′ can follow the following rules: d =I d +G·A d ·(I d -M), where M is the global average intensity value of the entire preliminary fused pixel data. The average intensity value is calculated by accumulating the intensity values ​​of all pixels in the preliminary fused pixel data and dividing it by the total number of pixels. For example, if the sum of all intensity values ​​of a 100x100 pixel preliminary fused pixel data is 1250000, then the global average intensity M = 1250000 / (100×100) = 125. The parameter G is a global gain factor used to control the intensity of the overall enhancement. Its value is set based on experience, for example, to 0.4. This value was determined after a series of tests on a representative sample set of steel pipe images containing various crack features. In the tests, G was adjusted from 0.1 to 0.8. Three technicians with more than five years of experience in steel pipe flaw detection evaluated the crack clarity and background noise amplification under different G values. Ultimately, 0.4 was selected as a compromise value that achieved a good balance between improving crack contrast and suppressing noise. For each pixel d, its stretching transformation amplitude A d (usually ranges from 0 to 1) will adjust the above enhancement term (I d -M) contribution, A d The larger the value, the richer the details of the area and the greater the adjustment range. The calculated I′ d The value then needs to be truncated to ensure that it falls within the valid pixel intensity range. For example, for an 8-bit image, it is truncated to the interval [0, 255]. That is, if I′ d<0, then let I′ d =0, if I′ d >255, then let I′ d =255, and after performing this adjustment and truncation operation on all pixel positions, an updated pixel intensity data set is formed.

[0155] According to the updated pixel intensity data set obtained in the previous step, the set includes the intensity value I′ of each pixel after the preliminary fusion pixel data is adjusted for local contrast based on the stretch transformation amplitude and subjected to preliminary truncation processing. d In order to further optimize the overall visual contrast of the image and make full use of the dynamic range of the image, each pixel position in the updated pixel intensity data set is traversed again and its intensity value is adjusted. This adjustment adopts the global contrast stretching method. First, it is necessary to determine the minimum intensity value I′ in the current updated pixel intensity data set. min and the maximum intensity value I′ max , which is done by a single pass through all pixels in the set I′ d The value is completed, for example, after traversing all I′ d After that, it is found that its minimum value is 30 and its maximum value is 210. If I′ min with I' max If they are not equal, then for each I′ d Apply a linear stretch transformation to the value, mapping it to a new intensity value I″ d , calculated as: I″ d = target maximum strength ×

[0156] (I′ d -I′ min ) / (I′ max -I′ min ) + target minimum intensity, usually the target maximum intensity is set to 255 and the target minimum intensity is set to 0 (for 8-bit images), then the formula is simplified to I″ d =255×(I′ d -I′ min ) / (I′ max -I′ min ), for example, for an I′ d The value is 150, given I′ min =30 and I′ max =210, the corresponding I″ d =255×(150-30) / (210-30)=255×120 / 180=255×(2 / 3)=170, if I′ appears min Equal to I′ max In the special case (i.e., all pixel intensities in the image are the same), then all I″d are all set to the same value (or a preset intermediate value such as 128). After this global stretching transformation, the intensity values ​​of all pixels will be evenly distributed in the range of [0, 255] (such as the target range), thereby obtaining a set of pixel values ​​with optimized contrast.

[0157] Based on the aforementioned steps, the updated pixel intensity data set is subjected to global contrast stretching, resulting in a set of optimized contrast pixel values. This set currently contains a series of values ​​representing the optimized brightness of each pixel in the final image. However, these values ​​may still be stored in the form of lists, one-dimensional arrays, or other non-image-native two-dimensional matrices. To generate the final contrast-optimized steel pipe image for visualization or further machine vision analysis, the intensity values ​​of each pixel in this set need to be reorganized according to their spatial position in the original image and synthesized into a complete two-dimensional image data matrix. Specifically, a new W×H two-dimensional matrix is ​​created based on the width W and height H of the original image. Then, all pixel coordinates (x, y) of the original image are traversed sequentially, where x ranges from 0 to W-1 and y ranges from 0 to H-1. For each coordinate (x, y), the final intensity value I″ corresponding to that spatial position is extracted from the set of optimized contrast pixel values. d (where d is the pixel index corresponding to the coordinate (x,y)), and this intensity value I″ d The elements at coordinates (x, y) in the newly created two-dimensional matrix are assigned. After filling the intensity values ​​at all pixel locations, this two-dimensional matrix constitutes a complete, contrast-optimized digital representation of the steel pipe image. This image data can then be directly output to a display device for display or saved to a standard image file format (such as PNG, JPEG, etc.) for subsequent use.

Claims

1. Steel pipe crack detection system based on image enhancement, characterized by: The system comprises: An image smoothing processing module reads the intensity values ​​of all pixels from the original steel pipe surface image, organizes the intensity values ​​into an original pixel set, sets a guided filter based on the original pixel set, and filters the original pixel set as a guided image together with the input image to obtain a smoothed basic image; The weight and detail calculation module reads all pixel values ​​of the original steel pipe surface image, calculates the standard deviation within the neighborhood of each pixel point, obtains a local standard deviation value, obtains a detail weight based on the local standard deviation value, subtracts the corresponding pixel value of the smoothed basic image from the pixel value of the original steel pipe surface image to obtain the original detail, and applies the detail weight to the original detail to generate a weighted crack detail; An image fusion construction module is configured to fuse the weighted crack details with the smoothed base image to obtain preliminary fused pixel data, and based on the preliminary fused pixel data, traverse each pixel to calculate the standard deviation distribution of the fused image; The contrast optimization output module analyzes the standard deviation value of each position in the standard deviation distribution of the fused image, determines the stretching transformation amplitude according to the standard deviation value, forms a target intensity mapping rule, and outputs an optimized contrast steel pipe image based on the target intensity mapping rule.

2. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps of obtaining the smoothed basic image are: Read the intensity values ​​of all pixels one by one from the original steel pipe surface image, extract the intensity values ​​corresponding to each pixel one by one and organize them into an original pixel set to obtain an original pixel set; Based on the original pixel set, by analyzing the spatial distribution characteristics and local variation trends of the intensity values ​​of each pixel in the original pixel set, setting the radius parameter and the regularization coefficient of the guided filter to obtain a filter parameter set; Based on the filter parameter set, the original pixel set is used as a guide image and an input image at the same time, and pixel intensity value filtering in the spatial domain is performed on the original pixel set to obtain a smooth basic image.

3. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the local standard deviation value are: All pixel values ​​are read from the original steel pipe surface image, and the position of each pixel in the image coordinate system and its corresponding pixel intensity value are paired and sorted to form a set of original pixel positions and intensity values, thereby obtaining a set of original pixel positions and intensity values; Based on the original pixel position and intensity value set, a fixed-size neighborhood window is defined according to the coordinate position of each pixel point in the image and the intensity values ​​of all pixels in the window are extracted. The discrete degree of the pixel intensity value in the neighborhood window is calculated to obtain the intensity distribution within the neighborhood range of each pixel point. Based on the intensity distribution within the neighborhood of each pixel, the standard deviation is calculated point by point to obtain the local standard deviation value.

4. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the weighted crack details are: Based on the local standard deviation value, the intensity values ​​of all pixel positions in the original steel pipe surface image and the intensity values ​​of the smoothed basic image at the corresponding positions are extracted, the intensity difference of each pixel is calculated and combined with the gradient amplitude of the corresponding pixel to obtain a gradient modulation difference set; According to the gradient modulation difference set, the maximum absolute value of the gradient modulation difference of all pixels is counted as a normalization factor, and a detail weight value is calculated for each pixel; Based on the detail weight value, the intensity difference of each pixel of the original steel pipe surface image is multiplied by the detail weight value of the corresponding position, and all calculation results are superimposed pixel by pixel to construct a brightness expression of the crack feature to generate weighted crack details.

5. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the preliminary fused pixel data are as follows: Calling the pixel intensity value of each pixel position in the weighted crack detail and synchronously calling the pixel intensity value of the corresponding position in the smoothed basic image, using the pixel position as an index, pairing and combining them one by one to form a pixel intensity value comparison set, thereby obtaining a pixel intensity value comparison set; Based on the pixel intensity value comparison set, linear superposition and fusion of intensity values ​​are performed pixel by pixel, and the pixel intensity values ​​of the weighted crack details and the smoothed basic image at each pixel position are superimposed in a fixed ratio to obtain a fused pixel intensity initial value set; Based on the fused initial pixel intensity value set, each pixel position is traversed in sequence, the initial pixel intensity values ​​are organized according to the spatial order of the image, and are recombined to form a complete image data matrix to obtain preliminary fused pixel data.

6. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the standard deviation distribution of the fused image are: Based on the preliminary fused pixel data, traverse each pixel position, extract the intensity value of each pixel position, and calculate the pixel intensity fluctuation within the local neighborhood to obtain a basic data set of local intensity distribution; Calculating the standard deviation value within the local area pixel by pixel based on the basic data set of the local intensity distribution to generate a standard deviation value set corresponding to each pixel position; Based on the standard deviation value set, all pixel positions in the image are traversed in sequence, and the standard deviation value of each pixel is sorted and summarized to form a standard deviation distribution of the fused image.

7. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the target intensity mapping rule are as follows: Based on the standard deviation distribution of the fused image, a set of local standard deviation values ​​of all pixels is collected, and the standard deviation value of each pixel position is extracted to obtain a complete set of standard deviation values; Calculating a stretch transformation amplitude for each pixel position based on the complete set of standard deviation values; Based on the stretch transformation amplitude, a target intensity mapping rule is obtained.

8. The steel pipe crack detection system based on image enhancement according to claim 1, characterized in that: The steps for obtaining the contrast-optimized steel pipe image are as follows: Based on the target intensity mapping rule, adjusting the intensity value of each pixel position according to the transformation amplitude defined in the target intensity mapping rule to obtain an updated pixel intensity data set; According to the updated pixel intensity data set, traverse each pixel position and adjust the intensity value to obtain a pixel value set with optimized contrast; Based on the contrast-optimized pixel value set, the intensity value of each pixel point is reorganized according to the image position and synthesized into complete image data, and the contrast-optimized steel pipe image is output.