A method and apparatus for image dehazing correction based on dark channel
By using an image dehazing correction method based on the dark channel, the problem of distortion in the sky region was solved, achieving clear and accurate image correction and improving image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QUANZHOU INST OF EQUIP MFG
- Filing Date
- 2022-12-28
- Publication Date
- 2026-07-03
AI Technical Summary
Existing techniques ignore distortion in the sky region during image dehazing correction, resulting in problems such as oversaturation of the sky region in the corrected image, which reduces the quality of image correction.
An image dehazing correction method based on the dark channel is adopted, which removes artifact regions and improves image quality through color correction, dark channel sky segmentation, morphological skeleton calculation and region growing.
It effectively reduces distortion in the sky area, improves image correction quality, obtains a clear and accurate sky area, and enhances the overall image correction effect.
Smart Images

Figure CN116228563B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and specifically to an image dehazing correction method and apparatus based on the dark channel. Background Technology
[0002] As people's demands for image quality continue to increase, how to preserve the true information of an image as much as possible and effectively correct for interference factors has become an urgent problem to be solved. In particular, due to the low temperatures on winter mornings, the water vapor in the air exceeds saturation, causing the excess water vapor to clump together or combine with tiny dust particles in the air, eventually forming fog. The presence of fog not only restricts human vision, but images taken in such weather also suffer from significant distortion. Although existing technologies have methods for image dehazing correction, they often neglect the distortion of the sky area, resulting in problems such as oversaturation of the sky area in the corrected image, significantly reducing the quality of image correction. Summary of the Invention
[0003] Therefore, the technical problem to be solved by the present invention is to overcome the shortcomings of the prior art, which ignores the distortion of the sky region, resulting in the sky region being oversaturated in the corrected image and greatly reducing the quality of image correction. Thus, the present invention provides an image dehazing correction method and apparatus based on the dark channel.
[0004] According to a first aspect, embodiments of the present invention provide an image dehazing correction method based on the dark channel, the method comprising:
[0005] Obtain the target image to be processed;
[0006] Color correction is performed on the color channels of the target image to obtain a color-corrected first image;
[0007] The RGB color system of the first image is switched to the CIE color system to obtain the second image, and the sky segmentation based on the dark channel is performed on the second image to obtain the baseline sky segmentation region.
[0008] The morphological skeleton of the baseline sky segmentation region is calculated to obtain the morphological skeleton result.
[0009] Based on the skeleton branches and endpoints of the morphological skeleton results, various sub-points in the region growth process are calculated.
[0010] Region growing is performed on each of the seed points in the baseline sky segmentation region to obtain the fourth image;
[0011] Based on the fourth image, artifact regions in the baseline sky segmentation region are identified and removed to obtain a corrected image.
[0012] Optionally, the step of performing dark channel-based sky segmentation on the second image to obtain a baseline sky segmentation region includes:
[0013] Calculate the gradient magnitude of the second image based on the brightness channel;
[0014] The local Shannon entropy is calculated based on the gradient magnitude.
[0015] Logical operations are performed on the local Shannon entropy and dark channel to obtain the baseline sky segmentation region.
[0016] Optionally, the method further includes:
[0017] Exposure correction is performed on the fourth image to obtain the final image.
[0018] Optionally, the exposure correction of the fourth image to obtain the final image includes:
[0019] Based on the fourth image, obtain its inverted image;
[0020] Forward illumination estimation is performed on the baseline sky segmentation region to obtain the seventh image;
[0021] The seventh image is subjected to overexposure correction to obtain a first corrected image;
[0022] The reversed image is subjected to backlight estimation to obtain the eighth image;
[0023] The eighth image is subjected to underexposure region correction to obtain a second corrected image;
[0024] The final image is obtained by fusing the first corrected image and the second corrected image.
[0025] Optionally, the step of fusing the first corrected image and the second corrected image to obtain the final image includes:
[0026] The normally exposed area in the baseline sky segmentation region is obtained to produce the ninth image;
[0027] Visual quality maps are calculated for the ninth image, the first corrected image, and the second corrected image respectively, to obtain the corresponding first visual quality map, second visual quality map, and third visual quality map;
[0028] The first visual quality image, the second visual quality image, and the third visual quality image are fused to obtain the final image.
[0029] Optionally, the step of performing color correction based on the color channels of the target image to obtain a color-corrected first image includes:
[0030] Based on the principle of minimum color loss, a color transfer image is derived from the target image;
[0031] Based on the maximum attenuation map and the color transfer image, color correction is performed to obtain the first image.
[0032] Optionally, before performing color correction based on the color channels of the target image to obtain a color-corrected first image, the method further includes:
[0033] Obtain the width and height of the target image;
[0034] Based on the width and height of the target image, the color cast factor is calculated;
[0035] Based on the color cast factor results, the target image is subjected to color cast detection and judgment to determine whether the target image has a color cast.
[0036] When the target image has a color cast, color correction is performed based on the color channels of the target image to obtain a color-corrected first image.
[0037] According to a second aspect, embodiments of the present invention provide an image dehazing correction apparatus based on the dark channel, the apparatus comprising:
[0038] The acquisition module is used to acquire the target image to be processed;
[0039] The first processing module is used to perform color correction based on the color channels of the target image to obtain a color-corrected first image.
[0040] The second processing module is used to switch the RGB color system of the first image to the CIE color system to obtain the second image, and to perform sky segmentation based on the dark channel on the second image to obtain the baseline sky segmentation region.
[0041] The third processing module is used to perform morphological skeleton calculation on the baseline sky segmentation region to obtain the morphological skeleton result.
[0042] The fourth processing module is used to calculate various sub-points in the region growth process based on the skeleton branches and endpoints of the morphological skeleton result.
[0043] The fifth processing module is used to perform region growing on each of the seed points in the baseline sky segmentation region to obtain the fourth image;
[0044] The sixth processing module is used to determine the artifact regions in the baseline sky segmentation region based on the fourth image, and remove the artifact regions to obtain a corrected image.
[0045] According to a third aspect, embodiments of the present invention provide an electronic device, comprising:
[0046] A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the method described in the first aspect, or any alternative embodiment of the first aspect.
[0047] According to a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer instructions for causing a computer to perform the method described in the first aspect, or any optional embodiment of the first aspect.
[0048] The technical solution of this invention has the following advantages:
[0049] The present invention provides an image dehazing correction method and apparatus based on dark channel, which involves: acquiring a target image to be processed; performing color correction based on the color channels of the target image to obtain a color-corrected first image; switching the RGB color system of the first image to the CIE color system to obtain a second image; performing sky segmentation based on the dark channel on the second image to obtain a baseline sky segmentation region; performing morphological skeleton calculation on the baseline sky segmentation region to obtain a morphological skeleton result; calculating various sub-points in the region growing process based on the skeleton branches and endpoints of the morphological skeleton result; performing region growing on each of the seed points in the baseline sky segmentation region to obtain a fourth image; and determining the artifact regions in the baseline sky segmentation region based on the fourth image and removing the artifact regions to obtain a corrected image. By performing color cast correction on the target image, a preliminary correction is performed, ensuring the subsequent accurate correction image. A second image is obtained by switching the color system, and morphological skeleton calculation is performed on the second image to determine various sub-points in the region growth process. Based on these sub-points, a fourth image is determined. On this basis, a dark channel-based artifact removal operation is performed on the baseline sky segmentation region, significantly reducing the possibility of sky distortion. This not only yields a corrected image with a clear and accurate sky region but also further improves the image correction quality. Attached Figure Description
[0050] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0051] Figure 1 This is a flowchart of an image dehazing correction method based on the dark channel according to an embodiment of the present invention;
[0052] Figure 2 This is a schematic diagram of the structure of the image dehazing correction device based on the dark channel according to an embodiment of the present invention;
[0053] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0054] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," "third," "fourth," "fifth," "sixth," "seventh," "eighth," and "ninth" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0056] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can also refer to the internal connection of two components; and they can refer to a wireless connection or a wired connection. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0057] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0058] This invention provides an image dehazing correction method based on the dark channel, such as... Figure 1 As shown, the image dehazing correction method based on the dark channel specifically includes the following steps:
[0059] Step S101: Obtain the target image to be processed;
[0060] Step S102: Perform color correction based on the color channels of the target image to obtain the first color-corrected image.
[0061] Specifically, in practical applications, when an image containing fog or haze is input, to ensure the subsequent dehazing effect, this embodiment of the invention will first perform color correction on the target image and output a first image containing normal colors after color correction. By performing color correction first, an image color standard is established in the early stage, providing a preliminary guarantee for obtaining a high-quality image with accurate dehazing later.
[0062] Step S103: Switch the RGB color system of the first image to the CIE color system to obtain the second image, and perform sky segmentation based on the dark channel on the second image to obtain the baseline sky segmentation region.
[0063] Specifically, in practical applications, embodiments of the present invention will first perform a dark channel prior on the second image. The dark channel prior is based on statistics from outdoor fog-free images. In most local areas without sky coverage, some pixels (called marker pixels) typically have very low intensity in at least one color (RGB) channel. In a blurred image, the intensity of these dark pixels in this channel is mainly due to atmospheric light. Therefore, these dark pixels can directly provide an accurate estimate of haze transmission, assisting in guiding the recovery of fog-free images.
[0064] Considering the discrepancies between colors, this embodiment of the invention will first switch the color system. Since the most commonly used color space is RGB, but RGB has disadvantages such as being unintuitive, uneven, and device-dependent, this embodiment of the invention uses the CLELab color space established by the International Commission on Illumination in 1976. The distance between colors calculated by this space is basically consistent with the actual perceived difference, further ensuring the accuracy of the subsequent dehazing correction results.
[0065] Step S104: Perform morphological skeleton calculation on the baseline sky segmentation region to obtain the morphological skeleton result.
[0066] Step S105: Based on the skeleton branches and endpoints of the morphological skeleton result, calculate various sub-points in the region growth process.
[0067] Step S106: Perform region growing on each of the seed points in the baseline sky segmentation region to obtain the fourth image.
[0068] Specifically, in practical applications, in order to accurately obtain the basic structure of the baseline sky segmentation region, it is necessary to perform morphological skeleton structure. In this embodiment of the invention, morphological skeleton calculation is performed to determine various sub-points for region growth, and finally the optimized sky region is obtained.
[0069] Step S107: Based on the fourth image, determine the artifact regions in the baseline sky segmentation region, and remove the artifact regions to obtain the corrected image.
[0070] By performing the above steps, the image dehazing correction method based on the dark channel provided in this embodiment of the invention corrects the target image by performing color cast correction, thus ensuring the subsequent accurate correction image. A second image is obtained by switching the color system, and morphological skeleton calculation is performed on the second image to determine various sub-points in the region growth process. A fourth image is determined based on these sub-points. On this basis, a dark channel-based artifact removal operation is performed on the baseline sky segmentation region, which greatly reduces the possibility of sky distortion. This not only yields a corrected image containing a clear and accurate sky region but also further improves the image correction quality.
[0071] Specifically, in one embodiment, before performing the above step S102 to perform color correction based on the color channels of the target image to obtain the color-corrected first image, the following steps are further included:
[0072] Step S201: Obtain the width and height of the target image.
[0073] Step S202: Calculate the color cast factor based on the width and height of the target image.
[0074] Step S203: Based on the color cast factor results, perform color cast detection on the target image to determine whether the target image has a color cast.
[0075] Step S204: When the target image has a color cast, perform color correction based on the color channels of the target image to obtain a color-corrected first image.
[0076] Specifically, in practical applications, since the choice of color space needs to measure the degree of deviation between two colors, it is necessary to first select a suitable color space before performing color cast detection and subsequent color correction. The most commonly used space is the RGB color space, but the RGB space has disadvantages such as being unintuitive, non-uniform, and device-dependent. This embodiment of the invention uses the CLELab color space established by the International Commission on Illumination in 1976 as an example. The distance between colors calculated by this space is basically consistent with the actual perceived difference, but the actual situation is not limited to this, and the color space can be changed according to the actual correction requirements. The Lab color in the CLELab color space consists of a luminance component and two chromaticity components, namely the a component (from green to red) and the b component (from blue to yellow). Specifically, the conversion from RGB space to Lab space can be achieved in three steps:
[0077] (1) Convert from 24-bit true color RGB space to sRGB (standard red green blue) space. sRGB space is a standard RGB space and is the most widely used color space on computers.
[0078] (2) Convert the sRGB space to the XYZ space through linear transformation. The XYZ space is a device-independent "transition" color space.
[0079] (3) Convert the XYZ space to the Lab space.
[0080] This invention employs a color cast detection method based on equivalent circles to examine the color cast of haze images. The color cast of an image is directly related not only to the average value of its chromaticity but also to its chromaticity distribution characteristics. It is indicated that if the chromaticity distribution in the two-dimensional histogram on the ab chromaticity coordinate plane is essentially a single peak or relatively concentrated, and the average chromaticity value is large, color cast generally exists, and the larger the average chromaticity value, the more severe the color cast.
[0081] Therefore, the concept of an equivalent circle is introduced, and the ratio of the image's average chromaticity D to the chromaticity center distance, i.e., the color cast factor K, is used to measure the degree of color cast in the image. The higher the K value exceeds 1.5, the more severe the color cast.
[0082] The specific calculation method is as follows:
[0083]
[0084]
[0085]
[0086]
[0087]
[0088] Where M and N are the width and height of the image, respectively, in pixels; d a d b Let be the center coordinates of the equivalent circle on the ab chromaticity plane, denoted as (d a d b R is the radius of the equivalent circle; D is the distance from the center of the equivalent circle to the origin of the neutral axis of the ab chromaticity plane (a=0, b=0).
[0089] The exact position of the equivalent circle on the ab chromaticity plane is calculated to determine the overall color cast of the image. Specifically, when d... a >0 indicates a reddish tint; otherwise, a greenish tint. b >0 indicates a yellowish tint; otherwise, a bluish tint.
[0090] Specifically, in one embodiment, step S102 above performs color correction based on the color channels of the target image to obtain a color-corrected first image, which specifically includes the following steps:
[0091] Step S301: Based on the principle of minimum color loss, derive the color transfer image from the target image.
[0092] Step S302: Based on the maximum attenuation map and the color transfer image, perform color correction to obtain the first image.
[0093] Specifically, in practical applications, in local adaptive color correction, the haze image is first converted into a detail image (DI), an attenuation image (AM), and three redefined color channels. Specifically, in this embodiment of the invention, color compensation is first performed based on the principle of minimum color loss. The color-compensated image derived from the three redefined color channels is considered a color transfer image (i.e., a color-transferred image). Then, a fusion strategy is guided by adaptively blending the detail image, attenuation image, and color transfer image based on the maximum attenuation image, ultimately obtaining the first color-corrected image.
[0094] Specifically, it includes two core steps:
[0095] (1) First, the color transfer image is derived from the haze image using the principle of minimum color loss, avoiding the use of clear, haze-free images as reference images;
[0096] (2) Based on a maximum attenuation map-guided fusion method, a color-transferred image is used to simultaneously adjust the color and details of the haze image locally to obtain a color-corrected image, while considering the loss of light absorption and contour information caused by forward scattering. The specific implementation process is as follows:
[0097] 1) Principle of minimum color loss:
[0098] First, red, green, and blue channels are redefined based on their average values, where the average values of the red, green, and blue channels are respectively expressed as:
[0099]
[0100] Where H and W are the height and width of the input image I, respectively; I c (i, j) represents the pixel value of each channel of the input image I within its length and width range.
[0101] It should be noted that, based on this, the embodiments of the present invention define the color channels with the maximum mean, medium mean, and minimum mean as large color channels I, respectively. l Medium color channel I m and small color channel I s Since all color channels of an image with natural colors have similar mean and histogram distributions, the principle of minimum color loss, inspired by the gray world hypothesis, is used. Based on this principle, the total color loss Lcolor between large color channels and medium and small color channels is defined as:
[0102]
[0103] in, For large color channel I l The mean; For the middle color channel I m The mean; For large color channel I s The mean.
[0104] Specifically, the color channels with the maximum mean, median mean, and minimum mean can be calculated using formula (6), and the calculation results are sorted to obtain the maximum mean, median mean, and minimum mean.
[0105] Since color loss is also a constraint of adaptive color compensation, and because the attenuation of the large color channel is less than that of the other two color channels, a simple linear transfer is used to increase the dynamic range of the large color channel, which can be expressed as:
[0106]
[0107] in, For the corrected large color channel; These are the minimum and maximum pixel values of the input image I, respectively; Set the stretch range to 0 and 255 respectively.
[0108] For the other two color channels Im and I s Because they are larger than the large color channel I l The color attenuation is even more severe, so the following formula is used for color compensation, and the compensation process is expressed as follows:
[0109]
[0110] in, These are the mid-color channel and the small-color channel after color compensation, respectively.
[0111] To ensure that the average value and histogram distribution of each color channel are similar, embodiments of the present invention iteratively apply the above color compensation equation until the condition is met:
[0112]
[0113] in, for and Minimum norm of the difference; for and The minimum norm of the difference.
[0114] Iteratively optimize the two color compensation equations and finally pass the above minimization equation, while updating... Until convergence. Furthermore, in this embodiment of the invention, the compensated color channels are further stretched to obtain a color transfer image I. CT .
[0115] 2) Maximum attenuation map-guided fusion:
[0116] Since the gray world assumption ignores wavelength-dependent light absorption, it may introduce some unwanted color distortion. Therefore, color correction of hazy images also needs to fully consider wavelength dependence. To accurately estimate the wavelength-dependent attenuation level, embodiments of the present invention consider different light attenuations and select the maximum attenuation map as the guiding image for color transfer. The maximum attenuation map can be represented as:
[0117]
[0118] Here, γ is a parameter that controls the intensity of the received light, with a default value of 1.2.
[0119] The maximum attenuation map-guided fusion strategy fully utilizes the color transfer image to locally adjust the colors of the input image, while considering the detail loss caused by forward scattering. It can be expressed as:
[0120]
[0121] in, This is the final color-corrected image for a specific c color channel; A color transfer image for a specific c color channel; The maximum attenuation map is obtained from formula (11); D c For blurred version of the image; G c is a Gaussian kernel; c is the color channel index, c∈{R,G,B}.
[0122] By combining the images from the three color channels, the final result is I. CC (The final color-corrected image, i.e., the first image), in addition, I is also generated during the color correction process. CT I CT The color transfer image is obtained by formulas (8) and (9).
[0123] Specifically, D c D is a blurred version of the input image after subtracting a Gaussian kernel. c =I c -G c *I c , where * represents the convolution operation.
[0124] Specifically, in practical applications, the color correction algorithm of this invention can not only correct the color of haze images, but also has very accurate color correction results for underwater images and other images with color cast.
[0125] This invention combines color cast detection and color correction to judge the input haze image, and performs preliminary correction on the image based on the judgment result to obtain a haze image with normal color. Subsequently, the color-corrected image is dehazed.
[0126] Specifically, in one embodiment, step S103 above performs sky segmentation based on the dark channel on the second image to obtain a baseline sky segmentation region, which specifically includes the following steps:
[0127] Step S401: Calculate the gradient magnitude of the second image based on the luminance channel.
[0128] Step S402: Calculate the local Shannon entropy based on the gradient magnitude.
[0129] Step S403: Perform logical operations on the local Shannon entropy and dark channel to obtain the baseline sky segmentation region.
[0130] Specifically, in practical applications, the dark channel prior is based on statistics from outdoor haze-free images. In most local areas without sky cover, some pixels (called marker pixels) typically have very low intensity in at least one color (RGB) channel. In a blurred image, the intensity of these dark pixels in this channel is primarily due to atmospheric light. Therefore, these dark pixels can directly provide an accurate estimate of haze transmission, thus aiding in the recovery of haze-free images. The theory behind the dark channel prior is as follows:
[0131] In computer vision and computer graphics, the model widely used to describe the formation of haze images is:
[0132] I(x)=J(x)t(x)+A(1-t(x)) (13)
[0133] Where I represents the observed (foggy) image; J represents the clear (foggy) image; A represents global atmospheric light; and t represents the medium transmission that describes the portion of light that is not scattered and reaches the camera.
[0134] The goal of defogging is to recover J, A and t from I. Given a foggy image I, we only need to find the transmittance t and atmospheric light A, then we can use formula (13) to calculate the fog-free image.
[0135] In formula (13), the first term J(x)t(x) on the right-hand side is called direct attenuation, and the second term A(1-t(x)) is called atmospheric light. Direct attenuation describes the scene radiation and its attenuation in the medium, while atmospheric light is generated by the previously scattered light and produces changes in the scene color. When the atmosphere is homogeneous, the transmittance t can be expressed as:
[0136] t(x)=e -βd(x) (14)
[0137] Where β is the atmospheric scattering coefficient and d is the scene depth. Equation (14) shows that scene radiation decreases exponentially with scene depth.
[0138] The haze imaging equation (13) implies that in the RGB color space, vectors A, I(x), and J(x) are coplanar, and their endpoints are collinear. Transmittance t is the ratio of the two line segments:
[0139]
[0140] The image J is formally defined as follows:
[0141]
[0142] Among them, J c Ω(x) is the value on the color channel of J; Ω(x) is the local patch centered at x.
[0143] Except for the sky region, if J is a fog-free outdoor image, the intensity of the dark channel of J is low and tends to zero: J dark →0. J is called dark For the dark channel J, the above content is the dark channel prior.
[0144] When J is a haze-free image, the dark channel of J is close to zero:
[0145]
[0146] Because atmospheric light A has a value of A in the color channel c Always being positive will lead to:
[0147]
[0148] In fact, even on clear days, the atmosphere is not completely free of particles. That is, when we look at distant scenes, haze is still present. Furthermore, the presence of haze is a fundamental clue for human perception of depth, a phenomenon known as aerial perspective. Therefore, completely removing haze might make the image appear unnatural and lose its original sense of depth. Taking these issues into full consideration, this embodiment of the invention introduces a constant parameter ω (0 < ω ≤ 1) to selectively retain a very small amount of haze for distant objects, thereby adaptively retaining more haze for distant objects. The value of ω can be set according to actual needs; for example, ω = 0.95. The specific haze calculation formula is as follows:
[0149]
[0150] The Dark Channel Prior (DCP) algorithm mentioned above has achieved significant results in image dehazing, but it has three main limitations: (1) high processing time, (2) artifact generation, and (3) oversaturation of the sky region. Therefore, in order to improve the processing time without reducing the restoration quality and avoid image artifacts in the image dehazing process, it is necessary to perform sky detection and segmentation on hazy images.
[0151] The overall process of sky reconnaissance segmentation is described below:
[0152] This method is based on two assumptions about the sky region in outdoor images of haze:
[0153] (1) The distance of the sky region is close to infinite, so the corresponding transmittance is close to 0, and the corresponding dark channel value is approximately 1.
[0154] (2) The sky region is mainly uniform; therefore, its corresponding local Shannon entropy approaches 0.
[0155] Under these two assumptions, this embodiment of the invention employs a novel two-stage method for calculating an initial dark channel map and an improved dark channel map. The first stage aims to calculate initial values for the dark channel, atmospheric light, and sky region masks. The second stage utilizes sky detection segmentation to obtain an improved dark channel map, atmospheric light, and an improved transmission map. Each stage is detailed below:
[0156] In the first stage, the corresponding dark channel with initial atmospheric light and sky mask can be obtained from the input image. The specific process is as follows:
[0157] (1) Estimate the initial atmospheric light.
[0158] (2) Calculate the initial dark channel using the initial atmospheric light and formula (16).
[0159] (3) Using the local Shannon entropy and dark channel criterion described in the latter part of the sky region detection and segmentation, the sky region mask s is detected, segmented, and obtained. i .
[0160] Square window Ω k Local Shannon entropy on Defined as:
[0161]
[0162] Where L is The number of possible values for a pixel (L = 256 in a grayscale image); For grayscale value j to appear in Ω k The probability in, where is an s×s square window centered at pixel k, n j Ω k The median value is the number of pixels j.
[0163] The second stage involves using the detected sky region s i Calculation of improved atmospheric light A 1 and transmission diagram Finally, the scattering model is applied as follows:
[0164] (1) Based on the detected sky region s i Estimate atmospheric light A 1 As input image I i The middle belongs to the sky region s i The average value of the pixels. If no sky area is detected, then A 1 The value is specified as A 1 =[1 1 1].
[0165] (2) Using A 1 Calculate the dark channel using formula (16)
[0166] (3) Based on dark channel Calculate coarse transmission As shown below:
[0167]
[0168] (4) Use FGF for and y i Calculate the final refined transfer rate Where y i This represents an RGB haze image.
[0169] The Fast Guided Filter (FGF) is a type of edge-preserving linear smoothing filter, defined as:
[0170]
[0171] Where, q i For the filtered output image; I i The image is the guide image; i is the pixel position; k is the index of the local square window Ω, with a size of s×s. k and b k Ω k The linear coefficients in the equation are constants. Given a filtered input image p, the filter minimizes the reconstruction error between p and q as follows:
[0172]
[0173] Where, μ k For image I in Ω k The mean of σ; k For image I in Ω k The variance in; For filtering the input image p at Ω k The average value in the equation; ∈ is the regularization parameter that controls the smoothness.
[0174] (5) By using an improved transmission map and atmospheric light A 1 Applying a scattering model to retrieve the restored image J i .
[0175] Based on the above operations, this embodiment of the invention will detect and segment the sky region:
[0176] The sky detection-segmentation process consists of two stages: detection and segmentation of the baseline sky region, and refinement or improvement of the sky region. The specific process is as follows:
[0177] The first phase involves detecting and segmenting the baseline sky region:
[0178] (1) In order to obtain accurate gradient information, the input image I i Convert from its RGB color model to the corresponding CIELab color space
[0179] (2) Gradient magnitude G i In the luminance (L) channel The calculation above, the specific formula is as follows:
[0180]
[0181] Among them, Gx i Gy i The Sobel operator is defined as follows:
[0182]
[0183] (3) Calculate G using formula (20) i Local Shannon entropy E on i .
[0184] (4) Assume E in the sky region i →0, then the local Shannon entropy map is binarized.
[0185] (5) Considering the sky area The dark channel mapping is binarized.
[0186] (6) Combining using the AND logical operator (∧) and Obtain the baseline sky segmentation region S i .
[0187] In the second stage, the sky area is refined and improved through morphological manipulation.
[0188] (1) In order to obtain the baseline sky segmentation region S i Its morphological skeleton must be calculated. The morphological skeleton result is obtained.
[0189] (2) Through The OR logical operator (∨) calculates and combines skeleton branches and endpoints to obtain the seed point sd used in the region growing process. i .
[0190] (3) By using edge thresholds to apply G i Binarization is performed to calculate the edge image e. i .
[0191] (4) To avoid e i The possible discontinuities in e iThe morphological expansion is performed using structuring element B, as shown in the following formula:
[0192] de i =δ B (e i (26)
[0193] (5) By and de i The AND (∧) operation is used to remove artifact regions (i.e., false edges).
[0194] (6) Region growing is used to calculate the accurate sky region. Region growing checks the neighboring pixels of the initial seed point.
[0195] (7) By applying the morphological opening operation, false sky areas are removed, and finally a clear, fog-free image with sky artifacts and oversaturation is obtained.
[0196] Based on the dark channel prior, this invention performs accurate detection and segmentation of the sky region, and removes artifact regions in the sky region based on region growing. While ensuring the quality of the restored image, it also avoids the interference of image artifacts during the image dehazing process, thus improving the dehazing efficiency.
[0197] However, due to underexposure of the dehazed image during dark channel processing, this embodiment of the invention will process the low-brightness image after dehazing.
[0198] Specifically, in one embodiment, the image dehazing correction method based on the dark channel provided by the present invention further includes the following steps:
[0199] Step S501: Perform exposure correction on the fourth image to obtain the final image.
[0200] Specifically, in one embodiment, step S501 above includes the following steps:
[0201] Step S601: Based on the fourth image, obtain its inverted image.
[0202] Step S602: Perform forward illumination estimation on the baseline sky segmentation region to obtain the seventh image.
[0203] Step S603: Perform overexposure correction on the seventh image to obtain the first corrected image.
[0204] Step S604: Perform backlight estimation on the inverted image to obtain the eighth image.
[0205] Step S605: Perform underexposure region correction on the eighth image to obtain a second corrected image.
[0206] Step S606: Fuse the first corrected image and the second corrected image to obtain the final image.
[0207] Specifically, in practical applications, this embodiment of the invention first predicts the forward illumination of the input image and the reverse illumination of the reverse input image, respectively. From the estimated forward and reverse illumination, two intermediate exposure-corrected images of the input image are recovered: one recovers overexposed areas, and the other recovers underexposed areas. Finally, the two intermediate exposure-corrected images and the locally optimal exposure portion of the input image are fused into a globally well-exposed image. The specific processing procedure is as follows:
[0208] (1) Two-illuminance estimation:
[0209] The dual illumination estimation method employed is based on the assumptions in Retinex image enhancement, which assume that an image I (normalized to [0,1]) can be characterized as the desired enhanced image I′ and a single-channel illumination map L:
[0210] I = I′ × L (27)
[0211] Where × represents pixel-by-pixel multiplication.
[0212] Based on the above assumptions, image enhancement can be simplified to an illumination estimation problem. When the single-channel illumination map (i.e., illumination map) L is known, the required image I′ can be recovered accordingly.
[0213] Specifically, in practical applications, in order to correct underexposed areas in the input image I, its inverted image I will first be obtained. inv =1-I, and estimate the corresponding illumination pattern L. inv .pass Calculate the overexposure-corrected image I′ inv And restore the required underexposed corrected image I′=1-I′ inv .
[0214] It should be noted that the inverted input image is usually an unrealistic image, but the recovered underexposure-corrected image is realistic. By performing illumination estimation on the inverted input image, the underexposure image is successfully corrected.
[0215] Based on this, this embodiment of the invention addresses the problem that the input image may have partial underexposure and overexposure by designing dual illuminance estimation. The first pass estimates the forward illuminance of the input image to correct overexposure areas; the second pass estimates the reverse illuminance of the input image to correct underexposure areas.
[0216] (2) Illuminance estimation framework
[0217] To estimate the illuminance of a given image I, we first use the largest RGB color channel as the illuminance value for each pixel to obtain the initial illumination map L′, denoted as:
[0218]
[0219] in, Let c be the color channel at pixel p.
[0220] Specifically, the reason why the maximum color channel is used as the initial illumination in this embodiment of the invention is that, according to I′=I×L′ -1 Lower illumination levels may risk sending color channels of the recovered image outside the color gamut. The rich detail and texture in the initial illuminance map are not due to uneven illumination, making the recovered result unrealistic. Therefore, the final illuminance map L is obtained by preserving prominent structures and removing redundant texture details, defined as:
[0221]
[0222] Among them, L p This represents the value of the final illuminance map L at pixel p; The spatial derivative in the horizontal direction; w is the spatial derivative in the vertical direction. x,p and w y,p For spatially varying smoothing weights, where w x,p w represents the smoothing weight in the x-direction. y,p The smoothing weights are in the y-direction.
[0223] Specifically, the first item (L) p -L′ p ) 2 The first term forces L to be similar to the initial lighting map L′, and the second term removes redundant texture details in L′ by minimizing the partial derivative. λ is the weight that balances the first and second terms.
[0224] Specifically, the smoothing weight w in the x-direction x,p for:
[0225]
[0226] T x,p Inspired by the relative total variation (RTV), it is defined as:
[0227]
[0228] Among them, Ω p For example, a square window centered at pixel p, which can be 15×15; G σ(p, q) is the Gaussian weight between pixels p and q based on spatial affinity, where σ is the standard deviation and can be 3.
[0229] Specifically, in practical applications, ε is fixed at 0.001.
[0230] In form, G σ (p, q) can be defined as:
[0231]
[0232] Here, the function D(p, q) is the spatial Euclidean distance between pixels p and q.
[0233] To achieve better brightness results in the recovered image, this embodiment of the invention will adjust the estimated illuminance map L using Gamma, that is, let L = L γ And through I′=I×(L γ ) -1 By optimizing the objective function in the equation (Equation (28)), a piecewise smoothed lighting map with little texture detail was obtained, from which the visually pleasing underexposure correction result was recovered.
[0234] For example, γ = 0.6.
[0235] Specifically, in one embodiment, step S606 above fuses the first corrected image and the second corrected image to obtain the final image, and specifically includes the following steps:
[0236] Step S701: Obtain the normally exposed area in the baseline sky segmentation region to obtain the ninth image.
[0237] Step S702: Perform visual quality map calculations on the ninth image, the first corrected image, and the second corrected image respectively to obtain the corresponding first visual quality map, second visual quality map, and third visual quality map.
[0238] Step S703: Perform image fusion on the first visual quality image, the second visual quality image, and the third visual quality image to obtain the final image.
[0239] Specifically, in practical applications, two intermediate exposure correction images can be obtained through dual illuminance estimation, namely, the overexposure correction image I′. r and underexposure correction diagram I′ f That is, the first corrected image and the second corrected image. Considering that there may be normally exposed areas in the input image I, this embodiment of the invention will perform multi-exposure image fusion, thereby combining the image sequence {I′}. f I' rI} is merged into a globally well-exposed image I′.
[0240] The specific process is as follows:
[0241] First, calculate the visual quality map for each image in the sequence:
[0242]
[0243] Where k is the k-th image in the image sequence; C is a quantitative measure of contrast; S is a quantitative measure of saturation; E is a quantitative measure of exposure; β C To control the influence of quantitative measures of contrast, parameter β S To control the influence of quantitative saturation measurement parameters; β E To control the influence of quantitative measures of exposure.
[0244] Specifically, in practical applications, β C β S and β E It can be set to 1 by default.
[0245] Based on this, the three visual quality images are normalized so that their sum at each pixel p is equal to the value at the same pixel in the normalized image.
[0246] Specifically, this embodiment of the invention seamlessly fuses images in a sequence under the guidance of a pre-calculated visual quality map. For example, this embodiment uses the multi-resolution image fusion technique proposed by Burt and Adelson. By fusing the images in the sequence and then modifying the visual quality map by only maintaining the maximum value of each pixel in the image sequence (rather than normalizing the visual quality map), it can be specifically represented as follows:
[0247]
[0248] Where j is the image index in the image sequence.
[0249] The dual illumination estimation method adopted in this embodiment of the invention for the enhanced part of the image is to adjust the exposure of the original image and the reversed image respectively by using dual illumination estimation, and finally perform adaptive exposure fusion with the original image to obtain a clear image with good exposure and normal color.
[0250] Specifically, in practical applications, the aforementioned parameter λ controls the smoothness of the generated illumination. Generally, a larger λ produces smoother illumination, resulting in an exposure-corrected image with stronger local contrast; however, overly smooth illumination reduces brightness and contrast. To achieve better visual effects, this embodiment of the invention sets λ = 0.15 in all experiments, yielding excellent results. However, the actual situation is not limited to this; the value of λ can be changed according to the actual environment and needs. Variations in the value of parameter λ to ensure image correction quality are also within the protection scope of the dark channel-based image dehazing correction method provided in this embodiment of the invention.
[0251] The image dehazing correction method based on the dark channel provided in this invention has been tested on hazy images of factory equipment, and the dehazing and adaptive enhancement effects are good.
[0252] Since images taken in foggy weather may exhibit color cast, this invention first detects and corrects color cast in the foggy image to ensure that color cast does not affect subsequent image processing. The dehazing process overcomes the limitations of traditional dark channel priors by employing a sky detection segmentation-based dehazing algorithm. Furthermore, a dual-illuminance estimation method is used in the exposure enhancement stage. Dual-illuminance estimation is performed on the input image to generate high-quality intermediate underexposed and overexposed corrected images. Finally, the two intermediate exposure corrected images and the locally optimal exposure portion of the input image are integrated into a globally well-exposed image. By efficiently integrating the above processes and adjusting the overall algorithm flow, the process is made reasonable while ensuring the quality of the final output image. The image dehazing correction method based on the dark channel provided by this invention not only performs real-time, large-scale image dehazing enhancement but also has good robustness and accuracy. Through clever design of the adaptive threshold algorithm, redundant and complex operations are significantly reduced, making it easier for users to operate while ensuring image quality.
[0253] By performing the above steps, the image dehazing correction method based on the dark channel provided in this embodiment of the invention corrects the target image by performing color cast correction, thus ensuring the subsequent accurate correction image. A second image is obtained by switching the color system, and morphological skeleton calculation is performed on the second image to determine various sub-points in the region growth process. A fourth image is determined based on these sub-points. On this basis, a dark channel-based artifact removal operation is performed on the baseline sky segmentation region, which greatly reduces the possibility of sky distortion. This not only yields a corrected image containing a clear and accurate sky region but also further improves the image correction quality.
[0254] This invention provides an image dehazing correction device based on the dark channel, such as... Figure 2As shown, the dark channel-based image dehazing correction device includes:
[0255] The acquisition module 101 is used to acquire the target image to be processed. For details, please refer to the relevant description of step S101 in the above method embodiment, which will not be repeated here.
[0256] The first processing module 102 is used to perform color correction based on the color channels of the target image to obtain a color-corrected first image. For details, please refer to the relevant description of step S102 in the above method embodiments, which will not be repeated here.
[0257] The second processing module 103 is used to switch the RGB color system of the first image to the CIE color system to obtain a second image, and to perform sky segmentation based on the dark channel on the second image to obtain a baseline sky segmentation region. For details, please refer to the relevant description of step S103 in the above method embodiment, which will not be repeated here.
[0258] The third processing module 104 is used to perform morphological skeleton calculation on the baseline sky segmentation region to obtain the morphological skeleton result. For details, please refer to the relevant description of step S104 in the above method embodiment, which will not be repeated here.
[0259] The fourth processing module 105 is used to calculate various sub-points in the region growth process based on the skeleton branches and endpoints of the morphological skeleton result. For details, please refer to the relevant description of step S105 in the above method embodiment, which will not be repeated here.
[0260] The fifth processing module 106 is used to perform region growing on each of the seed points in the baseline sky segmentation region to obtain the fourth image. For details, please refer to the relevant description of step S106 in the above method embodiments, which will not be repeated here.
[0261] The sixth processing module 107 is used to determine the artifact regions in the baseline sky segmentation region based on the fourth image, and remove the artifact regions to obtain a corrected image. For details, please refer to the relevant description of step S107 in the above method embodiments, which will not be repeated here.
[0262] For a further description of the above-described image dehazing correction device based on the dark channel, please refer to the relevant description of the above-described embodiment of the image dehazing correction method based on the dark channel, which will not be repeated here.
[0263] Through the synergistic cooperation of the aforementioned components, the image dehazing correction device based on the dark channel provided in this embodiment of the invention performs color cast correction on the target image, thus providing a guarantee for obtaining an accurate corrected image in the future. A second image is obtained by switching the color system, and morphological skeleton calculation is performed on the second image to determine various sub-points in the region growth process. A fourth image is determined based on these sub-points. On this basis, a dark channel-based artifact removal operation is performed on the baseline sky segmentation region, which greatly reduces the possibility of sky region distortion. This not only yields a corrected image containing a clear and accurate sky region but also further improves the image correction quality.
[0264] This invention provides an electronic device, such as... Figure 3 As shown, the electronic device includes a processor 901 and a memory 902, which are communicatively connected to each other. The processor 901 and the memory 902 can be connected via a bus or other means. Figure 3 Taking the example of a connection between China and Israel via a bus.
[0265] Processor 901 can be a Central Processing Unit (CPU). Processor 901 can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above types of chips.
[0266] The memory 902, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of the present invention. The processor 901 executes various functional applications and data processing of the processor 901 by running the non-transitory software programs, instructions, and modules stored in the memory 902, thereby implementing the methods in the above-described method embodiments.
[0267] The memory 902 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor 901, etc. Furthermore, the memory 902 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 902 may optionally include memory remotely located relative to the processor 901, and these remote memories may be connected to the processor 901 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0268] One or more modules are stored in memory 902, and when executed by processor 901, they perform the methods described in the above method embodiments.
[0269] The specific details of the aforementioned electronic device can be understood by referring to the relevant descriptions and effects in the above method embodiments, and will not be repeated here.
[0270] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The implemented program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.
[0271] 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 here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. An image dehazing correction method based on the dark channel, characterized in that, include: Obtain the target image to be processed; Color correction is performed on the color channels of the target image to obtain a color-corrected first image; The RGB color system of the first image is switched to the CIE color system to obtain the second image, and the sky segmentation based on the dark channel is performed on the second image to obtain the baseline sky segmentation region. The morphological skeleton of the baseline sky segmentation region is calculated to obtain the morphological skeleton result. Based on the skeleton branches and endpoints of the morphological skeleton results, various sub-points in the region growth process are calculated. Region growing is performed on each of the seed points in the baseline sky segmentation region to obtain the fourth image; Based on the fourth image, artifact regions in the baseline sky segmentation region are identified and removed to obtain a corrected image. The step of performing dark channel-based sky segmentation on the second image to obtain a baseline sky segmentation region includes: Calculate the gradient magnitude of the second image based on the brightness channel; The local Shannon entropy is calculated based on the gradient magnitude. Logical operations are performed on the local Shannon entropy and dark channel to obtain the baseline sky segmentation region; The method further includes: Exposure correction is performed on the fourth image to obtain the final image; The exposure correction of the fourth image to obtain the final image includes: Based on the fourth image, obtain its inverted image; Forward illumination estimation is performed on the baseline sky segmentation region to obtain the seventh image; The seventh image is subjected to overexposure correction to obtain a first corrected image; The reversed image is subjected to backlight estimation to obtain the eighth image; The eighth image is subjected to underexposure region correction to obtain a second corrected image; The final image is obtained by fusing the first corrected image and the second corrected image. The process of fusing the first corrected image and the second corrected image to obtain the final image includes: The normally exposed area in the baseline sky segmentation region is obtained to produce the ninth image; Visual quality maps are calculated for the ninth image, the first corrected image, and the second corrected image respectively, to obtain the corresponding first visual quality map, second visual quality map, and third visual quality map; The first visual quality image, the second visual quality image, and the third visual quality image are normalized so that the sum at each pixel is equal to the value at the same pixel in the normalized image. Image fusion is then performed on the first visual quality image, the second visual quality image, and the third visual quality image. Finally, the visual quality image is obtained by modifying the visual quality image corresponding to the maximum value of each pixel in the first visual quality image, the second visual quality image, and the third visual quality image.
2. The method according to claim 1, characterized in that, The step of performing color correction based on the color channels of the target image to obtain a color-corrected first image includes: Based on the principle of minimum color loss, a color transfer image is derived from the target image; Based on the maximum attenuation map and the color transfer image, color correction is performed to obtain the first image.
3. The method according to claim 2, characterized in that, Before performing color correction based on the color channels of the target image to obtain a color-corrected first image, the method further includes: Obtain the width and height of the target image; Based on the width and height of the target image, the color cast factor is calculated; Based on the color cast factor results, the target image is subjected to color cast detection and judgment to determine whether the target image has a color cast. When the target image has a color cast, color correction is performed based on the color channels of the target image to obtain a color-corrected first image.
4. An image dehazing correction device based on the dark channel, characterized in that, include: The acquisition module is used to acquire the target image to be processed; The first processing module is used to perform color correction based on the color channels of the target image to obtain a color-corrected first image. The second processing module is used to switch the RGB color system of the first image to the CIE color system to obtain the second image, and to perform sky segmentation based on the dark channel on the second image to obtain the baseline sky segmentation region. The third processing module is used to perform morphological skeleton calculation on the baseline sky segmentation region to obtain the morphological skeleton result. The fourth processing module is used to calculate various sub-points in the region growth process based on the skeleton branches and endpoints of the morphological skeleton result. The fifth processing module is used to perform region growing on each of the seed points in the baseline sky segmentation region to obtain the fourth image; The sixth processing module is used to determine the artifact regions in the baseline sky segmentation region based on the fourth image, and remove the artifact regions to obtain a corrected image; The second processing module is specifically used for: Calculate the gradient magnitude of the second image based on the brightness channel; The local Shannon entropy is calculated based on the gradient magnitude. Logical operations are performed on the local Shannon entropy and dark channel to obtain the baseline sky segmentation region; The device also includes an exposure correction module for: Exposure correction is performed on the fourth image to obtain the final image; The exposure correction of the fourth image to obtain the final image includes: Based on the fourth image, obtain its inverted image; Forward illumination estimation is performed on the baseline sky segmentation region to obtain the seventh image; The seventh image is subjected to overexposure correction to obtain a first corrected image; The reversed image is subjected to backlight estimation to obtain the eighth image; The eighth image is subjected to underexposure region correction to obtain a second corrected image; The final image is obtained by fusing the first corrected image and the second corrected image. The process of fusing the first corrected image and the second corrected image to obtain the final image includes: The normally exposed area in the baseline sky segmentation region is obtained to produce the ninth image; Visual quality maps are calculated for the ninth image, the first corrected image, and the second corrected image respectively, to obtain the corresponding first visual quality map, second visual quality map, and third visual quality map; The first visual quality image, the second visual quality image, and the third visual quality image are normalized so that the sum at each pixel is equal to the value at the same pixel in the normalized image. Image fusion is then performed on the first visual quality image, the second visual quality image, and the third visual quality image. Finally, the visual quality image is obtained by modifying the visual quality image corresponding to the maximum value of each pixel in the first visual quality image, the second visual quality image, and the third visual quality image.
5. An electronic device, characterized in that, include: A memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, the processor executing the computer instructions to perform the method as described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the method as described in any one of claims 1-3.