Image and video defogging methods

By calculating the dark channel value and fog intensity value of the image and combining them with the atmospheric light value, the image dehazing process is performed. This solves the problem of uneven dehazing in areas with high brightness and different fog concentrations, achieving efficient image and video dehazing effects and avoiding halo phenomena.

CN117541502BActive Publication Date: 2026-07-31ALI CORP
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALI CORP
Filing Date
2022-07-29
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing image dehazing algorithms perform poorly when dealing with high brightness values ​​and areas with varying fog concentrations, especially in areas with color distortion in the sky and uneven processing between dense and thin fog areas.

Method used

By acquiring the dark channel value and fog intensity value of the target image, the estimated value of transmittance and the defogging correction intensity value are calculated. Combined with the atmospheric light value, image defogging is performed. It is suitable for single-point or filter window unit defogging, avoids halo effect, and processes fog intensity and atmospheric light value by weighted average between video frames.

Benefits of technology

It achieves uniform dehazing in high-brightness areas and areas with different fog concentrations, maintains image clarity, avoids halo effects, and improves the uniformity and efficiency of video dehazing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117541502B_ABST
    Figure CN117541502B_ABST
Patent Text Reader

Abstract

This application discloses an image dehazing method and a video dehazing method. The image dehazing method includes: obtaining a second dark channel image of the target image based on the first dark channel value corresponding to each pixel in the target image; obtaining atmospheric light value; obtaining fog intensity value; obtaining a dehazing correction intensity value based on the fog intensity value, the first dark channel value corresponding to each pixel in the first dark channel image, or the brightness value corresponding to each pixel in the target image; obtaining a predicted transmittance value based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, and the atmospheric light value; and obtaining a dehazed image based on the predicted transmittance value, the target image, and the atmospheric light value. Therefore, the halo effect can be avoided, and areas with high brightness values ​​in a foggy image can still maintain appropriate brightness after dehazing, and areas with different fog concentrations have good dehazing effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image dehazing method and a video dehazing method. Background Technology

[0002] In foggy weather, atmospheric particle scattering significantly reduces image quality and visual impact on captured images and videos. Therefore, dehazing algorithms are commonly used to remove fog from images, resulting in clearer, more visible images.

[0003] However, most dehazing algorithms perform poorly in areas with high brightness values, such as the sky (e.g., color distortion). Furthermore, when dehazing foggy images taken in scenes with both dense and light fog, inconsistent processing results occur because light in dense fog areas is attenuated and scattered more than light in light fog areas.

[0004] In view of this, how to solve the various problems existing in the current image dehazing technology is a technical issue that urgently needs to be addressed by those skilled in the art. Summary of the Invention

[0005] This application provides an image dehazing method and a video dehazing method, which can solve the problem in the prior art that the image dehazing process has poor dehazing effect on areas with high brightness values ​​and areas with different fog concentrations.

[0006] To solve the above-mentioned technical problems, this application is implemented as follows: In a first aspect, an image dehazing method is provided, comprising: obtaining a second dark channel image corresponding to the target image based on the first dark channel value corresponding to each pixel in the target image; obtaining atmospheric light value; obtaining fog intensity value; obtaining a dehazing correction intensity value based on the fog intensity value, the first dark channel value corresponding to each pixel in the first dark channel image, or the brightness value corresponding to each pixel in the target image; obtaining a predicted transmittance value based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, and the atmospheric light value; and obtaining an estimated dehazed image based on the predicted transmittance value, the target image, and the atmospheric light value.

