Image defogging method and system
By segmenting the image into blocks, extracting RGB vectors and constructing a fitting matrix, and combining 3D Hough transform and adaptive compensation coefficients, the problem of inaccurate determination of atmospheric illumination values in existing methods is solved, achieving a high-precision image dehazing effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUZHOU CITY UNIV
- Filing Date
- 2025-12-03
- Publication Date
- 2026-04-17
AI Technical Summary
Existing physical model-based image dehazing methods rely solely on simple statistical quantities such as mean and maximum brightness to determine atmospheric illumination values, ignoring the directional correlation of the RGB three channels, resulting in poor accuracy of dehazed images.
By dividing the image to be dehazed into blocks, extracting the RGB vectors within each block region, constructing an initial fitting matrix, filtering effective pixels, obtaining atmospheric illumination values using the fused feature matrix and 3D Hough transform, and optimizing transmittance through median filtering and adaptive compensation coefficients, a dehazed image is generated.
It improves the accuracy and realism of dehazed images, reduces computational load, avoids noise interference, and ensures the naturalness and accuracy of the dehazing effect.
Smart Images

Figure CN121258845B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more particularly to an image dehazing method and system. Background Technology
[0002] The research and development of image dehazing technology aims to solve the problem of reduced visual information caused by fog. The scattering of light by tiny water droplets in fog impairs image acquisition, resulting in information loss and reduced brightness, contrast, and overall visibility. These factors severely impact the performance of image processing systems. The core objective of image dehazing technology is to recover a clear and visible image from fog-affected images. In safety-sensitive applications, such as intelligent transportation systems, suspended water droplets in the atmosphere significantly reduce a driver's ability to visually assess road conditions ahead through vehicle windows, increasing potential driving risks. Image dehazing technology not only improves image quality but, more importantly, ensures the accuracy and usability of image information, thereby supporting relevant systems in making effective decisions.
[0003] Currently, the main dehazing methods are divided into non-physical model-based methods and physically-based methods. Non-physical model-based methods primarily focus on image enhancement, improving the visual effect of images by adjusting parameters such as brightness, contrast, and sharpness. These methods are computationally efficient, but because they do not consider the causes of image degradation, they often suffer from overexposure and loss of detail, making true dehazing difficult. In contrast, physically-based methods construct atmospheric scattering models to characterize the degradation mechanism of foggy images and combine prior knowledge or image depth information to estimate key parameters such as transmission maps and atmospheric light intensity, thereby restoring a clear image. These methods have a solid theoretical foundation and good restoration results; however, in practical applications, the model parameter estimation process is complex and prone to bias, thus affecting the final image quality.
[0004] However, existing physical model-based image dehazing methods typically use the maximum, average, or pixel values selected by preset rules within a region as atmospheric illumination values. These methods rely solely on brightness information and ignore the directional correlation of the RGB three channels, making it difficult to accurately capture the dominant color trend within a region. This results in atmospheric illumination values being prone to deviation in complex scenes (such as areas with multiple light sources or mixed colors), failing to accurately reflect the true atmospheric light characteristics of each block. Summary of the Invention
[0005] Therefore, the technical problem to be solved by the present invention is to overcome the shortcomings of existing physical model-based image dehazing methods, which rely only on simple statistical quantities such as the mean and maximum brightness to determine the atmospheric illumination value, ignoring the directional correlation of the RGB three channels, resulting in poor accuracy of the dehazed image.
[0006] To address the aforementioned technical problems, this invention provides an image dehazing method, comprising:
[0007] The image to be dehazed is divided into blocks to obtain multiple block regions. For each block region, the RGB value of each pixel in the block region and the direction vector of the origin are extracted as the RGB vector of each pixel in the block region, and multiple pixels are randomly selected as target pixels.
[0008] Fit the RGB vectors of all target pixels in each block region to obtain the initial fitting matrix for each block region;
[0009] The effective pixels of each block region are obtained by filtering based on the inner product of the RGB vector of each pixel in each block region and the initial fitting matrix of that block region.
[0010] The effective pixels of each block region are fitted to obtain the optimized direction matrix of each block region;
[0011] The average brightness value and optimized orientation matrix of each block region are combined to obtain the fusion feature matrix of each block region;
[0012] Based on the fusion feature matrix of each block region, the atmospheric illumination value of each block region is obtained; based on the atmospheric illumination value and transmittance of each block region, a dehazed image is generated.
[0013] Preferably, the method of fitting the RGB vectors of all target pixels in each segmented region to obtain the initial fitting matrix for each segmented region includes:
[0014] The RGB vectors of all target pixels in each block region are fitted to obtain the total RGB vector of each block region;
[0015] Based on the angles between the total RGB vector of each block region and the R-axis, G-axis, and B-axis, an initial fitting matrix is constructed for each block region.
[0016] Preferably, the initial fitting matrix for each segmented region is:
[0017] ,
[0018] in, Let represent the initial fitting matrix of the block region in the i-th row and j-th column. Let be the angle between the total RGB vector of the block region in the i-th row and j-th column and the R-axis. Let G be the angle between the total RGB vector of the block region in the i-th row and j-th column and the G-axis. Let be the angle between the total RGB vector of the block region in row i and column j and the B-axis, where i is the row index of the block region and j is the column index of the block region.
[0019] Preferably, the method for obtaining the atmospheric illumination value of each block region based on the fusion feature matrix of each block region includes:
[0020] The fusion feature matrix of each block region is clustered in orientation using 3D Hough transform to obtain the set of orientation parameters for each block region;
[0021] For each block region, the parameter points with the same direction in the direction parameter set are accumulated, and the direction corresponding to the parameter point with the largest accumulated value is taken as the atmospheric illumination value of that block region.
[0022] Preferably, the process of obtaining the transmittance of each segmented region includes:
[0023] For each block region, a pixel is randomly selected as the transmission pixel of that block region;
[0024] Based on the pixel difference between the transmitted pixels and each pixel in each block region, the set of transmitted pixels in each block region is obtained by filtering.
[0025] Median filtering is applied to the set of transmitted pixels in each block region. Based on the correction coefficient, the atmospheric illumination value of each block region, and the median filtering result, the initial transmittance of each block region is calculated.
[0026] The initial transmittance of each segment is compensated by the compensation coefficient of each segment, thus obtaining the transmittance of each segment.
[0027] Preferably, the initial transmittance of each segmented region is compensated using a compensation coefficient to obtain the transmittance of that region, as shown in the formula:
[0028] ,
[0029] ,
[0030] in, Let be the transmittance of the block region in the i-th row and j-th column. Let be the initial transmittance of the block region in the i-th row and j-th column. Let be the compensation coefficient for the block region in the i-th row and j-th column. The threshold value for transmittance compensation is the threshold value for the block region in the i-th row and j-th column, where i is the row index of the block region and j is the column index of the block region.
[0031] Preferably, the formula for generating the dehazed image based on the atmospheric illumination value and transmittance of each segmented region is:
[0032] ,
[0033] in, Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the dehazed image. Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the image to be dehazed. Let be the transmittance of the block region in the i-th row and j-th column. Let i be the atmospheric illumination value of the block region in the i-th row and j-th column, where i is the row index of the block region and j is the column index of the block region.
[0034] Preferably, the method for dividing the image to be dehazed into blocks to obtain multiple block regions includes:
[0035] The image to be dehazed is converted into a grayscale image. Multiple starting pixels are evenly set in the grayscale image. With each starting pixel as the center, the image is gradually expanded to its neighborhood along the horizontal, vertical, and diagonal directions. For each pixel expansion, the brightness difference between the current pixel and the previous pixel is calculated. When the brightness difference of N consecutive pixels exceeds a set threshold, the endpoint of the sequence of N consecutive pixels is taken as the boundary of the region in the corresponding direction. Here, N is the set minimum number of pixels.
[0036] Based on the region boundaries in all directions, multiple initial block regions are obtained;
[0037] Based on the Weber contrast of each initial block region, each initial block region is segmented to generate multiple block regions.
[0038] Preferably, the method for segmenting each initial block region based on the Weber contrast of each initial block region to generate multiple block regions includes:
[0039] For each initial block region, determine whether the Weber contrast of the initial block region is greater than or equal to the set Weber contrast threshold. If it is greater than or equal to the threshold, then recursively divide the initial block region to obtain multiple sub-block regions.
[0040] Repeat the above judgment for each sub-block region obtained after segmentation. If the Weber contrast of the sub-block region is greater than or equal to the set Weber contrast threshold, continue to recursively segment until all sub-block regions meet any termination condition. The termination conditions include: the Weber contrast of the sub-block regions is lower than the set Weber contrast threshold, the total number of pixels in the sub-block regions is equal to the set minimum number of pixels, or the total number of sub-block regions is equal to the set total number of regions threshold.
[0041] All sub-block regions that meet the termination condition are designated as block regions.
[0042] The present invention also provides an image dehazing system, comprising:
[0043] A memory for storing computer programs; a processor for executing the computer programs to implement the steps of the image dehazing method described above.
[0044] Compared with the prior art, the above-described technical solution of the present invention has the following advantages:
[0045] The image dehazing method and system described in this invention extracts the direction vectors of each pixel's RGB values relative to the origin after dividing the image to be dehazed into blocks. The target pixel's RGB vector is then fitted into an initial fitting matrix containing the angle parameters between the RGB axes, enabling in-depth mining of color direction features within the blocks. This avoids the color correlation loss problem caused by existing block-segmentation methods relying solely on simple statistical quantities such as average and maximum brightness. Next, effective pixels are filtered by the inner product of the pixel's RGB vector and the initial fitting matrix to eliminate noise interference. Finally, based on the fused feature matrix, a 3D Hough transform is used to cluster and accumulate the direction parameters. This not only accurately captures the dominant atmospheric light direction of each block through direction consistency quantification but also replaces complex global calculations with cluster accumulation, reducing computational load while ensuring the accuracy of atmospheric illumination value extraction. Ultimately, combined with transmittance, a dehazed image with higher accuracy and details more closely matching the real scene is generated.
[0046] Furthermore, current physical model-based image dehazing methods rely on the dark channel theory in their transmittance estimation algorithms. This theory assumes that a color channel value close to 0 exists in a local area of a fog-free outdoor image. While this assumption aligns with the texture and lighting characteristics of objects in a fog-free environment, atmospheric scattering of fog disrupts this assumption when the scene is foggy. This causes the core assumption of the dark channel theory to fail, resulting in the calculated transmittance failing to accurately reflect the degree of light attenuation caused by fog, leading to an excessive underestimation. To address this, median filtering is applied to the selected pixel set. The median value of the pixels within this set is assigned to the center pixel of the window, resulting in a segmented median-filtered image. The noise-resistant properties of median filtering optimize the basic data, providing a more accurate input for transmittance calculation. Next, a correction coefficient is introduced into the transmittance calculation. The segmented transmittance is calculated by subtracting the correction coefficient from the filtered result and then using the ratio of the segmented atmospheric illumination value to avoid excessive attenuation of transmittance due to calculation errors based on fundamental assumptions. To address the issue of underestimated transmittance in bright areas, an adaptive compensation mechanism is further designed. By using compensation coefficient parameters, transmittance is improved, accurately correcting overexposure distortion in bright areas. This makes the transmittance more closely match the actual attenuation law of light by fog, ensuring a natural and realistic defogging effect and effectively improving the accuracy of the defogging image. Attached Figure Description
[0047] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:
[0048] Figure 1 This is a flowchart of the steps of an image dehazing method according to the present invention.
[0049] Figure 2 This is a schematic flowchart of an image dehazing method according to the present invention.
[0050] Figure 3 This is a flowchart of the process for obtaining the optimized direction matrix.
[0051] Figure 4 This is a flowchart of the process for obtaining atmospheric illumination values.
[0052] Figure 5 This is a flowchart of the process for obtaining transmittance. Detailed Implementation
[0053] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0054] Reference Figure 1 , Figure 2 As shown, this embodiment provides an image dehazing method, including:
[0055] like Figure 3 As shown, Figure 3 The flowchart for optimizing the acquisition of the direction matrix is shown below.
[0056] Step S1: Divide the image to be dehazed into blocks to obtain multiple block regions;
[0057] Existing methods for processing hazy images often employ fixed-size image partitioning. This partitioning approach is not only unscientific but also prone to resulting in an excessive number of partitions, significantly increasing computational complexity. This invention addresses the problems of high computational cost and low efficiency in current image dehazing algorithms by proposing an adaptive partitioning method, the specific scheme of which is as follows:
[0058] In this embodiment, preferably, the step of dividing the image to be dehazed into blocks to obtain multiple block regions includes:
[0059] The image to be dehazed is converted into a grayscale image. Multiple starting pixels are evenly set in the grayscale image. With each starting pixel as the center, the image is gradually expanded to its neighborhood along the horizontal, vertical, and 45° and 135° diagonal directions. For each pixel expansion, the brightness difference between the current pixel and the previous pixel is calculated. When the brightness difference of N consecutive pixels exceeds a set threshold, the endpoint of the sequence of N consecutive pixels is taken as the boundary of the region in the corresponding direction. Here, N is the set minimum number of pixels.
[0060] Based on the region boundaries in all directions, multiple initial block regions are obtained;
[0061] Based on the Weber contrast of each initial block region, each initial block region is segmented to generate multiple block regions, including:
[0062] The process involves segmenting each initial block region based on its Weber contrast, generating multiple block regions, including:
[0063] For each initial block region, determine whether the Weber contrast of the initial block region is greater than or equal to the set Weber contrast threshold. If it is greater than or equal to the threshold, then recursively divide the initial block region to obtain multiple sub-block regions.
[0064] Repeat the above judgment for each sub-block region obtained after segmentation. If the Weber contrast of the sub-block region is greater than or equal to the set Weber contrast threshold, continue to recursively segment until all sub-block regions meet any termination condition. The termination conditions include: the Weber contrast of the sub-block regions is lower than the set Weber contrast threshold, the total number of pixels in the sub-block regions is equal to the set minimum number of pixels, or the total number of sub-block regions is equal to the set total number of regions threshold.
[0065] All sub-block regions that meet the termination condition are designated as block regions.
[0066] In this embodiment, 64 starting pixels are uniformly set in the grayscale image, the minimum number of pixels N is set to 32, the threshold is set to 20% of the difference between the highest and lowest brightness values of the grayscale image, the minimum number of pixels is set to 512, and the total number of regions is set to a threshold. The value is 4096.
[0067] Starting from the initial pixel, the scan proceeds outwards, stopping when a significant brightness change is encountered at a boundary. The boundary is determined by a change in brightness exceeding 20% of the difference between the brightest and darkest pixels in 32 consecutive pixels. This boundary is used to segment the bright and dark areas and obtain the dividing lines. These lines then divide the image into several larger bright and dark areas.
[0068] Within each bright and dark area, further detailed subdivisions are performed. The subdivision algorithm can be expressed by the following formula:
[0069] ,
[0070] in, For a set of partitioned regions, For any block region, For pixel gradient, For block regions Weber contrast, ,in, For block regions The target brightness, For block regions Background brightness, To set the Weber contrast threshold, i.e., the smallest granularity.
[0071] The smaller the value, the more sensitive the algorithm is to contrast changes within the region, resulting in more segmented regions and smaller individual region sizes. The larger the value, the more likely segmentation will be triggered only when the contrast difference between regions is significant. The resulting number of segmented regions is smaller and the size of each region is larger. The appropriate T value can be determined through experimental optimization to balance segmentation accuracy and computational efficiency.
[0072] For a specific dataset, the optimal fit can be determined through experimental optimization. The value is determined to balance segmentation accuracy and computational efficiency.
[0073] This invention partitions photos using an adaptive partitioning strategy, dividing them into blocks based on the rate of change in image pixel brightness and contrast. This allows images with similar content (such as the sky) to be grouped into a single region, significantly reducing the number of partitions. Furthermore, this invention incorporates a preprocessing step, filtering pixel data in each region and retaining only the most representative data in each partition. This greatly reduces the amount of data that needs to be calculated and significantly improves the efficiency of data processing.
[0074] Step S2: For each segmented region, extract the RGB value of each pixel in the RGB 3D coordinate system and the direction vector of the origin, and use it as the RGB vector of each pixel in the segmented region. Randomly select multiple pixels as target pixels. In this embodiment, the number of randomly selected pixels is the set minimum number of pixels.
[0075] In the field of image processing, the RGB values of a pixel naturally constitute coordinate points in three-dimensional space. The brightness values of the three channels R, G, and B of a pixel (usually 0-255) correspond to the x-axis (R-axis), y-axis (G-axis), and z-axis (B-axis) of the three-dimensional coordinate system, respectively. Each pixel can be uniquely represented as a coordinate point (R, G, B) in this coordinate system. Therefore, the RGB value of each pixel and the direction vector of the origin are the vectors pointing from the origin (0, 0, 0) of the RGB three-dimensional coordinate system to the coordinate point (R, G, B) of that pixel.
[0076] Step S3: Fit the RGB vectors of all target pixels in each block region to obtain the initial fitting matrix for each block region;
[0077] In this embodiment, preferably, the RGB vectors of all target pixels in each block region are fitted using a RANSAC robust model to obtain an initial fitting matrix for each block region. The initial fitting matrix for each block region is a third-order matrix, comprising:
[0078] Fit the RGB vectors of all target pixels in each block region, that is, sum the RGB vectors of all target pixels in each block region to obtain the total RGB vector of each block region.
[0079] Based on the angles between the total RGB vector of each block region and the R-axis, G-axis, and B-axis, an initial fitting matrix is constructed for each block region. The initial fitting matrix for each block region is as follows:
[0080] ,
[0081] in, Let represent the initial fitting matrix of the block region in the i-th row and j-th column. Let be the angle between the total RGB vector of the block region in the i-th row and j-th column and the R-axis. Let G be the angle between the total RGB vector of the block region in the i-th row and j-th column and the G-axis. Let be the angle between the total RGB vector of the block region in row i and column j and the B-axis, where i represents the row index of the block region and j represents the column index of the block region.
[0082] The angle between the total RGB vector of each block region and the R-axis, G-axis, and B-axis is the angle between the total RGB vector of that block region and the unit vectors of the R-axis, G-axis, and B-axis; the unit vector of the R-axis is (1,0,0), the unit vector of the G-axis is (0,1,0), and the unit vector of the B-axis is (0,0,1).
[0083] According to the mathematical definition of the angle between two three-dimensional vectors, the angle between two vectors... The angle between the total RGB vector of the segmented region and each coordinate axis can be calculated using the dot product formula and the magnitude of the vector:
[0084] ,
[0085] in, The angle between the total RGB vector of the segmented region and the current coordinate axis. This is the total RGB vector of the divided region. The unit vector of the current coordinate axis. for The length of the mold, for The length of the mold, , Represents the inverse cosine function. express and The vector dot product;
[0086] According to the calculation formula The angles between the total RGB vector of each segmented region and the R-axis, G-axis, and B-axis can be calculated. , , Bring it in This allows us to obtain the initial fitting matrix for each segmented region.
[0087] Step S4: Based on the inner product of the RGB vector of each pixel in each block region and the initial fitting matrix of that block region, the effective pixels in each block region are selected.
[0088] In this embodiment, specifically, the step of filtering out effective pixels in each block region based on the inner product of the RGB vector of each pixel in each block region and the initial fitting matrix of that block region includes:
[0089] Determine if the inner product of the RGB vector of each pixel in each segmented region and the initial fitting matrix of that segmented region is greater than 0. If it is greater than 0, then the pixel is considered a valid pixel.
[0090] Step S5: Fit the effective pixels of each block region to obtain the optimized direction matrix for each block region. ;in, The matrix representing the optimization direction of the block region in the i-th row and j-th column;
[0091] like Figure 4 As shown, Figure 4 This is a flowchart of the process for obtaining atmospheric illumination values.
[0092] Step S6: Combine the average brightness value and optimized orientation matrix of each block region to obtain the fusion feature matrix of each block region;
[0093] In this embodiment, the process of obtaining the average brightness of each block region includes:
[0094] Each segmented region is converted to a grayscale image. Pixel values are uniformly extracted from each region at a predetermined ratio. The average brightness of the extracted pixel values is then used as the average brightness of that segmented region. In this embodiment, the ratio is set to 0.1%.
[0095] The fusion feature matrix for each block region is a fourth-order diagonal matrix. The fusion feature matrix for each block region is as follows:
[0096] ,
[0097] in, This represents the fusion feature matrix of the block region in the i-th row and j-th column. This represents the optimization direction matrix for the block region in the i-th row and j-th column. The average brightness of the block region in the i-th row and j-th column is given.
[0098] Step S7: Based on the fusion feature matrix of each block region, obtain the atmospheric illumination value of each block region; based on the atmospheric illumination value and transmittance of each block region, generate the dehazed image.
[0099] In this embodiment, preferably, obtaining the atmospheric illumination value of each block region based on the fusion feature matrix of each block region includes:
[0100] The fusion feature matrix of each block region is clustered directionally by 3D Hough transform, and the atmospheric light direction matrix ADIR is calculated to transform the linear model vector into mathematical parameter form, thus obtaining the set of directional parameters for each block region.
[0101] In each block region, parameter points with the same orientation are summed in Hough space, and the orientation corresponding to the parameter point with the largest summation value is taken as the atmospheric illumination value of that block region. ,in, This represents the atmospheric illumination value of the block region in the i-th row and j-th column.
[0102] In this embodiment, the fusion feature matrix integrates the optimized direction matrix (reflecting color direction features) and the average brightness (reflecting the overall brightness level) of the segmented regions, realizing the synergistic representation of color direction and brightness information, and providing a more comprehensive feature foundation for atmospheric illumination value extraction. On this basis, directional clustering is performed on the fusion feature matrix through 3D Hough transform, transforming the linear model vector into mathematical parameter form, which can accurately capture the dominant color-brightness joint direction trend in the segmented regions and avoid the bias caused by a single feature dimension. Furthermore, by accumulating parameter points with the same direction in Hough space, the direction corresponding to the parameter point with the largest accumulated value is taken as the atmospheric illumination value, which can effectively aggregate the direction features with the highest consistency in the region, reduce the interference of noise or local outliers, and ensure that the extracted atmospheric illumination value can truly reflect the illumination characteristics of the segmented regions affected by fog, providing accurate basic parameters for subsequent dehazing processing, and ultimately improving the color authenticity and detail clarity of the dehazed image.
[0103] In this embodiment, preferably, steps S6-S7 are repeated, with a different 0.1% of pixels being extracted each time to participate in the calculation, and the atmospheric light direction matrix is iteratively optimized to ensure the accuracy of the atmospheric light direction.
[0104] The iterative optimization of the atmospheric light direction matrix includes: statistically analyzing the atmospheric illumination values obtained from multiple iterations (for example, taking the direction consistent with most iteration results, or weakening the influence of outliers through weighted averaging), gradually correcting the atmospheric light direction matrix, and finally converging the results to a stable and accurate direction.
[0105] By calculating the average brightness of different pixel subsets through multiple random samplings, the interference of extreme pixels (such as noise points, abnormally bright / dark points) in a single sampling on the average brightness can be effectively avoided, making the brightness features closer to the true overall brightness level of the segmented region. Simultaneously, 3D Hough transform clustering based on the fused feature matrix of multiple combinations of different average brightness values and optimized direction matrices allows the direction parameter set to cover more diverse regional features, reducing misjudgments of atmospheric light direction caused by single feature extraction biases. This iterative optimization mechanism, through cross-validation of multiple rounds of sampling and calculation, gradually weakens the impact of random errors and local outliers, making the final determined atmospheric light direction matrix more stable and accurate. This improves the reliability of atmospheric illumination values, provides a more solid foundation for subsequent dehazing processing, and ensures the overall quality of the dehazed image.
[0106] This invention uses a direction vector method to process the brightness of each block region. By introducing 3D Hough transform for directional clustering, accurate atmospheric illumination values can be extracted with a small amount of computation.
[0107] Currently, image dehazing methods based on physical models employ dark channel theory for transmittance estimation. The algorithm's idea is that in most fog-free outdoor images, there is always a color channel with a very small value, close to 0, in a local area. This assumption is reasonable because of the texture details and lighting characteristics of objects in a fog-free environment, and it usually holds true in fog-free images. However, when fog is present in the scene, this assumption is broken due to the atmospheric scattering effect of fog. Tiny water droplets in the fog will randomly scatter ambient light, causing the originally low-pixel-value channels to be "filled" by scattered light. This results in the pixel values of all color channels in the local area increasing to varying degrees, and the originally low-pixel-value channels that were close to 0 disappearing. Consequently, the core assumption of the dark channel theory no longer holds true, and the transmittance calculated based on this failed assumption will be excessively underestimated because it cannot accurately reflect the degree of light attenuation caused by fog. The physical meaning of transmittance is "the proportion of light that reaches the camera after passing through fog". Underestimating transmittance means mistakenly believing that light is attenuated more severely by fog. During the image restoration process, brightness will be overcompensated. This overcompensation will directly lead to overexposure distortion in the restored image, resulting in poor image quality after dehazing.
[0108] like Figure 5 As shown, Figure 5 This is a flowchart for obtaining transmittance.
[0109] In this embodiment, preferably, the process of obtaining the transmittance of each segmented region includes:
[0110] For each block region, a pixel is randomly selected as the transmission pixel of that block region;
[0111] Based on the pixel difference between the transmitted pixels and each pixel in each segmented region, pixels with a pixel difference less than the segmentation threshold are selected as the set of transmitted pixels for that segmented region. ;
[0112] ,
[0113] in, Let be the set of transmitted pixels in the block region of row i and column j. This represents the value of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column. Let be the value of the transmitted pixel in the block region of row i and column j. The segmentation threshold is 0.3 in this embodiment.
[0114] For each block region, the set of transmissive pixels Median filtering is performed by assigning the median value of the set of pixels to the center pixel of the window, thus obtaining the median filtering result. The formula is: ,in, This is the result of median filtering. The center pixel of the transmission pixel set for each segmented region, Indicates the median;
[0115] To achieve a more natural defogging effect, a correction factor is introduced. Based on this correction factor, the atmospheric illumination value for each segment, and the median filtering result, the initial transmittance for each segment is calculated. The formula is:
[0116] ,
[0117] in, In this embodiment, the correction factor is 0.95.
[0118] Because the above transmittance algorithm significantly underestimates the transmittance of brighter blocks, this invention adds a compensation function to these brighter blocks to improve transmittance and correct overexposure distortion in bright areas. Specifically, the initial transmittance of each block is compensated using a compensation coefficient, resulting in the transmittance of each block. The formula is as follows:
[0119] ,
[0120] ,
[0121] in, Let be the transmittance of the block region in the i-th row and j-th column. Let be the initial transmittance of the block region in the i-th row and j-th column. Let be the compensation coefficient for the block region in the i-th row and j-th column. The critical threshold for transmittance compensation is set for the block region in row i and column j.
[0122] Compensation coefficient This invention utilizes machine learning to analyze and iterate through 2000 images to be dehazed. The specific operation method is as follows: input the images to be dehazed into a computer, and use the formula... Process the image to be dehazed. , parameters Starting from 1, the parameters are gradually increased in increments of 0.005 to calculate the corresponding dehazed images. Then, by comparing and analyzing the effects of dehazed images under different parameters, a fitted image is obtained. The expression was obtained through analysis and calculation. The best compensation effect was achieved by processing a large number of images. The results showed that areas with a transmittance less than 0.85 typically belonged to brighter regions such as the sky and water. Therefore, in this embodiment, [the following was selected]. When the value is 0.85, the compensation effect is better.
[0123] To achieve clear images and avoid overexposure, this invention proposes the aforementioned adaptive projection compensation algorithm. This algorithm overcomes the drawback of traditional dark channel priors, which excessively underestimate the transmittance in the image, leading to overexposure distortion in the restored image. This results in a clearer image after dehazing.
[0124] In this embodiment, the formula for generating the dehazed image based on the atmospheric illumination value and transmittance of each segmented region is as follows:
[0125] ,
[0126] in, Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the dehazed image. Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the image to be dehazed. Let be the transmittance of the block region in the i-th row and j-th column. Let i be the atmospheric illumination value of the block region in the i-th row and j-th column, where i is the row index of the block region and j is the column index of the block region.
[0127] This second embodiment provides an image dehazing system, including:
[0128] A memory for storing computer programs; a processor for executing the computer programs to implement the steps of the image dehazing method described above.
[0129] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0131] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0132] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0133] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. An image dehazing method, characterized in that, include: The process involves dividing the image to be dehazed into multiple blocks, including: converting the image to be dehazed into a grayscale image; uniformly setting multiple starting pixels in the grayscale image; gradually expanding outwards from each starting pixel along horizontal, vertical, and diagonal directions to its neighborhood; calculating the brightness difference between the current pixel and the previous pixel for each pixel expansion; when the brightness difference of N consecutive pixels exceeds a set threshold, the endpoint of the sequence of N consecutive pixels is taken as the region boundary in the corresponding direction; where N is a set minimum number of pixels; obtaining multiple initial block regions based on the region boundaries in all directions; and segmenting each initial block region based on its Weber contrast to generate multiple block regions. For each segmented region, extract the RGB value of each pixel in that segmented region and the direction vector of the origin, and use them as the RGB vector of each pixel in that segmented region, and randomly select multiple pixels as target pixels; Fit the RGB vectors of all target pixels in each block region to obtain the initial fitting matrix for each block region; The effective pixels of each block region are obtained by filtering based on the inner product of the RGB vector of each pixel in each block region and the initial fitting matrix of that block region. The effective pixels of each block region are fitted to obtain the optimized direction matrix of each block region, including: fitting the RGB vector of all target pixels in each block region to obtain the total RGB vector of each block region; and constructing the initial fitting matrix of each block region based on the angle between the total RGB vector of each block region and the R-axis, G-axis and B-axis. The average brightness value and optimized orientation matrix of each block region are combined to obtain the fusion feature matrix of each block region; the fusion feature matrix of each block region is as follows: , in, This represents the fusion feature matrix of the block region in the i-th row and j-th column. This represents the optimization direction matrix for the block region in the i-th row and j-th column. The average brightness of the block region in the i-th row and j-th column; Based on the fusion feature matrix of each block region, the atmospheric illumination value of each block region is obtained, including: performing directional clustering on the fusion feature matrix of each block region through 3D Hough transform to obtain the directional parameter set of each block region; accumulating the parameter points with the same direction in the directional parameter set of each block region, and taking the direction corresponding to the parameter point with the largest accumulated value as the atmospheric illumination value of that block region. Based on the atmospheric illumination value and transmittance of each segmented region, a dehazed image is generated.
2. The image dehazing method according to claim 1, characterized in that, The initial fitting matrix for each block region is: , in, Let represent the initial fitting matrix of the block region in the i-th row and j-th column. Let be the angle between the total RGB vector of the block region in the i-th row and j-th column and the R-axis. Let G be the angle between the total RGB vector of the block region in the i-th row and j-th column and the G-axis. Let be the angle between the total RGB vector of the block region in row i and column j and the B-axis, where i is the row index of the block region and j is the column index of the block region.
3. The image dehazing method according to claim 1, characterized in that, The process of obtaining the transmittance of each segmented region includes: For each block region, a pixel is randomly selected as the transmission pixel of that block region; Based on the pixel difference between the transmitted pixels and each pixel in each block region, the set of transmitted pixels in each block region is obtained by filtering. Median filtering is applied to the set of transmitted pixels in each block region. Based on the correction coefficient, the atmospheric illumination value of each block region, and the median filtering result, the initial transmittance of each block region is calculated. The initial transmittance of each segment is compensated by the compensation coefficient of each segment, thus obtaining the transmittance of each segment.
4. The image dehazing method according to claim 3, characterized in that, The initial transmittance of each segment is compensated using a compensation coefficient, resulting in the transmittance of each segment. The formula is as follows: , , in, Let be the transmittance of the block region in the i-th row and j-th column. Let be the initial transmittance of the block region in the i-th row and j-th column. Let be the compensation coefficient for the block region in the i-th row and j-th column. The threshold value for transmittance compensation is the threshold value for the block region in the i-th row and j-th column, where i is the row index of the block region and j is the column index of the block region.
5. The image dehazing method according to claim 1, characterized in that, The formula for generating the dehazed image based on the atmospheric illumination value and transmittance of each segmented region is as follows: , in, Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the dehazed image. Let x be the RGB values of the pixel in the x-th row and y-th column of the block region in the i-th row and j-th column of the image to be dehazed. Let be the transmittance of the block region in the i-th row and j-th column. Let i be the atmospheric illumination value of the block region in the i-th row and j-th column, where i is the row index of the block region and j is the column index of the block region.
6. The image dehazing method according to claim 1, characterized in that, The method for segmenting each initial block region based on the Weber contrast of each initial block region to generate multiple block regions includes: For each initial block region, determine whether the Weber contrast of the initial block region is greater than or equal to the set Weber contrast threshold. If it is greater than or equal to the threshold, then recursively divide the initial block region to obtain multiple sub-block regions. Repeat the above judgment for each sub-block region obtained after segmentation. If the Weber contrast of the sub-block region is greater than or equal to the set Weber contrast threshold, continue to recursively segment until all sub-block regions meet any termination condition. The termination conditions include: the Weber contrast of the sub-block regions is lower than the set Weber contrast threshold, the total number of pixels in the sub-block regions is equal to the set minimum number of pixels, or the total number of sub-block regions is equal to the set total number of regions threshold. All sub-block regions that meet the termination condition are designated as block regions.
7. An image dehazing system, characterized in that, include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the image dehazing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image defogging method and image defogging device using image defogging method
CN114693542A
Video image defogging method and device, computer equipment and medium
CN117078562A