Image processing-based city image defogging method
By partitioning urban images, calculating transmittance, and performing smoothing, the problem of the dark channel prior algorithm failing to effectively remove fog in urban images is solved, achieving a more natural defogging effect.
Patent Information
- Application Number
- CN202511126931.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-13
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-08-13
AI Technical Summary
Existing dark channel prior algorithms cannot effectively remove the haze effects from the sky and smooth reflective areas in urban images, resulting in poor image quality after dehazing, which has a significant impact, especially in the fields of urban surveillance and traffic management.
By partitioning the city image, the transmittance of the real area, the sky area, and the smooth reflective area are calculated separately. The boundary of the sky area is smoothed, and the atmospheric scattering model is used for dehazing to avoid abrupt changes and discontinuities in transmittance.
It improves the visual naturalness of the dehazed image, reduces the lines separating light and dark areas, and enhances image quality.
Smart Images

Figure CN120634916B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an urban image defogging method based on image processing. Background Art
[0002] Urban image dehazing technology aims to eliminate the effects of atmospheric particulate matter on images during hazy weather, restoring image clarity and detail. In hazy weather, particles such as water vapor and dust in the air scatter and absorb light, blurring images, reducing brightness, and distorting colors, impacting image quality. This impact is particularly pronounced in applications such as urban surveillance, traffic management, and environmental monitoring.
[0003] Image dehazing is often achieved using a dark channel prior algorithm. However, the sky area in urban images does not have a low-pixel channel due to its high brightness and channel balance. Smooth reflective areas also do not have a low-pixel channel in some local areas due to the reflection of high-brightness ambient light. Therefore, it is necessary to calculate the transmittance by partitioning. However, directly splicing the transmittance calculated by partitions will cause transmittance jumps at the partition boundaries, resulting in a clear light-dark dividing line at the junction of the sky and buildings in the dehazed image, which in turn results in poor image quality after dehazing. Summary of the Invention
[0004] The present invention provides an urban image defogging method based on image processing to solve the existing problems.
[0005] The urban image defogging method based on image processing of the present invention adopts the following technical solutions:
[0006] An embodiment of the present invention provides a method for defogging an urban image based on image processing, the method comprising the following steps:
[0007] Collect city images and filter out fog images;
[0008] Partition the fog image to obtain real areas and non-real areas, where the non-real areas include sky areas and smooth reflective areas;
[0009] Estimate the transmittance of the real area based on the real area pixels; determine the transmittance of the sky area based on the transmittance of the fog map theory; obtain the transmittance of the smooth reflective area based on the transmittance of the pixels in the adjacent areas in different directions of the smooth reflective area;
[0010] Determine a pixel to be smoothed at the boundary of the sky area, determine a rate of change of the transmittance of the pixel to be smoothed based on the transmittance of the pixel to be smoothed and the nearest pixel in other areas; interpolate the transmittance of the pixel to be smoothed based on the rate of change of the transmittance of the pixel to be smoothed to obtain a smoothed transmittance of the pixel to be smoothed; and update the transmittance of the pixel to be smoothed to the smoothed transmittance.
[0011] According to the transmittance of all pixels, the fog image is defogged to obtain the defogged image.
[0012] Preferably, partitioning the fog image to obtain real areas and non-real areas, wherein the non-real areas include sky areas and smooth reflective areas, comprises the following specific steps:
[0013] First, the probability that a pixel belongs to a non-real area is determined based on its brightness and saturation. The brightness of a pixel is positively correlated with the probability that the pixel belongs to a non-real area, while the saturation of a pixel is negatively correlated with the probability that the pixel belongs to a non-real area.
[0014] Then, based on the possibility that the pixel points belong to the non-real area, the fog image is segmented to obtain the non-real area in the fog image;
[0015] Finally, in the obtained non-real area, the edge gradient amplitude is used to distinguish the sky area from the smooth reflective area.
[0016] Preferably, the specific method of using edge gradient amplitude to distinguish the sky area from the smooth reflective area is as follows:
[0017] In the obtained non-real area, the mean gradient amplitude of each edge pixel of the area is calculated respectively;
[0018] The mean of all the gradient amplitudes is classified into two categories using the Otsu method to obtain two types of areas, where one type of area with a large gradient amplitude is the sky area, and the other type of area is the smooth reflective area.
[0019] Preferably, the estimating the transmittance of the real area based on the pixels of the real area includes the following specific steps:
[0020] First, determine the dark channel of the fog image;
[0021] Then, in the dark channel of the fog image, the atmospheric light of the fog image is determined based on the brightness of the pixels in the real area;
[0022] Finally, the transmittance of the real area is determined based on the dark channel of the fog image and the atmospheric light of the fog image.
[0023] Preferably, the method of determining the transmittance of the sky area based on the theoretical transmittance of the fog map includes the following specific steps:
[0024] The theoretical transmittance of the sky area obtained based on the original dark channel prior algorithm;
[0025] Add a stability factor to the theoretical transmittance of the sky area;
[0026] The theoretical transmittance with the stability coefficient added and the minimum value of 1 are used as the transmittance of the sky area.
[0027] Preferably, the method of obtaining the transmittance of the smooth reflective area according to the transmittance of pixels in adjacent areas in different directions of the smooth reflective area includes the following specific steps:
[0028] First, multiple pixels in adjacent areas in different directions of the smooth reflective area are selected as adjacent real pixels of the smooth reflective area;
[0029] Then, the average of the gradient amplitudes of the transmittances of adjacent real pixels in the smooth reflective area in one direction is used as the weight factor in the corresponding direction;
[0030] Finally, the transmittance of the smooth reflective area is obtained based on the weight factors in different directions of the smooth reflective area and the average transmittance of the real pixels in different directions.
[0031] Preferably, the step of determining the pixel points to be smoothed at the boundary of the sky area includes the following specific steps:
[0032] In the fog map, extract all sky areas and determine the edge of each sky area;
[0033] In a sky area, determine the shortest distance between each pixel and the edge pixel;
[0034] Select the pixel point whose shortest distance to the edge pixel point is less than or equal to L0 as the pixel point to be smoothed, where L0 is a preset value.
[0035] Preferably, the method of determining the rate of change of the transmittance of the pixel to be smoothed based on the transmittance of the pixel to be smoothed and the pixels in other areas closest to the pixel to be smoothed comprises the following specific steps:
[0036] Determine the nearest pixel points in other areas to each pixel to be smoothed;
[0037] Connect the pixel to be smoothed with the nearest pixel points in other areas to obtain a connecting line; the pixels passed by a connecting line form a pixel sequence;
[0038] Calculate the transmittance difference between the first and last pixel in each pixel sequence;
[0039] The ratio of the transmittance difference to the number of pixels in the pixel sequence is used as the change rate of the transmittance of the pixel to be smoothed.
[0040] Preferably, the method of interpolating the transmittance of the pixel to be smoothed based on the rate of change of the transmittance of the pixel to be smoothed to obtain the smoothed transmittance of the pixel to be smoothed includes the following specific steps:
[0041] In the pixel point sequence corresponding to the connecting line of the current pixel point to be smoothed, linear interpolation is performed on the other pixel points except the first and last pixel points in the pixel point sequence, where the slope of the linear equation of the linear interpolation is the rate of change of the transmittance of the current pixel point to be smoothed;
[0042] The interpolation results of a pixel to be smoothed in multiple pixel sequences are averaged to obtain the smoothed transmittance of the pixel to be smoothed.
[0043] Preferably, the defogging operation is performed on the fog image according to the transmittance of all pixels to obtain a defogged image, which includes the following specific steps:
[0044] According to the atmospheric scattering model and combined with the atmospheric light and transmittance of the fog image, the defogged image is obtained.
[0045] The beneficial effects of the technical solution of the present invention are:
[0046] The urban image is partitioned and the transmittance is calculated in the real area to avoid the influence of non-real areas that do not conform to the dark channel prior and improve the accuracy of the transmittance of the real area. The transmittance of the smooth reflective area is obtained by weighted fusion of the transmittance of adjacent areas, which avoids the incorrect estimation of the transmittance of the smooth reflective area and reduces the sudden change of transmittance. At the same time, the boundary of the sky area is smoothed, so that the brightness of the dehazed image changes continuously, the boundary is clearer and more natural, and the visual naturalness is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 This is a flowchart of the steps of the urban image defogging method based on image processing of the present invention. DETAILED DESCRIPTION
[0049] To further illustrate the technical means and effectiveness of the present invention in achieving its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation, structure, features, and effectiveness of the urban image dehazing method based on image processing proposed by the present invention. In the following description, different references to "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
[0050] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0051] The specific scheme of the urban image defogging method based on image processing provided by the present invention is described in detail below with reference to the accompanying drawings.
[0052] See also Figure 1 , which shows a flowchart of a method for defogging an urban image based on image processing according to an embodiment of the present invention, the method comprises the following steps:
[0053] S001. Data collection and data preprocessing.
[0054] Within the city, urban images are often needed in various fields, such as for traffic monitoring, urban inspections, etc., and a large number of urban images need to be obtained in this process.
[0055] First, determine the image acquisition device, that is, use an industrial camera for acquisition. The specific parameters are:
[0056] (1) Resolution
[0057] Recommended setting: 25 megapixels (industrial camera).
[0058] Setting logic: High resolution preserves foggy details (such as the outlines of distant buildings and the edges of glass reflections), preventing loss of details after defogging due to insufficient pixels.
[0059] (2) Sensor type
[0060] Recommended setting: Global shutter CMOS (industrial camera).
[0061] Setting logic: CCD noise is lower (suitable for low-light foggy days); global shutter avoids smear when shooting moving objects (such as vehicles) and ensures the continuity of fog distribution.
[0062] (3) Focal length
[0063] Recommended settings: 18-70mm (zoom lens).
[0064] Setting logic: The wide-angle end (18mm) can capture large scenes (such as street panoramas, including the sky and buildings); the telephoto end (70mm) can capture distant foggy areas (such as the top of a tall building).
[0065] (4) Aperture (f-number)
[0066] Recommended settings: f / 5.6-f / 8.
[0067] Setting logic: If the aperture is too small (the f-value is too large), it will cause diffraction blur and affect details; if it is too large (the f-value is too small), it will lead to insufficient depth of field (the near view is clear and the distant view is blurred), and it will not be able to truly reflect the spatial distribution of fog.
[0068] (5) Shutter speed
[0069] Recommended setting: 1 / 100-1 / 500s.
[0070] Setting logic: The light is dim in foggy days, and a too slow shutter speed can easily cause blur due to hand shaking (a tripod is required); a too fast shutter speed may lead to underexposure and loss of the grayscale level of the fog.
[0071] (6) ISO (sensitivity)
[0072] Recommended setting: 100-400.
[0073] Setting logic: Low ISO (100) can reduce noise (foggy images have low contrast, and noise will seriously interfere with the defogging algorithm); the maximum should not exceed 400 (to avoid noise explosion).
[0074] (7) White balance
[0075] Recommended settings: Automatic or Cloudy Mode.
[0076] Setting logic: Light in foggy days tends to be colder (more blue light), and automatic white balance can balance the color temperature to avoid color cast in the image (color cast will interfere with atmospheric light estimation).
[0077] Based on the above equipment and parameter settings, we collected urban images. First, we converted the original image to grayscale. Then, we set a grayscale threshold. Pixels above the grayscale threshold were considered high-brightness pixels. The proportion of high-brightness pixels in the image was calculated. Finally, images with a high-brightness pixel ratio greater than the ratio threshold were considered foggy. The grayscale threshold was set to 200, and the ratio threshold was set to 0.8.
[0078] S002. Obtain a real area and a non-real area based on the brightness and saturation of the pixel points, and divide the non-real area into a sky area and a smooth reflective area based on the area edge gradient.
[0079] For the defogging operation of the obtained fog image, the dark channel prior algorithm can be used to perform image defogging. The existing dark channel prior algorithm defogging process is as follows:
[0080] (1) Calculating dark channel: fog image Set a local window (15×15), and then take the minimum value of the RGB three channels for each pixel in the local window to get the dark channel .
[0081] (2) Estimation of atmospheric light: Take the average value of the original image pixels corresponding to the top 0.1% pixels with the highest brightness in the dark channel as the atmospheric light A of the current fog image.
[0082] (3) Estimation of transmittance: The dark channel of the fog image is mainly composed of atmospheric light A and transmittance The decision is approximately:
[0083]
[0084] The transmittance is thus obtained as:
[0085]
[0086] (4) Defogging fog image: Based on the atmospheric scattering model , the fog-free image to be restored is:
[0087]
[0088] The aforementioned dark channel prior algorithm for image dehazing relies on a dark channel prior, which assumes that the dark channel is close to 0. However, urban images may contain areas of sky with high surrounding pixel values, so their dark channel values are not close to 0. This results in an underestimation of the transmittance estimate, which can easily cause a color cast in the sky after dehazing, affecting the dehazing effect. Furthermore, urban images may contain smooth surfaces such as glass curtain walls and wet pavement, which reflect skylight or ambient light, resulting in high RGB values for these pixels and dark channel values not close to 0, violating the prior.
[0089] Therefore, it's not possible to directly use the dark channel prior algorithm for dehazing urban images. The fundamental reason is that the dark channel prior doesn't apply to sky and smooth reflective areas. To address this, dehazing urban images can be achieved by partitioning the image and correcting the transmittance in the sky and smooth reflective areas. The sky and smooth reflective areas are referred to as non-real areas, while the rest of the image is referred to as real areas.
[0090] In the fog image, the pixels in the sky area have low saturation, while the pixels in the smooth reflective area have high brightness due to the reflection of natural light. Based on this, the possibility of the pixel belonging to the non-real area is determined, and the fog image is partitioned.
[0091] As an embodiment, the specific process of partitioning the fog map is as follows:
[0092] (1) For the fog image, the color space conversion is first performed, where the saturation S of the pixel point in the HSV space is:
[0093]
[0094] in Indicates taking the minimum value of the three channels R, G, and B.
[0095] And determine the brightness V of the pixel as:
[0096]
[0097] Wherein, a, b, and c are weights respectively. In this embodiment, the values of a, b, and c are 0.229, 0.587, and 0.114 respectively.
[0098] (2) Based on the brightness and saturation of the pixel, determine the possibility that the pixel belongs to the non-real area:
[0099]
[0100] (3) In the fog image, based on the possibility that a pixel point belongs to a non-real area, the non-real area can be identified. The watershed algorithm can be directly used to obtain the non-real area in the fog image. The area other than the non-real area in the fog image is the real area. The watershed algorithm is an existing technology and will not be described here.
[0101] (4) In the obtained non-real area, the mean gradient amplitude of each pixel point at the edge of the area is calculated respectively, and then the mean gradient amplitude of all the above-mentioned values is classified into two categories using the Otsu method to obtain two types of areas, where the area with the smaller gradient amplitude is the sky area, and the other area is the smooth reflective area.
[0102] As another embodiment, the process of distinguishing the smooth reflective area in the sky area is as follows:
[0103] In the obtained non-real area, the gradient amplitude of each edge pixel point of the area is calculated respectively to obtain the mean gradient amplitude of each edge pixel point of the non-real area; the distinction threshold is set to 180, and the area with the mean gradient amplitude greater than the distinction threshold is the smooth reflective area, and the rest of the non-real area is the sky area.
[0104] S003. Determine the transmittance of the real area based on the pixels of the real area, correct the estimated transmittance of the sky area, and then determine the transmittance of the smooth reflective area based on the transmittance of the adjacent area.
[0105] Based on the fog map partitioning described above, dehazing is performed within the partitions. This process yields real and non-real areas. Since the non-real areas do not satisfy the dark channel prior, their transmittance is low and therefore cannot be directly dehazed using the dark channel prior. Since the real areas satisfy the dark channel prior, their transmittance is accurately estimated. However, when estimating the transmittance of the real areas, the influence of the non-real areas must be considered. Specifically, pixels in the non-real areas must be excluded when calculating the atmospheric light.
[0106] As an embodiment, the specific process of estimating the transmittance of the real area in the fog image is as follows:
[0107] First, a local window (15×15) is set in the fog image. For each pixel, the minimum value of the RGB three channels is taken in the local window to obtain the dark channel of the fog image. ;
[0108] Then, the average value of the original image pixels corresponding to the top 0.1% pixels with the highest brightness in the real area is extracted from the dark channel of the fog image as the atmospheric light intensity of the fog image. .
[0109] Finally, determine the transmittance of the real area for:
[0110]
[0111] Where, For the dark channel of the fog map, This is the atmospheric light for the fog image.
[0112] At this point, the transmittance of all real areas in the fog map is determined.
[0113] Furthermore, for non-realistic areas in the fog map, their transmittance varies, necessitating a different approach to determining it. Light in the sky region primarily originates from atmospheric scattering, not reflection from objects. The fog's influence on its propagation path is relatively weak, resulting in an actual transmittance close to 1. This means that the "fog" in the sky region is essentially scattered light from the atmosphere itself, rather than light from objects being attenuated by the fog. Therefore, the transmittance of the sky region needs to be estimated based on the relative size of its theoretical transmittance to 1.
[0114] As an embodiment, the transmittance of the sky area in the fog image is determined The method is:
[0115]
[0116] Where, is the theoretical transmittance of the sky area obtained based on the original dark channel prior algorithm, is the stability factor, add Ensure that the transmittance of the sky area is close to 1 to avoid overexposure caused by too low theoretical transmittance of the sky area in the original dark channel prior algorithm. , Indicates taking the minimum value.
[0117] Furthermore, for smooth reflective areas, the reflections on their surfaces may completely cover the original pixel representation, so their transmittance needs to be determined based on the transmittance of the adjacent real area. Since the adjacent real area has a smooth representation, the transmittance of its pixels has good smoothness. In this case, for the real area pixels, the larger the gradient amplitude of the transmittance, the more reliable the transmittance.
[0118] As an embodiment, the specific process of determining the transmittance of the smooth reflective area is as follows:
[0119] (1) For each smooth reflective area, determine its geometric center, and then draw a horizontal line and a vertical line passing through the geometric center.
[0120] (2) The horizontal straight line and the vertical straight line pass through other real areas in the left, right, up, and down directions of the smooth reflective area, respectively. In each direction, the N pixel points of the real area passed through and closest to the geometric center of the smooth reflective area are recorded as the adjacent real pixel points of the smooth reflective area in the left, right, up, and down directions, respectively. In this embodiment, N is set to 20.
[0121] (3) Calculate the average transmittance of adjacent real pixels in each of the left, right, up, and down directions, expressed as , , , ; and calculate the mean value of the gradient amplitude of the transmittance of adjacent real pixel points in each direction of the left, right, up and down directions, which are expressed as , , , ; That is, obtain the weight factors of the left, right, top and bottom directions of the smooth reflective area.
[0122] At this time, taking the left direction of the smooth reflective area as an example, the weight of one direction of the smooth reflective area is constructed:
[0123]
[0124] Where, Indicates the mean value of the gradient amplitude of the transmittance of the adjacent real pixel points in the left direction of the smooth reflective area. Represents the sum of the mean values of the gradient amplitudes of the transmittances of adjacent real pixels in each of the left, right, up, and down directions; multiplied by The purpose is to make the sum of the weights of a smooth reflective area in the four directions equal to 1.
[0125] Based on the method of this embodiment, the weights for the right, top, and bottom directions of the smooth reflective area are determined as follows:
[0126]
[0127]
[0128]
[0129] Where, 、 、 Respectively represent the mean values of the gradient amplitude of the transmittance of adjacent real pixels in the right, upper, and lower directions of the smooth reflective area, 、 、 Represents the weights of the right, top, and bottom directions of the smooth reflective area respectively.
[0130] (4) Determine the transmittance of a smooth reflective area for:
[0131]
[0132] In the formula 、 、 、 Represents the weights of the left, right, top, and bottom directions of the smooth reflective area, 、 、 、 Respectively represent the average transmittance of adjacent real pixel points in each direction of the smooth reflective area: left, right, up, and down.
[0133] As another embodiment, the specific process of determining the transmittance of the smooth reflective area is as follows:
[0134] (1) For each smooth reflective area, determine its geometric center, and then draw a horizontal line and a vertical line passing through the geometric center.
[0135] (2) The horizontal straight line and the vertical straight line pass through other real areas in the left, right, up, and down directions of the smooth reflective area, respectively. In each direction, the N pixel points of the real area passed through and closest to the geometric center of the smooth reflective area are recorded as the adjacent real pixel points of the smooth reflective area in the left, right, up, and down directions, respectively. In this embodiment, N is set to 20.
[0136] (3) Calculate the average transmittance of adjacent real pixels in the left, right, top, and bottom directions of the smooth reflective area respectively.
[0137] (4) The average of the transmittances of the adjacent real pixels in the left, right, up, and down directions of the smooth reflective area is calculated and used as the transmittance of the smooth reflective area.
[0138] In some other embodiments, the method for determining the transmittance of the smooth reflective area is:
[0139] For each smooth reflective area, all other adjacent areas are first determined as adjacent areas of the smooth reflective area; then the average transmittance of all pixel points adjacent to a smooth reflective area is calculated as the transmittance of the smooth reflective area.
[0140] S004: Determine boundary pixels to be smoothed in the sky area, and then perform transmittance interpolation on the pixels to be smoothed to update the transmittance of the pixels to be smoothed.
[0141] It is known that transmittance reflects the ability of light to penetrate fog. Its value is determined by the fog concentration. The spatial variation of fog concentration is continuous. For example, the fog concentration from the sky to the ground gradually increases rather than suddenly. Therefore, the spatial variation of transmittance must also be continuous. That is, in the real world, the transmittance change caused by atmospheric scattering is gradual rather than abrupt.
[0142] In the above process, the fog image is partitioned, and the transmittance of pixels is calculated for the real and non-real areas based on the partitions. In the non-real area, the transmittance is calculated separately for the sky area and the smooth reflective area. The transmittance of the sky area is usually close to 1, while the transmittance of the real area is lower, even below 0.5 when the fog concentration is high. In this case, if the images are directly spliced, a jump from high to low transmittance will occur at the boundary, resulting in a clear light and dark dividing line at the junction of the sky and the building in the defogged image. For example, the defogged sky part is too bright, while the residual fog on the building part is dark, resulting in a hard boundary. The smooth reflective area is determined by the adjacent area, so its boundary does not have a clear dividing line.
[0143] Therefore, it is necessary to smooth the transmittance of the boundary pixels of the sky area in the non-real area, wherein firstly it is necessary to determine the pixels to be smoothed, that is, determine the area to be smoothed.
[0144] As an embodiment, the specific process of determining the area to be smoothed in the sky area is as follows:
[0145] (1) In the fog image, extract all sky areas and determine the edge of each sky area.
[0146] (2) In a sky area, the shortest distance between each pixel and the edge pixel is determined, and then the pixel whose shortest distance is less than or equal to L0 is selected as the pixel to be smoothed. The pixel to be smoothed constitutes the area to be smoothed, where L0 is set to 5 in this embodiment.
[0147] Furthermore, based on the gradual change characteristics of the transmittance, the pixels to be smoothed in the sky area are smoothed. The smoothing process is mainly based on the smooth change of the transmittance of consecutive pixels.
[0148] As an embodiment, the transmittance determination process of the pixel to be smoothed is as follows:
[0149] (1) Determine the nearest pixel point in other regions to each pixel point to be smoothed; connect the pixel point to be smoothed with the nearest pixel point in other regions to obtain a connecting line; wherein the connecting line passes through multiple other pixels to be smoothed; each pixel point to be smoothed corresponds to a connecting line, a connecting line passes through multiple pixels to be smoothed, and a pixel to be smoothed may pass through multiple connecting lines.
[0150] (2) All the pixels that a connecting line passes through constitute a pixel sequence, where the first pixel in the pixel sequence is a pixel in other areas, and then it is arranged in sequence according to its position on the connecting line. The last pixel is the starting point of the connecting line, that is, the pixel to be smoothed corresponding to the current connecting line.
[0151] (3) Calculate the rate of change of transmittance in the pixel sequence corresponding to each connecting line for:
[0152]
[0153] in , They represent the transmittance of the first and last pixels in the pixel sequence respectively, and m is the number of pixels in the pixel sequence.
[0154] (4) Based on the rate of change of the transmittance of the pixel sequence, determine the smooth transmittance of each pixel in the pixel sequence for:
[0155]
[0156] in 、 Respectively represent the smoothed transmittance of the v-1th and vth pixel points in the pixel sequence, It is the rate of change of the transmittance of the pixel sequence. When , it means the first pixel in the sequence, that is, , and when When , it means the last bit of the pixel sequence, that is, .
[0157] (5) Because a pixel to be smoothed in a sky area may pass through multiple connecting lines, a pixel to be smoothed may correspond to multiple pixel sequences, that is, a pixel to be smoothed may have multiple smoothed transmittances. In this case, the multiple smoothed transmittances of a pixel to be smoothed are averaged, and the transmittance of the area to be smoothed is updated to the average of the multiple smoothed transmittances.
[0158] S005. Defogging the city fog image based on the obtained pixel transmittance.
[0159] Based on the above steps, the transmittance of each pixel in the fog image is obtained, including the transmittance of the real area. , the transmittance of the sky region , the transmittance of the smooth reflective area , at this time, the transmittance of all pixels in the fog image is expressed as Then, based on the dark channel prior algorithm, the defogging image is determined. The specific process is:
[0160] (1) Extract the average value of the original image pixels corresponding to the top 0.1% pixels with the highest brightness in the real area in the dark channel of the fog image as the atmospheric light intensity of the current fog image. .
[0161] (2) Obtain the defogging image based on the atmospheric scattering model for:
[0162]
[0163] in represents the original fog map, Represents the transmittance of the pixel, Represents the atmospheric light of the current fog map.
[0164] At this point, the dehazing of the city image is completed and the dehazed image is obtained.
[0165] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. The urban image defogging method based on image processing is characterized by: The method comprises the following steps: Collect city images and filter out fog images; Partition the fog image to obtain real areas and non-real areas, where the non-real areas include sky areas and smooth reflective areas; Estimate the transmittance of the real area based on the real area pixels; determine the transmittance of the sky area based on the transmittance of the fog map theory; obtain the transmittance of the smooth reflective area based on the transmittance of the adjacent real area pixels in different directions of the smooth reflective area; Determine a pixel to be smoothed at the boundary of the sky area, determine a rate of change of the transmittance of the pixel to be smoothed based on the transmittance of the pixel to be smoothed and the nearest pixel in other areas; interpolate the transmittance of the pixel to be smoothed based on the rate of change of the transmittance of the pixel to be smoothed to obtain a smoothed transmittance of the pixel to be smoothed; and update the transmittance of the pixel to be smoothed to the smoothed transmittance. According to the transmittance of all pixels, the fog image is defogged to obtain the defogged image; The specific steps of obtaining the transmittance of the smooth reflective area according to the transmittance of the pixels of the adjacent real area in different directions of the smooth reflective area are as follows: First, multiple pixel points in adjacent real areas in different directions of the smooth reflective area are selected as adjacent real pixel points of the smooth reflective area; Then, the average of the gradient amplitudes of the transmittances of adjacent real pixels in the smooth reflective area in one direction is used as the weight factor in the corresponding direction; Finally, the transmittance of the smooth reflective area is obtained based on the weight factors in different directions of the smooth reflective area and the average transmittance of the real pixels in different directions.
2. The urban image defogging method based on image processing according to claim 1 is characterized in that: Partitioning the fog image to obtain real areas and non-real areas, where the non-real areas include sky areas and smooth reflective areas, includes the following specific steps: First, the probability that a pixel belongs to a non-real area is determined based on its brightness and saturation. The brightness of a pixel is positively correlated with the probability that the pixel belongs to a non-real area, while the saturation of a pixel is negatively correlated with the probability that the pixel belongs to a non-real area. Then, based on the possibility that the pixel points belong to the non-real area, the fog image is segmented to obtain the non-real area in the fog image; Finally, in the obtained non-real area, the edge gradient amplitude is used to distinguish the sky area from the smooth reflective area.
3. The urban image defogging method based on image processing according to claim 2, characterized in that: The specific method of using edge gradient amplitude to distinguish the sky area from the smooth reflective area is as follows: In the obtained non-real area, the mean gradient amplitude of each edge pixel of the area is calculated respectively; The mean of all the gradient amplitudes is classified into two categories using the Otsu method to obtain two types of areas, where one type of area with a large gradient amplitude is the sky area, and the other type of area is the smooth reflective area.
4. The urban image defogging method based on image processing according to claim 1, characterized in that: The specific steps of estimating the transmittance of the real area based on the pixels of the real area are as follows: First, determine the dark channel of the fog image; Then, in the dark channel of the fog image, the atmospheric light of the fog image is determined based on the brightness of the pixels in the real area; Finally, the transmittance of the real area is determined based on the dark channel of the fog image and the atmospheric light of the fog image.
5. The urban image defogging method based on image processing according to claim 1, characterized in that: The specific steps of determining the transmittance of the sky area based on the theoretical transmittance of the fog map are as follows: The theoretical transmittance of the sky area is obtained based on the original dark channel prior algorithm; Add a stability factor to the theoretical transmittance of the sky area; The theoretical transmittance with the stability coefficient added and the minimum value of 1 are used as the transmittance of the sky area.
6. The urban image defogging method based on image processing according to claim 1, characterized in that: The specific steps of determining the pixel points to be smoothed at the boundary of the sky area are as follows: In the fog map, extract all sky areas and determine the edge of each sky area; In a sky area, determine the shortest distance between each pixel and the edge pixel; Select the pixel point whose shortest distance to the edge pixel point is less than or equal to L0 as the pixel point to be smoothed, where L0 is a preset value.
7. The urban image defogging method based on image processing according to claim 1, characterized in that: The method of determining the rate of change of the transmittance of the pixel to be smoothed based on the transmittance of the pixel to be smoothed and the pixels in other areas closest to the pixel to be smoothed comprises the following specific steps: Determine the nearest pixel points in other areas to each pixel to be smoothed; Connect the pixel to be smoothed with the nearest pixel points in other areas to obtain a connecting line; the pixels passed by a connecting line form a pixel sequence; Calculate the transmittance difference between the first and last pixel in each pixel sequence; The ratio of the transmittance difference to the number of pixels in the pixel sequence is used as the change rate of the transmittance of the pixel to be smoothed.
8. The urban image defogging method based on image processing according to claim 7 is characterized in that: The method of interpolating the transmittance of the pixel to be smoothed based on the rate of change of the transmittance of the pixel to be smoothed to obtain the smoothed transmittance of the pixel to be smoothed includes the following specific steps: In the pixel point sequence corresponding to the connecting line of the current pixel point to be smoothed, linear interpolation is performed on the other pixel points except the first and last pixel points in the pixel point sequence, where the slope of the linear equation of the linear interpolation is the rate of change of the transmittance of the current pixel point to be smoothed; The interpolation results of a pixel to be smoothed in multiple pixel sequences are averaged to obtain the smoothed transmittance of the pixel to be smoothed.
9. The urban image defogging method based on image processing according to claim 1, characterized in that: The defogging operation is performed on the fog image according to the transmittance of all pixels to obtain the defogged image, and the specific steps include the following: According to the atmospheric scattering model and combined with the atmospheric light and transmittance of the fog image, the defogged image is obtained.
Citation Information
Patent Citations
Foggy day image visibility detection method and device, computer equipment and storage medium
CN118052764A
KR1017285070000B1