[0007] Secondly, a video dehazing method is provided, comprising: performing dehazing processing on each frame of a video using the image dehazing method of this application; wherein the atmospheric light values ​​corresponding to the first N frames of the video include: a default atmospheric light value, a set atmospheric light value, a brightness value of the target image corresponding to the pixel with the largest first dark channel value in the first dark channel image as the atmospheric light value, or selecting multiple brightness values ​​of the target image corresponding to multiple pixels in the first dark channel image sorted from high to low according to a predetermined proportion, and calculating the average of the multiple brightness values ​​as the atmospheric light value; the first N frames of the video The corresponding fog intensity values ​​include: a default fog intensity value, a set fog intensity value, or a fog intensity value obtained based on the average dark channel value of the first dark channel image or the average brightness value of the target image; N is a positive integer; wherein, the atmospheric light value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the atmospheric light values ​​corresponding to the previous M frames; the fog intensity value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the fog intensity values ​​corresponding to the previous M frames; M is an integer less than or equal to N; and each frame image after dehazing is merged into a dehazed video and output.

[0008] In this embodiment, the image dehazing method is applicable to dehazing on a single point or filter window basis, which can avoid the halo effect caused by dehazing on a filter window basis. In addition, the image dehazing method of this application performs image dehazing by estimating the transmittance based on the dehazing correction intensity value, so that high brightness areas in a hazy image can still maintain appropriate brightness after dehazing, and areas with different fog concentrations have good dehazing effects. Attached Figure Description

[0009] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A schematic flowchart of an embodiment of the image dehazing method according to this application; Figure 2 for Figure 1 A schematic flowchart of an embodiment of step 110; Figure 3 This is a first dark channel diagram according to an exemplary embodiment of this application; Figure 4 This is a schematic flowchart of an embodiment of the video dehazing method according to this application; and Figure 5 This is a block diagram of an embodiment of a terminal device according to this application. Detailed Implementation

[0010] The embodiments of the present invention will be described below with reference to the accompanying drawings. In these drawings, the same reference numerals denote the same or similar components or method flows.

[0011] It must be understood that the use of terms such as "comprising" or "including" in this specification is intended to indicate the presence of specific technical features, values, method steps, work processes, and / or components, but does not preclude the addition of more technical features, values, method steps, work processes, components, or any combination thereof.

[0012] It is important to understand that when a component is described as "connected" or "coupled" to another component, it can be a direct connection or coupling to other components, and there may be intermediate components. Conversely, when a component is described as "directly connected" or "directly coupled" to another component, there are no intermediate components.

[0013] Please see Figure 1 This is a schematic flowchart of an embodiment of the image dehazing method according to this application. Figure 1 As shown, the image dehazing method includes the following steps: obtaining a second dark channel image corresponding to the target image based on the first dark channel value corresponding to each pixel in the target image (step 110); obtaining atmospheric light value (step 120); obtaining fog intensity value (step 130); obtaining dehazing correction intensity value based on fog intensity value, the first dark channel value corresponding to each pixel in the first dark channel image, or the brightness value corresponding to each pixel in the target image (step 140); obtaining a predicted transmittance value based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, and atmospheric light value (step 150); and obtaining an estimated dehazed image based on the predicted transmittance value, the target image, and atmospheric light value (step 160). For dehazed images, The target image (i.e., the foggy image). Atmospheric light value, Transmittance (transmittance is related to the defogging correction intensity value). These are the spatial coordinates in the image; based on the atmospheric scattering model, it can be known that... .

[0014] In one embodiment, please refer to Figure 2 , it is Figure 1 A schematic flowchart of an embodiment of step 110. For example... Figure 2As shown, the image dehazing method is applicable to dehazing on a per-filter-window basis. Therefore, step 110 may include: obtaining the first dark channel image corresponding to the target image (step 210); obtaining the size of the filter window (step 220); obtaining the lower limit channel value corresponding to each pixel in the first dark channel image through a default function (step 230); obtaining the first dark channel value of each pixel in the filter window corresponding to each pixel in the first dark channel image (step 240); and obtaining the second dark channel value corresponding to each pixel in the first dark channel image based on the lower limit channel value corresponding to each pixel in the first dark channel image and the first dark channel value of each pixel in the filter window, thereby obtaining the second dark channel image (step 250).

