A method for improving the contrast of images in low-light environments of robot welding paths

Through the image enhancement method of contrast-aware compression factor and polar coordinate structure, the problems of insufficient brightness and blurred edges of welding path images in low-light environments are solved, and accurate enhancement and recognition of welding paths are achieved.

CN120471815BActive Publication Date: 2025-09-09GUANGDONG OCEAN UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510940044.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-09
Publication Date
2025-09-09
Estimated Expiration
2045-07-09

AI Technical Summary

Technical Problem

In low-light environments, the welding path image has insufficient brightness, blurred edges, and severe background noise, resulting in low path recognition and tracking accuracy. Existing image enhancement methods have failed to effectively improve structural recognizability.

Method used

The contrast-aware compression factor is used to improve the single-factor brightness compression. A low-light image enhancement color space based on polar coordinate structure is introduced. The directional consistency entropy and directional responsivity are combined to construct the welding path structure response map. The color-enhanced image and the structure response map are fused to suppress background noise interference.

Benefits of technology

The clarity and structural continuity of the welding path image are improved, the welding edge details are enhanced, and the recognition accuracy and robustness of the welding path in low-light environments are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120471815B_ABST
    Figure CN120471815B_ABST
Patent Text Reader

Abstract

The present invention provides a method for enhancing the contrast of a robot welding path image in a low-light environment, which relates to the field of image processing. First, a contrast perception compression factor is used to improve the original compression method based on a single brightness factor. Second, a low-light image enhancement color space based on a polar coordinate structure is introduced, and a low-light image enhancement color space with spatial decoupling capability is constructed in combination with the contrast perception compression factor. Directional consistency entropy and directional responsivity are integrated to construct a welding path structure response map, thereby enhancing the sensitivity to structural features with directionality and coherence such as the welding path, and improving the accuracy and robustness of structure extraction. Finally, by combining the color-enhanced robot welding path image and the welding path structure response map, the welding edge details are highlighted while the background noise interference is effectively suppressed, thereby achieving precise enhancement of the welding path image, strengthening the welding edge details, and improving the image clarity and structural continuity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing, and in particular relates to a method for improving the contrast of a robot welding path image in a weak light environment. Background Art

[0002] Automated welding technology is an important means to achieve high-quality and high-efficiency production in the manufacturing industry. Welding robots have been widely used in many key industrial fields such as automobile manufacturing, engineering machinery, and shipbuilding heavy industry. Accurate identification and tracking of welding paths are the core steps to achieve automated and precise welding. However, in actual production environments, welding scenes generally have problems such as poor lighting conditions, significant smoke disturbances, and complex weld structures. Especially in low illumination or strong interference scenes, weld images are prone to overall insufficient brightness, blurred edges, and severe background noise, which seriously affect the accuracy of path identification and tracking. Manual assistance or reliance on manual observation throughout the process not only places high technical requirements on operators and is labor-intensive, but also cannot meet the needs of high-precision, high-consistency, and high-efficiency automated welding operations. Therefore, it is necessary to build an intelligent perception system with adaptive perception capabilities and image quality enhancement capabilities to ensure the stability and accuracy of welding path identification.

[0003] Most existing image enhancement methods focus solely on brightness changes, while ignoring the weld structure's spatial distribution, frequency characteristics, and edge continuity. This results in improved brightness in the enhanced image, but insufficient structural recognizability, which impacts the accuracy of subsequent path extraction and control. Therefore, this paper proposes a contrast enhancement method for low-light images of robotic welding paths. A contrast-aware compression factor is designed to improve the existing compression method based on a single brightness factor. A polar coordinate-based low-light image enhancement color space is introduced to convert RGB images into HSV images, which are more consistent with human visual perception. The contrast-aware compression factor is then combined to construct a low-light image enhancement color space with spatial decoupling capabilities. A welding path structure response map is constructed by fusing directional consistency entropy and directional responsivity. This map identifies dominant directions from local grayscale evolution trends, independent of edge intensity, enhancing sensitivity to directional and coherent structural features such as the welding path, and improving the accuracy and robustness of structure extraction. By combining brightness similarity and structural response similarity, weld edge details are highlighted while background noise interference is effectively suppressed. This allows for precise enhancement of the welding path image, enhancing weld edge details, improving image clarity and structural continuity, and making the welding path easier to identify in low-light environments. Summary of the Invention

[0004] The present invention provides a method for enhancing the contrast of a robot welding path in a low-light environment. First, a contrast-aware compression factor is proposed to improve the original compression method based on a single brightness factor. Secondly, a low-light image enhancement color space based on a polar coordinate structure is introduced, and a low-light image enhancement color space with spatial decoupling capability is constructed in combination with the contrast-aware compression factor. The directional consistency entropy and directional responsivity are integrated to construct a welding path structure response map, thereby enhancing the sensitivity to structural features with directionality and coherence such as the welding path, and improving the accuracy and robustness of structure extraction. Finally, by combining the color-enhanced robot welding path image and the welding path structure response map, the welding edge details are highlighted while the background noise interference is effectively suppressed, thereby achieving precise enhancement of the welding path image, strengthening the welding edge details, and improving the image clarity and structural continuity.

[0005] In order to achieve the above-mentioned purpose, the present invention provides the following technical solution: a method for improving the contrast of a low-light environment image of a robot welding path, comprising the following steps.

[0006] S1. Create a welding path low-light image dataset from the robot welding path image.

[0007] S2. Design a contrast-aware compression factor for each pixel through the brightness map and contrast map of the low-light image of the welding path, and dynamically adjust the compression strength of each pixel.

[0008] S3. Introduce a low-light image enhancement color space based on a polar coordinate structure, construct a color space conversion module, convert the RGB image into an HSV image, decompose the color saturation into two orthogonal axes through the HSV image and the contrast perception compression factor, and obtain a low-light welding path image enhancement color space. After the inverse transformation module, it is restored to an RGB image and the color-enhanced welding path image is output.

[0009] S4. A local structure perception mechanism based on direction difference vector is introduced to construct a welding path local perception module, and the direction responsiveness and direction consistency entropy are weightedly fused to obtain the welding path structure response map.