[0015] In one embodiment, step 210 may include: selecting the minimum RGB component value of each pixel in the target image to obtain a first dark channel image. Specifically, each pixel in the target image has values ​​for three color channels: red (R), green (G), and blue (B) (i.e., the values ​​of the R channel, G channel, and B channel). The minimum value of the RGB channel of each pixel in the target image (i.e., the minimum value of the RGB channel) is selected. ), to obtain the first dark channel image corresponding to the target image (e.g. Figure 3 As shown, Figure 3 This is a first dark channel image according to an exemplary embodiment of the present application, wherein the first dark channel image indicates the minimum value of the RGB channels for each pixel.

[0016] In one embodiment, the size of the filtering window described in step 220 can be adjusted according to actual needs. For an example, please refer to... Figure 3 The size of the filtering window can be, but is not limited to, [a certain value]. .

[0017] In one embodiment, step 230 calculates the minimum RGB channel value (i.e., the first dark channel value) of each pixel in the first dark channel image using a default function to obtain the lower limit channel value corresponding to each pixel in the first dark channel image. Specifically, since pixels with higher brightness values ​​have lower RGB channel minimum values ​​(i.e., the minimum RGB channel value...) The smaller the difference between the RGB channel value and the lower limit channel value, the lower the brightness value of the pixel, and the lower the minimum value of its RGB channel (i.e., the lower the brightness value). The larger the difference between the default function and the lower limit channel value, the better. Therefore, the default function can be, but is not limited to, a reciprocal function, and the actual default function can be adjusted according to actual needs. It should be noted that the lower limit channel value is a positive integer.

[0018] In one embodiment, the default function may be: ,in, This is the fittable coefficient, for example: 512 or 1024. See one example. Figure 3 ,when The minimum value of the RGB channels of a certain pixel is 512 (i.e.) When the value is 90, the lower limit channel value corresponding to the pixel is 85 (because the calculation result is rounded up unconditionally); when The minimum value of the RGB channels of a certain pixel is 512 (i.e.) When the value is 105, the lower limit channel value corresponding to the pixel is 101 (because the calculation result is rounded up unconditionally).

[0019] In one embodiment, step 240 involves selecting corresponding filter windows centered on each pixel in the first dark channel image (i.e., the center pixel) to obtain the first dark channel values ​​of all pixels within each filter window. For an example, please refer to... Figure 3 Using the minimum value of the RGB channels (i.e. The corresponding filter window is selected centered on the pixel with a value of 90 (e.g., ...). Figure 3 As shown in the thin frame 50 in the image), the first dark channel values ​​of all pixels included in the filtering window are 55, 90, 100, 50, 90, 100, 25, 40, and 40, respectively; with the minimum value of the RGB channels (i.e., The corresponding filter window is selected centered on the pixel with a value of 105 (e.g., ...). Figure 3 As shown in the thick outline 60 in the figure), the first dark channel values ​​of all pixels included in the filter window are 105, 105, 105, 102, 105, 105, 102, 105, 105, 105, 105, 105, respectively.

[0020] In one embodiment, step 250 may include: selecting a first dark channel value in the filter window corresponding to each pixel in the first dark channel image that is greater than or equal to the lower limit channel value as a candidate dark channel value corresponding to each pixel in the first dark channel image; and selecting the minimum value among all candidate dark channel values ​​corresponding to each pixel in the first dark channel image as a second dark channel value corresponding to each pixel in the target image. In one example, please refer to... Figure 3 When the default function is And when k is 512, the minimum value of the RGB channels (i.e. The lower limit channel value corresponding to a pixel with a value of 90 can be 85, and the minimum value of the RGB channel (i.e. The filter window corresponding to a pixel value of 90 (e.g.) Figure 3 The first dark channel values ​​of all pixels included within the thin frame 50 (shown in the figure) are 55, 90, 100, 50, 90, 100, 25, 40, and 40, respectively. Therefore, only the first dark channel values ​​of 90, 100, 90, and 100 can be used as the minimum values ​​of the RGB channels (i.e., The candidate dark channel values ​​corresponding to pixels with a value of 90 are given, and the minimum value among these candidate dark channel values ​​is 90, which makes the minimum value of the RGB channels (i.e., The second dark channel value corresponding to the pixel with a value of 90 is 90.

[0021] By obtaining the second dark channel value of each pixel through steps 230 to 250 above, the problem of existing dehazing algorithms that perform dehazing on a per-filter-window basis, which only perform minimum value filtering on the filter window to obtain the dark channel value of each pixel, can be solved. This results in halo effects easily occurring in areas with high brightness values ​​within the filter window after subsequent dehazing processing, and poor dehazing effects in areas with different fog concentrations after subsequent dehazing processing.

[0022] In one embodiment, the image dehazing method can be applied to dehazing on a single point basis. Therefore, step 110 may include: selecting the minimum component value of the RGB components of each pixel in the target image as its first dark channel value (i.e., To obtain the second dark channel image, the first dark channel value of each pixel in the target image is the corresponding second dark channel value of each pixel in the second dark channel image.

[0023] In one embodiment, step 120 may include: obtaining a default atmospheric light value; or setting an atmospheric light value; or selecting the brightness value of the target image corresponding to the pixel with the largest first dark channel value in the first dark channel image as the atmospheric light value; or selecting multiple brightness values ​​of the target image corresponding to a predetermined proportion of pixels with the highest to lowest first dark channel values ​​in the first dark channel image, and calculating the average of the multiple brightness values ​​as the atmospheric light value. Wherein, the atmospheric light value is either the default atmospheric light value (i.e., the built-in atmospheric light value) or a set atmospheric light value (i.e., the atmospheric light value currently set by the user, for example: When ), bandwidth can be saved because it is not necessary to traverse the entire first dark channel graph.

[0024] In one embodiment, the step of selecting a plurality of brightness values ​​of the target image corresponding to a plurality of pixels in the first dark channel image sorted from high to low, and calculating the average of the plurality of brightness values ​​as the atmospheric light value, may include: selecting the brightness values ​​of the target image corresponding to the first 0.1% of pixels in the first dark channel image sorted from high to low, and calculating their average as the atmospheric light value.

[0025] In one embodiment, step 130 may include: obtaining a default fog intensity value; or setting a fog intensity value; or based on the average dark channel value of the first dark channel map (i.e., ) or the average brightness value of the target image (i.e. , (The value of fog intensity is obtained as a brightness function, i.e., 1- ).in, or , When the brightness values ​​of the three channels (red, green, and blue) and the value of the first dark channel are each stored using F bits, H is 2. F -1, F is a positive integer (e.g., 8 or 10); when the fog intensity value is the default fog intensity value (i.e., the built-in fog intensity value) or the set fog intensity value (i.e., the fog intensity value currently set by the user (e.g., 0.5)), bandwidth can be saved because it is not necessary to traverse the entire first dark channel map.

[0026] In one embodiment, the fog intensity value (i.e., 1-) mentioned in step 130 Included in The dehazing correction intensity value obtained from formula (1) is such that the value obtained in step 140 is... It is obtained from formula (2).

[0027] (1) (2) In another embodiment, the fog intensity value (i.e., 1-) mentioned in step 130 Included in The dehazing correction intensity value obtained from formula (3) is such that the value obtained in step 140 is... Obtained from formula (4). Among them, pixels with dense fog will have a larger first dark channel value, therefore, It should be enlarged to improve defogging performance.

[0028] (3) (4) In one embodiment, since different pixels have different transmittance, especially for pixels with brighter luminance or second dark channel values, the transmittance is more inclined towards 1. Therefore, the estimated transmittance value in step 150 (i.e., ) can be obtained from formula (5), where, This is the value for the second dark channel.

[0029] (5) In another embodiment, this can be achieved by setting a pre-estimated value for the transmittance (i.e., ... The default range method (i.e., adding conditional constraints) avoids the estimated transmittance obtained by formula (5) (i.e., ) computational overflow occurs (i.e. In the case of a value greater than 1, step 150 may include: obtaining a predicted transmittance value based on the dehazing correction intensity value, the second dark channel value of each pixel in the second dark channel image, the atmospheric light value, and the default range. In one example, the predicted transmittance value (i.e., The default range for () can be greater than or equal to 0.1 and less than or equal to 1, but this example is not intended to limit this application. The estimated value of the actual transmittance (i.e. The default range can be adjusted according to actual needs.

[0030] In one embodiment, the estimated dehazed image described in step 160 (i.e. ) can be obtained from formula (6).

[0031] +A (6) Please see Figure 1 and Figure 4 , Figure 4 This is a schematic flowchart of an embodiment of the video dehazing method according to this application. Figure 1 and Figure 4 As shown, the video dehazing method includes the following steps: Each frame of the video is dehazed using the image dehazing method from steps 110 to 160; wherein, the atmospheric light values ​​corresponding to the first N frames of the video include: a default atmospheric light value, a set atmospheric light value, the brightness value of the target image corresponding to the pixel with the largest first dark channel value in the first dark channel image as the atmospheric light value, or multiple brightness values ​​of the target image corresponding to multiple pixels in the first dark channel image sorted from high to low according to a predetermined proportion, and the average of the multiple brightness values ​​is calculated as the atmospheric light value; the fog values ​​corresponding to the first N frames of the video... The fog intensity value includes: a default fog intensity value, a set fog intensity value, or a fog intensity value obtained based on the average dark channel value of the first dark channel image or the average brightness value of the target image; N is a positive integer; wherein, the atmospheric light value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the atmospheric light values ​​corresponding to the previous M frames; the fog intensity value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the fog intensity values ​​corresponding to the previous M frames; M is an integer less than or equal to N (step 410); and merging each frame image after dehazing into a dehazed video and outputting it (step 420).

[0032] In other words, in step 410, the atmospheric light value and fog intensity value used in the current frame image can be obtained by weighted averaging of the atmospheric light value and fog intensity value of the previous few frames. Therefore, in one embodiment, when performing dehazing processing on each frame image after the first N frames in the video, the atmospheric light value and fog intensity value corresponding to the next frame image are calculated simultaneously.

[0033] Please see Figure 5 This is a block diagram of an embodiment of a terminal device according to this application. Figure 5 As shown, the terminal device 500 includes one or more processors 510 and a memory 520, the memory 520 being used to store one or more computer programs 530. When the one or more computer programs 530 are executed by the one or more processors 510, the one or more processors 510 perform... Figure 1 Image dehazing methods or Figure 4 The video dehazing method.

[0034] This application also provides a storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the image dehazing method or video dehazing method provided in the above embodiments. The storage medium is a non-transitory storage medium and may include various media capable of storing program code, such as a USB flash drive, external hard drive, read-only memory (ROM), magnetic disk, or optical disk.

[0035] In summary, the image dehazing method in this application is suitable for dehazing on a single point or filter window basis, avoiding the halo effect caused by dehazing on a filter window basis. Furthermore, the image dehazing method of this application performs image dehazing by estimating the transmittance based on the dehazing correction intensity value, ensuring that high-brightness areas in a foggy image retain appropriate brightness after dehazing, and that areas with different fog concentrations show good dehazing effects. In addition, the image dehazing method can also be applied to dehaze each frame of a video to obtain a dehazed video. Moreover, when the atmospheric light value and / or fog intensity value used by the image dehazing method are default or user-defined, the process of traversing the dark channel map can be eliminated, saving bandwidth.

[0036] Although the components described above are included in the drawings of this application, it is not excluded that more additional components may be used to achieve better technical effects without departing from the spirit of the invention.

[0037] While the present invention has been described using the above embodiments, it should be noted that these descriptions are not intended to limit the invention. Rather, this invention encompasses modifications and similar arrangements that are obvious to those skilled in the art. Therefore, the scope of the claims should be interpreted in the broadest possible sense to include all obvious modifications and similar arrangements.

Claims

1. An image defogging method, characterized by, Includes the following steps: The second dark channel image corresponding to the target image is obtained based on the first dark channel value corresponding to each pixel in the target image; Obtain atmospheric light values; Obtain the fog intensity value; Using formula Get the dehazing correction intensity value ,in, The fog intensity value is... The global fog concentration estimate and min ( H is the first dark channel value, which is the minimum value of the red, green, and blue color channels of each pixel; when the first dark channel values ​​of the red, green, and blue channels are each stored using F bits, H is 2. F -1, where F is a positive integer; Based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, and the atmospheric light value, an estimated transmittance value is obtained; and An estimated dehazed image is obtained based on the estimated transmittance, the target image, and the atmospheric light value; The step of obtaining the second dark channel image of the target image based on the first dark channel value corresponding to each pixel in the target image includes: Obtain the first dark channel image corresponding to the target image; Get the size of the filtering window; The lower limit channel value corresponding to each pixel in the first dark channel image is obtained through a default function, wherein the default function is: , Min is the fittable coefficient. ( ) is the value of the first dark channel; Obtain the first dark channel value of each pixel in the filter window corresponding to each pixel in the first dark channel image; and Based on the lower limit channel value corresponding to each pixel in the first dark channel image and the first dark channel value of each pixel in the filter window, the second dark channel value corresponding to each pixel in the first dark channel image is obtained, and then the second dark channel image is obtained. The step of obtaining the second dark channel value corresponding to each pixel in the first dark channel image based on the lower limit channel value corresponding to each pixel in the first dark channel image and the first dark channel value of each pixel in the filter window includes: The first dark channel value, which is greater than or equal to the lower limit channel value, is selected from the filtering window corresponding to each pixel in the first dark channel image as the candidate dark channel value corresponding to each pixel in the first dark channel image; and The minimum value among all candidate dark channel values ​​corresponding to each pixel in the first dark channel image is selected as the second dark channel value corresponding to each pixel in the first dark channel image.

2. The image dehazing method as described in claim 1, characterized in that, The step of obtaining the estimated transmittance based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, and the atmospheric light value includes: Based on the dehazing correction intensity value, the second dark channel value corresponding to each pixel in the second dark channel image, the atmospheric light value, and the default range, the estimated value of the transmittance is obtained.

3. The image dehazing method as described in claim 1, characterized in that, The steps for obtaining atmospheric light values ​​include: Get the default atmospheric light value; or Set the atmospheric light value; or The brightness value of the target image corresponding to the pixel with the largest first dark channel value in the first dark channel image is selected as the atmospheric light value; or In the first dark channel image, a predetermined proportion of pixels corresponding to the target image are selected from the first dark channel values ​​sorted from high to low, and the average value of the multiple brightness values ​​is calculated as the atmospheric light value.

4. A video dehazing method, characterized in that, Includes the following steps: The image dehazing method according to any one of claims 1 to 2 is used to dehaze image frames in a video; wherein, the atmospheric light value corresponding to the first N frames of the video includes: a default atmospheric light value, a set atmospheric light value, a brightness value of the target image corresponding to the pixel with the largest first dark channel value in the first dark channel image as the atmospheric light value, or multiple brightness values ​​of the target image corresponding to multiple pixels with a predetermined proportion of first dark channel values ​​sorted from high to low in the first dark channel image, and the average of the multiple brightness values ​​is used as the atmospheric light value; the fog intensity value corresponding to the first N frames of the video is , The estimated global fog concentration is and min ( H is the first dark channel value, which is the minimum value of the red, green, and blue color channels of each pixel; when the first dark channel values ​​of the red, green, and blue channels are each stored using F bits, H is 2. F -1, F is a positive integer; N is a positive integer; wherein, the atmospheric light value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the atmospheric light values ​​corresponding to the preceding M frames; the fog intensity value corresponding to each frame image after the first N frames in the video is obtained by weighted averaging of the fog intensity values ​​corresponding to the preceding M frames; M is an integer less than or equal to N; and Each frame of the image after dehazing is merged into a dehazed video and then output.

5. The video defogging method of claim 4, wherein, When performing dehazing on each frame after the first N frames in the video, the atmospheric light value and the fog intensity value corresponding to the next frame are calculated simultaneously.