[0010] S5. Structure-guided bilateral filtering and contrast enhancement factor are proposed to construct a structure-aware contrast enhancement module. The color-enhanced welding path image and the welding path structure response map are fused to obtain a contrast-enhanced welding path image.

[0011] S6. Integrate the color space conversion module, the welding path local perception module, and the structure perception contrast enhancement module to build a low-light welding path image contrast enhancement model, input the welding path low-light image into the model, and output the contrast-enhanced welding path image.

[0012] Preferably, in step S1, it is costly to collect real weak-light and labeled robot welding path image data, and the real weak-light conditions are uncontrollable, and the sample diversity is insufficient. A robot welding path weak-light image generation scheme is proposed, and "weak-light-clear" paired training samples are generated based on clear welding path images. The weak-light image generation scheme specifically includes: local non-uniform brightness compression, local non-linear color degradation, and spatially correlated non-Gaussian noise superposition. Local non-uniform brightness compression simulates the coexistence of local strong light and weak light at the welding site, the complex distribution of welding arc light and surrounding shadows, and reflects the uneven brightness around the path; local non-linear color degradation simulates the color attenuation of the welding affected area and the color deviation caused by the reflectivity of different welding materials to ensure that the training samples are diverse and realistic in color; spatially correlated non-Gaussian noise superposition simulates the non-uniform noise and outliers caused by welding smoke, spatter and thermal disturbances, improves the robustness of the model to extreme interference, and obtains a welding path weak-light image dataset, which is divided into a training set and a validation set.

[0013] Preferably, in the weak light environment of robot welding operations, the welding area is often accompanied by strong reflections, sparks and smoke obstructions, resulting in low overall brightness of the welding path image, extremely uneven contrast distribution, sudden grayscale changes at the weld edge and a dark and flat background, and abnormally bright local noise. If a unified enhancement strategy is adopted, it is easy to cause overexposure of the weld edge, loss of background details, and synchronous amplification of noise, which directly affects the subsequent welding path detection and position tracking accuracy.

[0014] Preferably, in step S2, the specific steps of designing the contrast perception compression factor are:

[0015] S21. Input the low-light image of the welding path into the contrast perception compression module. First, the low-light image is normalized and the brightness map is extracted. The brightness map is obtained by the maximum value of the three RGB channels in the normalized low-light image. ,in, is any pixel in the image, Pixels The brightness value at , is the set of all pixel points of the weak light image of the welding path, is the brightness map;

[0016] S22, using the sliding window method, calculate the local brightness contrast of each pixel on the brightness map, and define the pixel Neighborhood area , , for pixels Take the pixel value in its neighborhood and calculate the brightness difference in the neighborhood , , for Pixels in the neighborhood, , taking the maximum difference as the contrast value , Pixels The contrast value at the point is used to construct a contrast map. , is the contrast map;

[0017] S23, calculate the contrast perception compression factor for each pixel through the brightness map and the contrast map, the contrast perception compression factor corresponding to the pixel point x The specific calculation formula is:

[0018] ;

[0019] Where, is the contrast adjustment weight parameter, , controls the degree of contrast influence in compression, Neighborhood area The average brightness of the image, k is the compression coefficient. The larger the contrast perception compression factor, the weaker the overall compression strength, which allows the pixel to maintain a higher brightness value and enhance its significance. The smaller the contrast perception compression factor, the stronger the compression strength, which pushes the pixel to the dark part and reduces its visual interference.

[0020] Preferably, in step S2, the contrast-aware compression module dynamically adjusts the compression strength of each pixel by combining the brightness map and the contrast map, thereby overcoming the problem that the traditional compression method based only on brightness information has insufficient image structure recognition ability; this mechanism can adaptively improve the brightness retention and edge clarity of the welding area when enhancing the robot welding path image, while performing stronger compression suppression on the background area, providing a better image for the extraction and recognition of the welding path.

[0021] Preferably, in the robot welding path image, the weak light environment often causes the RGB image to show severe brightness compression, tight channel coupling, color expression distortion and other problems. Especially when there are areas with high reflection and dark background coexisting around the welding area, the traditional RGB space enhancement method is difficult to effectively decouple the brightness and chromaticity information, resulting in problems such as false color and structural deformation after enhancement.

[0022] Preferably, in step S3, the color space conversion module specifically performs the following steps:

[0023] S31, convert the RGB value of each pixel in the welding path low-light image into HSV value, and normalize the red, green and blue channel values ​​of each pixel to Interval, calculate the maximum and minimum values, calculate the hue H and saturation S through the maximum and minimum values, and separate the color information into the HSV form that is more in line with human perception;

[0024] S32. Project the hue H onto the unit circle to obtain the horizontal component after polarization and vertical component , , , To normalize the hue and project it onto Within the range, ensure the stability of angle representation, combined with the saturation S and contrast perception compression factor in the HSV map Generate polarized color channels and , is the horizontal color response, , is the color response in the vertical direction, , is the color saturation value of pixel x. By polarizing the color channel, the color saturation is decomposed into two orthogonal axes (horizontal and vertical directions). 、 and brightness map Constructing welding path low-light image enhancement color space , enhance spatial separation and geometric processing capabilities;

[0025] S33, the inverse transformation module remaps the polar coordinates into angle form, through and Constructed as the hue of the enhanced HSV map and saturation , , , which will enhance the hue of the HSV image and saturation and brightness graph Integrated enhanced HSV robot welding path image , use the standard HSV to RGB conversion process to convert the enhanced HSV welding path image into an enhanced RGB welding path image, use the cv2.cvtColor function in the OpenCV library to complete the HSV image to RGB image, and output the color enhanced welding path image .

[0026] Preferably, in step S3, by introducing a low-light image enhancement color space based on a polar coordinate structure, the RGB image (a color image consisting of three color channels of red, green, and blue) is converted into an HSV form that is more in line with human visual perception (a model based on human color perception, describing color through three dimensions of hue, saturation, and brightness), and combined with the contrast perception compression factor to decompose the color information into two orthogonal axes, thereby constructing a low-light image enhancement color space with spatial decoupling capability, and realizing detail enhancement and color enhancement of the robot welding path image in a low-light environment; the enhanced low-light robot welding path image enhancement color space is restored to an RGB image through a reversible inverse transformation process, and the contrast is significantly enhanced, while ensuring natural color and realistic structure.

[0027] Preferably, there are interference factors in the low-light welding path image, such as blurred edges of the welding area, local overexposure caused by high-temperature reflection, broken directional information caused by smoke and dust obstruction, and disordered directional continuity caused by diffuse reflection of the background metal surface. These factors cause the traditional edge direction estimation method based on gradient or structure tensor to fail easily in areas severely affected by noise, resulting in directional redundancy, mutation and misjudgment. Especially in welding guidance path recognition, the accuracy of directional information directly determines the integrity and continuity of structure extraction. Once the local direction estimation is unstable, it will seriously affect the key response of the enhancement module to the main weld area, thereby leading to path recognition errors.

[0028] Preferably, in step S4, the specific steps of the welding path local perception module are:

[0029] S41. Input the welding path low-light image to the welding path local perception module, use a 9×9 sliding window to build a direction neighborhood for each pixel, which is used to calculate the direction consistency and coherence around the pixel, and set a set of direction sets. , , for each direction , defining pixels Two adjacent points in this direction and ,in, is the point one step forward in the current direction, , is the point two steps forward in the current direction, , calculate the grayscale difference between two segments through the grayscale values ​​of adjacent points, , , Pixel The grayscale value at the position is obtained by the grayscale difference between the two segments to obtain the direction difference vector in that direction. , calculate the direction difference vector of each direction in the direction set, and construct the direction perception information vector , used to calculate the total directional response and directional response distribution;

[0030] S42. Calculate the average intensity of the grayscale difference in each direction , calculate the total responsiveness of the direction corresponding to pixel x in the weak light image of the welding path according to the average intensity of the grayscale value in all directions The total directional response reflects the degree of brightness change of pixel x; by calculating the ratio of the average intensity of the current direction to the total average intensity of all directions, the average intensity of all directions is normalized into a probability distribution to obtain the directional response distribution , based on the Shannon entropy definition, the directional consistency entropy of pixel x in the low-light image of the welding path is calculated ,Directional consistency entropy measures the degree of discreteness of directional distribution.,A high entropy value indicates that the directional response is evenly distributed,which is the background area. A low entropy value indicates that the pixel occupies the dominant direction,which is a coherent structure.

[0031] S43. The directional total responsivity and directional consistency entropy of the integrated welding path weak light image are used to define the final structural score. The directional responsivity at pixel x and the directional consistency entropy at pixel x are weightedly fused to construct the final structural score at pixel x. The higher the final structure score, the more likely the point is to be in the continuous structure area. The value of the structure response map at pixel x is obtained by the final structure score. , the structural response diagram of the entire welding path is .

[0032] Preferably, in step S4, the local perception module of the welding path constructs a multi-directional grayscale difference vector, fuses the directional consistency entropy and directional responsiveness of the welding path weak-light image to finely quantify the pixel-level directional response and structural consistency, identifies the dominant direction from the local grayscale evolution trend without relying on edge intensity, and realizes the explicit modeling of the continuity and directionality of the linear structure in the welding path weak-light image; compared with traditional methods, it can robustly extract potential welding paths under complex conditions such as texture weakening, noise interference or boundary blur, enhances the sensitivity to structural features with directionality and coherence such as welding paths, and improves the accuracy and robustness of structure extraction.

[0033] Preferably, in the robot welding path image obtained in a low-light industrial environment, the grayscale difference between the metal reflective or low-brightness area and the background is weakened, resulting in the easy occurrence of structural detail false enhancement, background pseudo-edge misjudgment, and inconsistent welding boundary response during the contrast enhancement process. These problems make it difficult for the pixel brightness enhancement method to distinguish the main welding structure from the invalid background, affecting the accuracy of weld recognition and guidance. It is necessary to more specifically enhance the brightness of the main welding area and suppress the false enhancement of noise.

[0034] Preferably, in step S5, the structure-aware contrast enhancement module specifically comprises the following steps:

[0035] S51, input color enhanced welding path image and welding path structure response diagram , for the pixels at the same position in the color enhanced robot welding path image and the welding path structure response map , select a 5×5 pixel area centered on the pixel, and the area contains Adjacent pixels are recorded as , by calculating the adjacent pixels of the robot welding path image after color enhancement With the center pixel The brightness similarity weight is obtained by the grayscale difference between the pixels. The brightness similarity weight controls the similarity between the current pixel and the neighboring pixels in brightness, ensuring that no brightness values ​​other than strong contrast edges are introduced; the adjacent pixels of the welding path structure response map are calculated. With the center pixel The difference between the structural responses is used to obtain the structural similarity weight, which controls the similarity of the structural response graph. If the adjacent pixels and the central pixel are in the welding area, they trust each other, and the point is not weakened. If one of them is not in the welding area, the point is weakened to avoid background interference from being mixed in. The structure-guided bilateral filter is constructed by the brightness similarity weight and the structural similarity weight to adjust the trust in the surrounding pixels, enhance the edge clarity of the welding area, and suppress background interference. The specific calculation formula is:

[0036] ;

[0037] Where, Pixel 5×5 neighborhood area, is the brightness similarity weight, , is the structural similarity weight, , Pixels The structural response value at Pixel Gray value at ;

[0038] S52, calculation The brightness average value in the 5×5 neighborhood of the pixel is used to construct a contrast enhancement factor through the brightness average and the structural response value. The brightness contrast in the welding area is improved to make it more prominent. The specific calculation formula of the contrast enhancement factor is:

[0039] ;

[0040] Where, for The average brightness of the pixel in the 5×5 neighborhood area, ;

[0041] S53, calculation The difference between the pixel brightness and the neighborhood average brightness is then multiplied by the contrast enhancement factor, and the product is added to the welding path image after structure-guided bilateral filtering to obtain the enhanced Pixel , and finally obtain the welding path image with enhanced contrast , It is the set of all pixels of the robot welding path image after color enhancement.

[0042] Preferably, in step S5, the structure-aware contrast enhancement module can effectively suppress background noise interference while highlighting the details of the welding edge by combining brightness similarity and structural response similarity, thereby achieving accurate enhancement of the welding path image. Through the synergistic effect of local brightness mean, variance and structural response map, the welding edge details are enhanced, the clarity and structural continuity of the image are improved, the welding path is easier to identify in a low-light environment, and the enhancement results are more stable and perceptually consistent, which is suitable for industrial welding image enhancement tasks with low illumination and weak structure.

[0043] Preferably, in step S6, the specific steps of the low-light welding path image contrast enhancement model are as follows:

[0044] Input the welding path low-light image to the low-light welding path image contrast enhancement model. First, the welding path low-light image is processed to obtain a brightness map and a contrast map. The contrast perception compression factor is calculated through the brightness map and the contrast map. The contrast perception compression factor is used to perform color enhancement on the welding path low-light image in the color space conversion module to obtain a color-enhanced robot welding path image. The welding path low-light image is input to the welding path local perception module to construct a welding path structure response map. Finally, the color-enhanced robot welding path image and the welding path structure response map are fused through the structure perception contrast enhancement module to achieve accurate enhancement of the welding path low-light image and output a contrast-enhanced welding path image.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] The present invention provides a method for improving the contrast of a robot welding path image in a low-light environment, and proposes a contrast-aware compression factor to improve the original compression method based on a single brightness factor; introduces a low-light image enhancement color space based on a polar coordinate structure, and combines the contrast-aware compression factor to construct a low-light image enhancement color space with spatial decoupling capability, so as to achieve detail enhancement and color enhancement of the robot welding path image in a low-light environment; fuses directional consistency entropy and directional responsiveness to construct a welding path structure response map, and realizes explicit modeling of the continuity and directionality of the linear structure in the welding path image. Compared with traditional methods, the method can robustly extract potential welding paths under complex conditions such as texture weakening, noise interference and boundary fuzziness, and enhances the sensitivity to structural features with directionality and continuity such as welding paths; finally, the color-enhanced robot welding path image and the welding path structure response map are combined to highlight the details of the welding edge while effectively suppressing background noise interference, thereby achieving precise enhancement of the welding path image, strengthening the details of the welding edge, and improving the clarity and structural continuity of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 This is a flow chart of a method for improving the contrast of images in a low-light environment of a robot welding path provided by the present invention.

[0048] Figure 2 This is a structural diagram of the design contrast perception compression factor provided by the present invention.

[0049] Figure 3 This is a structural diagram of the color space conversion module provided by the present invention.

[0050] Figure 4 This is the welding path structure response diagram provided by the present invention.

[0051] Figure 5 This is a structural diagram of the structure-aware contrast enhancement module provided by the present invention.

[0052] Figure 6 This is a comparison chart of the contrast enhancement effect of weak-light images of welding paths provided by the present invention. DETAILED DESCRIPTION

[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0054] See also Figures 1 to 6The present invention provides a method for improving the contrast of a robot welding path in a low-light environment, and proposes a contrast-aware compression factor to improve the original compression method based on a single brightness factor; introduces a low-light image enhancement color space based on a polar coordinate structure, and combines the contrast-aware compression factor to construct a low-light image enhancement color space with spatial decoupling capability; fuses directional consistency entropy and directional responsiveness to construct a welding path structure response map, enhances the sensitivity to structural features with directionality and continuity such as welding paths, and improves the accuracy and robustness of structure extraction; by combining the color-enhanced robot welding path image and the welding path structure response map, the welding edge details are highlighted while the background noise interference is effectively suppressed, thereby achieving precise enhancement of the welding path image, strengthening the welding edge details, and improving the image clarity and structural continuity.

[0055] See Figure 1 As shown, a method for improving the contrast of a low-light environment image of a robot welding path in an embodiment of the present application.

[0056] S1. Create a welding path low-light image dataset from the robot welding path image.

[0057] Furthermore, the cost of collecting real low-light and labeled robot welding path image data is high, and the real low-light conditions are uncontrollable and the sample diversity is insufficient. A low-light image generation scheme for robot welding paths is proposed. Based on the clear welding path images, "low-light-clear" paired training samples are generated. The low-light image generation scheme specifically includes: local non-uniform brightness compression, local nonlinear color degradation and spatially correlated non-Gaussian noise superposition. Local non-uniform brightness compression simulates the coexistence of local strong light and weak light in the welding site, the complex distribution of welding arc light and surrounding shadows, and reflects the uneven brightness around the path; local non-linear color degradation simulates the color attenuation of the welding affected area and the color deviation caused by the reflectivity of different welding materials to ensure that the training samples are diverse and realistic in color; spatially correlated non-Gaussian noise superposition simulates the non-uniform noise and outliers caused by welding smoke, spatter and thermal disturbances to improve the robustness of the model to extreme interference. A dataset of 500 low-light images of the welding path is obtained with a resolution of 1280×720. The dataset of low-light images of the welding path is divided into a training set of 400 and a validation set of 100. The implementation code for generating low-light welding path images is as follows:

[0058] import cv2

[0059] import numpy as np

[0060] # Module 1: Local non-uniform brightness compression

[0061] def local_brightness_compression(image, grid_size=64, intensity_range=(0.4, 1.0)):

[0062] h, w = image.shape[:2]

[0063] mask = np.ones((h, w), dtype=np.float32)

[0064] for y in range(0, h, grid_size):# Divide the image into blocks and randomly compress the brightness of each block

[0065] for x in range(0, w, grid_size):

[0066] compression = np.random.uniform(*intensity_range) # brightness compression ratio

[0067] y_end = min(y + grid_size, h)

[0068] x_end = min(x + grid_size, w)

[0069] mask[y:y_end, x:x_end] *= compression # Applied to brightness mask

[0070] mask = cv2.GaussianBlur(mask, (0, 0), sigmaX=grid_size / 2)# Use Gaussian blur to generate a spatially continuous non-uniform brightness map

[0071] mask = np.clip(mask, 0.2, 1.0) # Prevent it from being too dark or 0

[0072] darkened = (image.astype(np.float32) * mask[..., None]).astype(np.uint8) # Apply brightness compression mask

[0073] return darkened

[0074] # Module 2: Local nonlinear color degradation

[0075] def local_color_degradation(image, grid_size=64, color_shift_range=30):

[0076] h, w = image.shape[:2]

[0077] degraded = image.astype(np.int16) # Prevent addition and subtraction operations from crossing the boundary

[0078] for y in range(0, h, grid_size):# Randomly apply RGB offset to local areas

[0079] for x in range(0, w, grid_size):

[0080] shift = np.random.randint(-color_shift_range, color_shift_range + 1, size=3) # Random color shift

[0081] y_end = min(y + grid_size, h)

[0082] x_end = min(x + grid_size, w)

[0083] degraded[y:y_end, x:x_end, :] += shift # Add to the RGB of each pixel

[0084] degraded = np.clip(degraded, 0, 255).astype(np.uint8) # limited to the image range

[0085] return degraded

[0086] # Module 3: Spatially correlated non-Gaussian noise superposition

[0087] def spatial_correlated_noise(image, noise_std=25, correlation_sigma=7):

[0088] h, w = image.shape[:2]

[0089] noise = np.random.normal(0, noise_std, (h, w, 1)).astype(np.float32) # Generate standard Gaussian noise

[0090] correlated = cv2.GaussianBlur(noise, (0, 0), sigmaX=correlation_sigma) # Gaussian blur introduces spatial correlation

[0091] noisy_image = image.astype(np.float32) + correlated

[0092] noisy_image = np.clip(noisy_image, 0, 255).astype(np.uint8)

[0093] return noisy_image

[0094] # Three stages superimposed in sequence

[0095] def generate_pseudo_weak_light(image_path, save_path=None):

[0096] image = cv2.imread(image_path)

[0097] image = cv2.resize(image, (512, 512)) # uniform size

[0098] step1 = local_brightness_compression(image)# Stage 1: Local brightness compression

[0099] step2 = local_color_degradation(step1)# Stage 2: Color shift degradation

[0100] final = spatial_correlated_noise(step2)# Stage 3: Non-Gaussian noise superposition

[0101] if save_path:

[0102] cv2.imwrite(save_path, final)

[0103] return final

[0104] if __name__ == '__main__':

[0105] input_path = 'welding_path_clear.jpg'# Input welding path clear image path

[0106] output_path = 'welding_path_pseudo_weak.jpg' # Output welding path weak light image path.

[0107] S2. Design a contrast-aware compression factor for each pixel through the brightness map and contrast map of the low-light image of the welding path, and dynamically adjust the compression strength of each pixel.

[0108] Further, if Figure 2 As shown, the specific steps for designing the contrast perception compression factor are as follows.

[0109] S21. Input the low-light image of the welding path into the contrast perception compression module. First, the low-light image is normalized and the brightness map is extracted. The brightness map is obtained by the maximum value of the three RGB channels in the normalized low-light image. ,in, is any pixel in the image, Pixels The brightness value at , is the set of all pixel points of the weak light image of the welding path, The brightness map.

[0110] S22, using the sliding window method, calculate the local brightness contrast of each pixel on the brightness map, and define the pixel Neighborhood area , , the initial value is set to 3, the value is determined by the brightness of the brightness map, the higher the brightness, the larger the value of c is, the better the pixel Take the pixel value in its neighborhood and calculate the brightness difference in the neighborhood , , for Pixels in the neighborhood, , taking the maximum difference as the contrast value , Pixels The contrast value at the point is used to construct a contrast map. , For contrast map, the implementation code for contrast map generation is:

[0111] import cv2

[0112] import numpy as np

[0113] def compute_contrast_map(gray_img, c=3):#Calculate the local brightness contrast map according to the specified window size k

[0114] assert isinstance(c, int) and c>= 3 #window size c should be an integer, c can be 3, 4, 5

[0115] gray = gray_img.astype(np.float32)

[0116] h, w = gray.shape

[0117] pad = c / / 2

[0118] #Calculate the maximum value I_max(x) within the c×c neighborhood of each pixel

[0119] I_max = np.zeros_like(gray)

[0120] for i in range(pad, h - pad):

[0121] for j in range(pad, w - pad):

[0122] local_patch = gray[i - pad:i + pad + 1, j - pad:j + pad +1]

[0123] I_max[i, j] = np.max(local_patch)

[0124] #Calculate Δ(x) = max |I_max(x) - I_max(r)|, r ∈ N(x)

[0125] contrast_map = np.zeros_like(gray)

[0126] for i in range(pad, h - pad):

[0127] for j in range(pad, w - pad):

[0128] I_x = I_max[i, j]# Maximum brightness of the neighborhood of the current pixel

[0129] neighbors = I_max[i - pad:i + pad + 1, j - pad:j + pad +1]

[0130] delta = np.abs(I_x - neighbors)

[0131] contrast_map[i, j] = np.max(delta)

[0132] return contrast_map.

[0133] S23, calculate the contrast perception compression factor for each pixel through the brightness map and the contrast map, the contrast perception compression factor corresponding to the pixel point x The specific calculation formula is:

[0134] ;

[0135] Where, is the contrast adjustment weight parameter, , the value range is , the initial value is set to 0.5, which controls the impact of contrast in compression. Neighborhood area The average brightness of k is the compression coefficient, and the value range is , the initial value is set to 1, When the enhancement is too weak, the overall image is dark and the contrast improvement is not obvious. When the contrast is over-enhanced, the image may be overexposed, with loss of details or color bleaching. The larger the contrast perception compression factor, the weaker the overall compression strength, which allows the pixel to maintain a higher brightness value and enhance its significance. The smaller the contrast perception compression factor, the stronger the compression strength, which pushes the pixel to the dark part and reduces its visual interference.

[0136] S3. Introduce a low-light image enhancement color space based on a polar coordinate structure, construct a color space conversion module, convert the RGB image into an HSV image, decompose the color saturation into two orthogonal axes through the HSV image and the contrast perception compression factor, and obtain a low-light welding path image enhancement color space. After the inverse transformation module, it is restored to an RGB image and the color-enhanced welding path image is output.

[0137] Furthermore, if Figure 3 As shown, the specific steps of the color space conversion module are as follows.

[0138] S31, convert the RGB value of each pixel in the welding path low-light image into HSV value, and normalize the red, green and blue channel values ​​of each pixel to The maximum and minimum values ​​are calculated, and the hue H and saturation S are calculated by the maximum and minimum values, and the color information is separated into the HSV form that is more in line with human perception. The brightness V is obtained by the brightness map. Indicates that the implementation code for calculating hue H and saturation S is:

[0139] import numpy as np

[0140] class RGB2HSVConverter:

[0141] def __init__(self):

[0142] pass

[0143] def convert(self, rgb_img):

[0144] rgb = rgb_img.astype('float32') / 255.0 # Normalize RGB values ​​to [0,1]

[0145] r, g, b = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]

[0146] c_max = np.maximum.reduce([r, g, b]) # Calculate the maximum and minimum values ​​of each pixel

[0147] c_min = np.minimum.reduce([r, g, b])

[0148] delta = c_max - c_min

[0149] H = np.zeros_like(c_max) # Initialize HSV channel

[0150] S = np.zeros_like(c_max)

[0151] mask = delta != 0

[0152] idx_r = (c_max == r)&mask

[0153] idx_g = (c_max == g)&mask

[0154] idx_b = (c_max == b)&mask

[0155] H[idx_r] = 60 * ((g[idx_r]- b[idx_r]) / delta[idx_r]) % 360 #Calculate the H value in degrees, range [0,360)

[0156] H[idx_g] = 60 * ((b[idx_g]- r[idx_g]) / delta[idx_g]) + 120

[0157] H[idx_b] = 60 * ((r[idx_b]- g[idx_b]) / delta[idx_b]) + 240

[0158] S[c_max != 0] = delta[c_max != 0] / c_max[c_max != 0] #Calculate saturation S

[0159] return H, S.

[0160] S32. Project the hue H onto the unit circle to obtain the horizontal component after polarization and vertical component , , , To normalize the hue and project it onto Within the range, ensure the stability of angle representation, combined with the saturation S and contrast perception compression factor in the HSV map Generate polarized color channels and , is the horizontal color response, , is the color response in the vertical direction, , is the color saturation value of pixel x. By polarizing the color channel, the color saturation is decomposed into two orthogonal axes (horizontal and vertical directions). 、 and brightness map Constructing welding path low-light image enhancement color space , enhancing spatial separation and geometric processing capabilities.

[0161] S33, the inverse transformation module remaps the polar coordinates into angle form, through and Constructed as the hue of the enhanced HSV map and saturation , , is the inverse tangent function, , which will enhance the hue of the HSV image and saturation and brightness graph Integrated enhanced HSV robot welding path image , use the standard HSV to RGB conversion process to convert the enhanced HSV welding path image into an enhanced RGB welding path image, use the cv2.cvtColor function in the OpenCV library to complete the HSV image to RGB image, and output the color enhanced welding path image .

[0162] S4. A local structure perception mechanism based on direction difference vector is introduced to construct a welding path local perception module, and the direction responsiveness and direction consistency entropy are weightedly fused to obtain the welding path structure response map.

[0163] Further, if Figure 4 As shown in the figure, the welding path structure response diagram is shown, and the specific steps of the welding path local perception module are as follows.

[0164] S41. Input the welding path low-light image to the welding path local perception module, use a 9×9 sliding window to build a direction neighborhood for each pixel, which is used to calculate the direction consistency and coherence around the pixel, and set a set of direction sets. , , for each direction , defining pixels Two adjacent points in this direction and ,in, is the point one step forward in the current direction, , is the point two steps forward in the current direction, , calculate the grayscale difference between two segments through the grayscale values ​​of adjacent points, , , Pixel The grayscale value at the position is obtained by the grayscale difference between the two segments to obtain the direction difference vector in that direction. , calculate the direction difference vector of each direction in the direction set, and construct the direction perception information vector , used for the calculation of total directional responsiveness and directional response distribution, the directional perception information vector does not directly participate in the calculation, but the data in the directional perception information vector is used in the calculation process.

[0165] S42. Calculate the average intensity of the grayscale difference in each direction , calculate the total responsiveness of the direction corresponding to pixel x in the weak light image of the welding path according to the average intensity of the grayscale value in all directions The total directional response reflects the degree of brightness change of pixel x; by calculating the ratio of the average intensity of the current direction to the total average intensity of all directions, the average intensity of all directions is normalized into a probability distribution to obtain the directional response distribution , based on the Shannon entropy definition, the directional consistency entropy of pixel x in the low-light image of the welding path is calculated ,Directional consistency entropy measures the degree of discreteness of directional distribution.,A high entropy value indicates that the directional response is evenly distributed,which is the background area. A low entropy value indicates that the pixel occupies the dominant direction,which is a coherent structure.

[0166] S43. The directional total responsivity and directional consistency entropy of the integrated welding path weak light image are used to define the final structural score. The directional responsivity at pixel x and the directional consistency entropy at pixel x are weightedly fused to construct the final structural score at pixel x. The higher the final structure score, the more likely the point is to be in the continuous structure area. The value of the structure response map at pixel x is obtained by the final structure score. , the structural response diagram of the entire welding path is .

[0167] S5. Structure-guided bilateral filtering and contrast enhancement factor are proposed to construct a structure-aware contrast enhancement module. The color-enhanced welding path image and the welding path structure response map are fused to obtain a contrast-enhanced welding path image.

[0168] Furthermore, if Figure 5 As shown in Figure 2, the specific steps of the structure-aware contrast enhancement module are as follows.

[0169] S51, input color enhanced welding path image and welding path structure response diagram , for the pixels at the same position in the color enhanced robot welding path image and the welding path structure response map , select a 5×5 pixel area centered on the pixel, and the area contains Adjacent pixels are recorded as , by calculating the adjacent pixels of the robot welding path image after color enhancement With the center pixel The brightness similarity weight is obtained by the grayscale difference between the pixels. The brightness similarity weight controls the similarity between the current pixel and the neighboring pixels in brightness, ensuring that no brightness values ​​other than strong contrast edges are introduced; the adjacent pixels of the welding path structure response map are calculated. With the center pixel The difference between the structural responses is used to obtain the structural similarity weight, which controls the similarity of the structural response graph. If the adjacent pixels and the central pixel are in the welding area, they trust each other, and the point is not weakened. If one of them is not in the welding area, the point is weakened to avoid background interference from being mixed in. The structure-guided bilateral filter is constructed by the brightness similarity weight and the structural similarity weight to adjust the trust in the surrounding pixels, enhance the edge clarity of the welding area, and suppress background interference. The specific calculation formula is:

[0170] ;

[0171] Where, Pixel 5×5 neighborhood area, is the brightness similarity weight, , is the structural similarity weight, , Pixels The structural response value at Pixel The gray value at .

[0172] S52, calculation The brightness average value in the 5×5 neighborhood of the pixel is used to construct a contrast enhancement factor through the brightness average and the structural response value. The brightness contrast in the welding area is improved to make it more prominent. The specific calculation formula of the contrast enhancement factor is:

[0173] ;

[0174] Where, for The average brightness of the pixel in the 5×5 neighborhood area, .

[0175] S53, calculation The difference between the pixel brightness and the neighborhood average brightness is then multiplied by the contrast enhancement factor, and the product is added to the welding path image after structure-guided bilateral filtering to obtain the enhanced Pixel , and finally obtain the welding path image with enhanced contrast , It is the set of all pixels of the robot welding path image after color enhancement.

[0176] S6. Integrate the color space conversion module, the welding path local perception module, and the structure perception contrast enhancement module to build a low-light welding path image contrast enhancement model, input the welding path low-light image into the model, and output the contrast-enhanced welding path image.

[0177] Furthermore, in step S6, the weak-light image of the welding path is input into the weak-light welding path image contrast enhancement model. First, the weak-light image of the welding path is processed to obtain a brightness map and a contrast map. The contrast perception compression factor is calculated through the brightness map and the contrast map. The contrast perception compression factor is used to perform color enhancement on the weak-light image of the welding path in the color space conversion module to obtain a color-enhanced robot welding path image. The weak-light image of the welding path is input into the welding path local perception module to construct a welding path structure response map. Finally, the color-enhanced robot welding path image and the welding path structure response map are fused through the structure perception contrast enhancement module to achieve precise enhancement of the weak-light image of the welding path, and output a contrast-enhanced welding path image. The weak-light welding path image contrast enhancement model is based on the Pytorch framework and is implemented through the Pycharm application. The model is trained using 400 training images in the welding path weak-light image dataset, and the trained model is verified on 100 validation sets.

[0178] Further, if Figure 6 As shown in the figure, a comparison of the enhancement effect of the low-light welding path image contrast enhancement model is shown. The left figure is the original low-light image of the welding path, and the right figure is the low-light image of the welding path after being processed by the low-light welding path image contrast enhancement model. This model significantly enhances the contrast and clarity of the low-light image of the welding path.

[0179] The above are only preferred embodiments of the present invention. It should be pointed out that those skilled in the art can make several modifications and improvements without departing from the inventive concept of the present invention, and these all fall within the scope of protection of the present invention.

Claims

1. A method for improving the contrast of a robot welding path image in a low-light environment, characterized in that: The following steps are involved: S1. Create a welding path low-light image dataset from the robot welding path image; S2. Design a contrast-aware compression factor for each pixel based on the brightness map and contrast map of the low-light image of the welding path, and dynamically adjust the compression strength of each pixel; The specific steps for designing the contrast perception compression factor are: S21. Input the low-light image of the welding path into the contrast perception compression module. First, the low-light image is normalized and the brightness map is extracted. The brightness map is obtained by the maximum value of the three RGB channels in the normalized low-light image. ,in, is any pixel in the image, Pixel The brightness value at , is the set of all pixel points of the weak light image of the welding path, is the brightness map; S22, using the sliding window method, calculate the local brightness contrast of each pixel on the brightness map and define the pixel point Neighborhood area , , for pixels Take the pixel value in its neighborhood and calculate the brightness difference in the neighborhood , , for Pixels in the neighborhood, , taking the maximum difference as the contrast value , Pixel The contrast value at the point is used to construct a contrast map. , is a contrast map; S23, calculate the contrast perception compression factor for each pixel through the brightness map and contrast map, pixel point The corresponding contrast perception compression factor The specific calculation formula is: ; Where, is the contrast adjustment weight parameter, k is the compression coefficient; S3. Introduce a low-light image enhancement color space based on a polar coordinate structure, build a color space conversion module, convert the RGB image into an HSV image, decompose the color saturation into two orthogonal axes using the HSV image and the contrast perception compression factor, and obtain the welding path low-light image enhancement color space. After the inverse transformation module, restore it to an RGB image and output the color-enhanced welding path image. S4. Introduce a local structure perception mechanism based on direction difference vectors and construct a welding path local perception module. The welding path local perception module weightedly fuses the direction responsivity and direction consistency entropy of the welding path low-light image to obtain the welding path structure response map. S5. Structure-guided bilateral filtering and contrast enhancement factors are proposed to build a structure-aware contrast enhancement module. The color-enhanced welding path image and the welding path structure response map are fused through the structure-aware contrast enhancement module to obtain a contrast-enhanced welding path image. S6. Integrate the color space conversion module, the welding path local perception module, and the structure perception contrast enhancement module to build a low-light welding path image contrast enhancement model, input the welding path low-light image into the model, and output the contrast-enhanced welding path image.

2. The method for improving the contrast of a robot welding path image in a low-light environment according to claim 1, characterized in that: In step S1, the cost of collecting real low-light and labeled robot welding path image data is high, the real low-light conditions are uncontrollable, and the sample diversity is insufficient. A low-light image generation scheme for the robot welding path is proposed. "Weak-light-clear" paired training samples are generated based on clear welding path images. The low-light image generation scheme specifically includes: local non-uniform brightness compression, local non-linear color degradation, and spatially correlated non-Gaussian noise superposition. Local non-uniform brightness compression simulates the coexistence of local strong light and weak light at the welding site, the complex distribution of welding arc light and surrounding shadows, and reflects the uneven brightness around the path; local non-linear color degradation simulates the color attenuation of the welding affected area and the color deviation caused by the reflectivity of different materials; spatially correlated non-Gaussian noise superposition simulates the non-uniform noise and abnormal points caused by welding smoke, spatter, and thermal disturbances, to obtain a welding path low-light image dataset, which is divided into a training set and a validation set.

3. The method for improving the contrast of a robot welding path image in a low-light environment according to claim 2, characterized in that: In step S3, the color space conversion module specifically performs the following steps: S31, convert the RGB value of each pixel in the welding path low-light image into HSV value, and normalize the red, green and blue channel values ​​of each pixel to Interval, calculate the maximum and minimum values, calculate the hue H and saturation S through the maximum and minimum values, and separate the color information into the HSV form that is more in line with human perception; S32. Project the hue H onto the unit circle to obtain the horizontal component after polarization and vertical component , , , Pixel The hue value, combined with the saturation S and contrast perception compression factor in the HSV map Generate polarized color channels and , Polarization color channel At the pixel The horizontal color response, , Polarization color channel At the pixel is the vertical color response, , Pixel The color saturation value of the polarized color channel is decomposed into two orthogonal axes. 、 and brightness map Constructing welding path low-light image enhancement color space ; S33, the inverse transformation module remaps the polar coordinates into angle form, through and Constructed as the hue of the enhanced HSV map and saturation , , , which will enhance the hue of the HSV image and saturation and brightness graph Integrated enhanced HSV robot welding path image , use the standard HSV to RGB conversion process to convert the enhanced HSV welding path image into an enhanced RGB welding path image, and output the color enhanced welding path image .

4. The method for improving the contrast of a robot welding path image in a low-light environment according to claim 3, characterized in that: In step S4, the specific steps of the welding path local perception module are as follows: S41, input the welding path low-light image to the welding path local perception module, use a 9×9 sliding window to build a direction neighborhood for each pixel, and set a set of direction sets , , for each direction , define pixel points Two adjacent points in this direction and ,in, is the point one step forward in the current direction, , is the point two steps forward in the current direction, , calculate the grayscale difference between two segments through the grayscale values ​​of adjacent points, , , Pixel The grayscale value at the position is obtained by the grayscale difference between the two segments to obtain the direction difference vector in that direction. , calculate the direction difference vector of each direction in the direction set, and construct the direction perception information vector ; S42. Calculate the average intensity of the grayscale difference in each direction , calculate the pixel points in the weak light image of the welding path based on the average intensity of the gray value in all directions The corresponding total responsiveness of the direction , the total directional response reflects the pixel The degree of brightness change; by calculating the ratio of the average intensity of the current direction to the total average intensity of all directions, the average intensity of all directions is normalized into a probability distribution to obtain the direction response distribution , based on the Shannon entropy definition, the pixel points in the weak light image of the welding path are calculated Directional consistency entropy ,Directional consistency entropy measures the degree of discreteness of directional distribution.,A high entropy value indicates that the directional response is evenly distributed,which is the background area. A low entropy value indicates that the pixel occupies the dominant direction,which is a coherent structure. S43, the directional total response and directional consistency entropy of the comprehensive welding path weak light image are used to define the final structure score. The pixel point is constructed by weighted fusion of directional response and directional consistency entropy Final structural score at , the structural response map is obtained at the pixel point through the final structural score The value at , is the set of all pixel points of the weak light image of the welding path, and the structural response diagram of the entire welding path is .

5. The method for improving the contrast of a robot welding path image in a low-light environment according to claim 4, characterized in that: In step S5, the structure-aware contrast enhancement module specifically performs the following steps: S51, input color enhanced welding path image and welding path structure response diagram , for the pixel points at the same position in the color enhanced robot welding path image and the welding path structure response map , select a 5×5 pixel area centered on the pixel, and the area contains the pixel point Adjacent pixels are recorded as , by calculating the adjacent pixels of the robot welding path image after color enhancement With the center pixel The brightness similarity weight is obtained by the grayscale difference between the two pixels, and the brightness similarity weight controls the similarity in brightness between the current pixel and the neighboring pixels; Calculate adjacent pixels of welding path structure response map With the center pixel The difference between the structural responses is used to obtain the structural similarity weight, which controls the similarity of the structural response map. The structure-guided bilateral filter is constructed by the brightness similarity weight and the structural similarity weight to adjust the trust in the surrounding pixels. The specific calculation formula is: ; Where, Pixel 5×5 neighborhood area, is the brightness similarity weight, , is the structural similarity weight, , Pixel The structural response value at Pixels Gray value at ; S52, calculation The brightness average value in the 5×5 neighborhood of the pixel is used to construct the contrast enhancement factor by using the brightness average value and the structural response value. The specific calculation formula of the contrast enhancement factor is: ; Where, for The average brightness of the pixel in the 5×5 neighborhood area, ; S53, calculation The difference between the pixel brightness and the neighborhood average brightness is then multiplied by the contrast enhancement factor, and the product is added to the welding path image after structure-guided bilateral filtering to obtain the enhanced Pixel , and finally obtain the welding path image with enhanced contrast , It is the set of all pixels of the robot welding path image after color enhancement.

Citation Information

Patent Citations

  • Multi-scale gradient domain guided filtering low-illumination image enhancement algorithm

    CN110111280A

  • Image processing method and system

    CN112348760A