An improved dark channel based traffic scene image defogging method and system
By using an improved dark channel method, combined with erosion and atmospheric light estimation and guided filtering to process traffic scene images, the real-time performance and color distortion problems of existing dehazing algorithms are solved, achieving clear image restoration and security assurance.
Patent Information
- Application Number
- CN202410693970.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Existing dehazing algorithms rely on image structural features, resulting in poor real-time performance, severe color distortion, and unclear image gradient structure. This leads to blurred details and low contrast in foggy images, affecting the normal operation of traffic monitoring systems.
An improved dark channel method is employed to generate an eroded image through erosion operations. An improved atmospheric light estimation algorithm and dark channel estimation are used to generate a transmission map. Combined with guided filtering and color fidelity processing, a clear dehazed image is restored.
It effectively removes the effects of smog, improves image details and contrast, ensures the normal operation of traffic monitoring systems, reduces safety hazards, and enhances the visual quality and color fidelity of images.
Smart Images

Figure CN118747727B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a traffic scene image defogging method and system based on an improved dark channel. BACKGROUND
[0002] In order to ensure the normal work of the traffic monitoring system, it is of great practical significance to study the defogging work. However, the current defogging methods still have problems such as relying on the structural features of the image, poor real-time performance, poor performance for image algorithms with severe color distortion and non-obvious image gradient structure, etc.
[0003] The defogging algorithm based on the physical model mainly considers the imaging principle of fog and the light attenuation principle of foggy day, considers the scattering and attenuation of light, and then establishes a model. The atmospheric scattering model mainly consists of an incident light attenuation model and an atmospheric light imaging model. By analyzing the captured image light, the process of obtaining the image is modeled according to the scattering effect of light and the atmospheric optical model, so as to decompose the defogging image. However, the defogging effect depends on the structural features of the image, and the subsequent processing does not have a high degree of color restoration.
[0004] The defogging algorithm based on the non-physical model enhances the image details and strengthens the image edges to obtain more detailed information to achieve the defogging effect. Specific algorithms include histogram equalization, color scale enhancement algorithm, Retinex algorithm, wavelet and curvelet transform, etc. The biggest feature of the Retinex defogging algorithm is the constancy of color, that is, it is believed that the color and brightness of the object perceived by the human eye are only related to the interaction of light and the object. The histogram equalization algorithm enhances the visual contrast by homogenizing the image gray scale distribution to achieve the purpose of defogging. The wavelet transform is to decompose the original signal into sub-signals with different frequency characteristics and direction characteristics, and the image is processed locally by local features to enhance the image in multiple scales and then amplify useful information to enhance the image.
[0005] The defogging algorithm based on the non-physical model mainly restores the mathematical features and statistical features of the image itself. Whether it is based on histogram equalization algorithm, Retinex defogging algorithm, or wavelet transform and homomorphic filtering algorithm, the essence is to amplify the detail features of the original image through certain statistics and transformation, which belongs to the image enhancement means.
[0006] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0007] To this end, the technical problem to be solved by the present application is to overcome the fact that the existing algorithms based on histogram equalization, Retinex defogging algorithm, wavelet transform and homomorphic filtering algorithm all essentially amplify the details of the original image through certain statistics and transformation, and all belong to image enhancement means.
[0008] To solve the above technical problems, the first aspect of the present application provides a traffic scene image defogging method based on an improved dark channel, which comprises:
[0009] obtaining a traffic scene image;
[0010] performing an erosion operation on the traffic scene image to generate an erosion image;
[0011] calculating the erosion image according to an improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value;
[0012] calculating the traffic scene image by dark channel estimation to generate a transmission map;
[0013] performing refinement on the transmission map to generate a refined transmission map;
[0014] generating a defogging image according to the traffic scene image, the atmospheric light estimation value and the refined transmission map;
[0015] performing color fidelity processing on the defogging image to obtain a target image.
[0016] In an embodiment of the present application, the step of performing an erosion operation on the traffic scene image to generate an erosion image comprises:
[0017] generating a minimum pixel value according to the traffic scene image;
[0018] calculating the minimum pixel value by a minimum value filter to generate a dark channel value;
[0019] calculating the dark channel value to generate an erosion image.
[0020] In an embodiment of the present application, the step of generating a minimum pixel value according to the traffic scene image comprises:
[0021] converting the traffic scene image into a gray image;
[0022] traversing each pixel of the gray image by a sliding window technique;
[0023] calculating the minimum pixel value in the sliding window.
[0024] In an embodiment of the present application, the step of calculating the dark channel value to generate an erosion image comprises:
[0025] selecting a minimum dark channel value in the dark channel values;
[0026] calculating the minimum dark channel value according to an erode function to obtain an erosion image.
[0027] In an embodiment of the present application, the step of calculating the atmospheric light estimation value according to the improved atmospheric light estimation algorithm comprises:
[0028] acquiring a plurality of pixel points from the erosion image;
[0029] calculating color values of the pixel points;
[0030] averaging a plurality of the color values to obtain an atmospheric light estimation value.
[0031] In an embodiment of the present application, the step of refining the transmission map to generate a refined transmission map comprises:
[0032] refining the transmission map according to a guided filter to generate a refined transmission map.
[0033] In an embodiment of the present application, the step of performing color fidelity processing on the defogged image to obtain a target image comprises:
[0034] adjusting brightness and contrast of the defogged image to generate an initial defogged image;
[0035] judging whether the initial defogged image reaches color balance;
[0036] if yes, generating a target image;
[0037] if no, adjusting brightness and contrast of the defogged image until color balance is reached.
[0038] A second aspect of the present application provides a traffic scene image defogging system based on an improved dark channel, which comprises an erosion module, a calculation module and a data processing module.
[0039] The erosion module is configured to acquire a traffic scene image, and perform an erosion operation on the traffic scene image to generate an erosion image.
[0040] The calculation module is configured to calculate the erosion image according to an improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value, and calculate the traffic scene image through dark channel estimation to generate a transmission map.
[0041] The data processing module is configured to refine the transmission diagram to generate a refined transmission diagram, generate a defogged image according to the traffic scene image, the atmospheric light estimation value and the refined transmission diagram, and perform color fidelity processing on the defogged image to obtain a target image.
[0042] The third aspect of the application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect or any possible implementation of the first aspect.
[0043] The fourth aspect of the application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the method of the first aspect or any possible implementation of the first aspect.
[0044] The above technical solution of the application has the following advantages compared with the prior art.
[0045] The traffic scene image defogging method and system based on the improved dark channel provided by the application solve the problems that the image taken in foggy weather is easily affected by fog or haze, resulting in blurred details, low contrast and even loss of important image information, and the like. In addition, the traffic image information can be effectively processed in combination with a traffic monitoring system, the normal work of the traffic monitoring system is ensured, traffic safety hazards are reduced, and contributions are made to the traffic industry. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to make the content of the application more easily understood, the application will be further described in detail below according to specific embodiments of the application and in combination with the drawings.
[0047] Figure 1 is a flowchart of the traffic scene image defogging method and system based on the improved dark channel provided by the application;
[0048] Figure 2 is a system architecture diagram of the traffic scene image defogging method and system based on the improved dark channel provided by the application. DETAILED DESCRIPTION
[0049] The application will be further described below in combination with the drawings and specific embodiments, so that those skilled in the art can better understand the application and implement it, but the embodiments are not limiting to the application.
[0050] In addition, the described embodiments are only some embodiments of the present application, not all embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0051] Referring to Figure 1 As shown in the drawings, the present application provides a traffic scene image defogging method based on improved dark channel, which comprises the following steps:
[0052] S100, acquiring a traffic scene image;
[0053] In step S100, an input traffic scene image is received, which is RGB image data. In addition, the present application supports various common image formats such as JPEG, PNG, etc.
[0054] S200, performing an erosion operation on the traffic scene image to generate an erosion image;
[0055] In step S200, the erosion operation on the traffic scene image to generate an erosion image comprises: generating a minimum pixel value according to the traffic scene image; calculating the minimum pixel value by a minimum value filter to generate a dark channel value; calculating the dark channel value to generate an erosion image. The step of generating a minimum pixel value according to the traffic scene image comprises: converting the traffic scene image into a grayscale image; traversing each pixel of the grayscale image by a sliding window technique; calculating the minimum pixel value in the sliding window. The step of calculating the dark channel value to generate an erosion image comprises: selecting the minimum dark channel value in the dark channel value; calculating the minimum dark channel value according to an erode function to obtain an erosion image.
[0056] In practical application scenarios, the input RGB image is converted to a grayscale image. A sliding window technique is used to iterate through each pixel of the grayscale image, calculating the minimum value within the sliding window. For each pixel in the sliding window, a dark channel is calculated using a minimum filter. Since the original image data is typically represented as a multi-dimensional array in computer vision and image processing, operations can be performed directly on the multi-dimensional array. The minimum value of the RGB three-channel values is selected, and an erosion operation is used to extract the minimum value. Then, the minimum of these minimum values is selected as the dark channel value for that pixel. An erode function is used to perform an erosion operation on the calculated minimum dark channel value to reduce the range of higher brightness areas. The core function of the erosion operation is to reduce the range of higher brightness areas to more accurately simulate the areas with the least light. This step helps to more accurately estimate the thickness of the propagation medium in the defogging algorithm. The shape and size of the structural element in the erosion operation are adjusted according to the specific application to achieve the best performance. The optimized method reduces the calculation time by reducing array operations and utilizing built-in functions. The optimized method reduces the storage requirements for temporary data, as separate color channels do not need to be stored.
[0057] S300, according to the improved atmospheric light estimation algorithm, the erosion image is calculated to obtain an atmospheric light estimation value;
[0058] In step S300, the step of calculating the erosion image according to the improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value includes: obtaining a plurality of pixel points from the erosion image; calculating the color value of the pixel points; averaging a plurality of color values to obtain an atmospheric light estimation value.
[0059] In practical application scenarios, the current atmospheric light estimation method uses the brightest pixels in the image. This method can be affected by abnormal bright spots in the image. We introduce a more robust statistical method based on the average value mode estimation, which helps to reduce the influence of outliers. The estimation of atmospheric light is a key step, and the present application aims to improve the naturalness and accuracy of the overall defogging effect through an improved atmospheric light estimation method. The core of this method is to select the pixel points with the highest dark channel values in the image, which are considered to be the areas most affected by atmospheric light, and then calculate the average color value of these areas as the estimation value of atmospheric light. The specific method is:
[0060] The most bright pixels from the haze image are obtained by first calculating the number of pixels to consider, which is based on the dark channel of the image and a user-defined percentage. This percentage determines how many of the brightest pixels from all pixels are selected to estimate the atmospheric light. The pixel values of the dark channel are sorted, and the indices of the brightest few pixels are obtained. Then the corresponding color values are extracted from the original image using these indices. The color values of the selected brightest pixels are averaged, and the result is taken as the estimate of the atmospheric light. This average is calculated independently for each color channel over all selected pixels. Outliers, such as color points that deviate too much from the average, are excluded to prevent extreme values from affecting the final result. The function finally returns the color value of the calculated atmospheric light, which is used in subsequent steps.
[0061] S400, calculating the traffic scene image by dark channel estimation to generate a transmission map;
[0062] In step S400, the traffic scene image is calculated by dark channel estimation to generate a transmission map, which describes the degree of light absorption by scene depth.
[0063] S500, refining the transmission map to generate a refined transmission map;
[0064] In step S500, the transmission map is refined to generate a refined transmission map, which includes refining the transmission map according to guided filtering to generate a refined transmission map.
[0065] In actual application scenarios, refining the transmission map is crucial for restoring image details and colors. Using guided filtering to refine the transmission map is an effective method because guided filtering can remove image noise and over-smoothed areas while preserving edges. We define a function that uses the cv2.ximgproc.guidedFilter method of OpenCV to implement guided filtering. This function requires four parameters: the guide image I (the original image), the input image p (the image to be filtered, such as the rough transmission map), the radius r (which defines the size of the local area of the filter), and the regularization parameter eps (which controls the degree of smoothing).
[0066] After calculating the preliminary transmission map et (such as the transmission map obtained by dark channel prior), we use guided filtering to refine this transmission map to obtain a refined transmission map. In this process, the original image I is used as the guide image, and the preliminary transmission map et is used as the image to be filtered. By using guided filtering to refine the transmission map, the quality of image dehazing can be significantly improved, and the visual effect of the real scene can be better restored.
[0067] S600, generating a defogged image according to the traffic scene image, the atmospheric light estimation value and the refined transmission map;
[0068] In step S600, the defogged image is recovered by the traffic scene image, the atmospheric light estimation value and the refined transmission map.
[0069] S700, performing color fidelity processing on the defogged image to obtain a target image.
[0070] In step S700, the step of performing color fidelity processing on the defogged image to obtain a target image includes: adjusting the brightness and contrast of the defogged image to generate an initial defogged image; judging whether the initial defogged image reaches color balance; if yes, generating a target image; if no, adjusting the brightness and contrast of the defogged image until color balance is reached.
[0071] In actual application scenarios, in order to improve the color fidelity of the defogged image, adding color balance processing is an important step. It can help adjust the color distribution of the image to make it more balanced and natural. By adjusting the brightness and contrast of the defogged image to reach color balance, the visual effect of the image is improved. If the defogged image does not reach color balance, the brightness and contrast of the defogged image need to be adjusted again until color balance is reached.
[0072] Color balance improves color distribution by adjusting the brightness boundary of the image. The specific steps include calculating the lower and upper bounds of brightness, then limiting the color values in the image between these two limits and remapping to the entire color space.
[0073] In the final stage of the defogging algorithm, the defogged image is adjusted for color balance. This step is performed after the image is restored, and the purpose is to improve the visual quality of the image.
[0074] Referring to Figure 2 The second aspect of the present application provides a traffic scene image defogging system based on an improved dark channel, which comprises an erosion module 100, a calculation module 200 and a data processing module 300.
[0075] The erosion module 100 is configured to: obtain a traffic scene image; perform an erosion operation on the traffic scene image to generate an erosion image;
[0076] The calculation module 200 is configured to: calculate the erosion image according to an improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value; calculate the traffic scene image by dark channel estimation to generate a transmission map;
[0077] The data processing module 300 is configured to refine the transmission diagram to generate a refined transmission diagram, generate a defogged image according to the traffic scene image, the atmospheric light estimation value and the refined transmission diagram, and perform color fidelity processing on the defogged image to obtain a target image.
[0078] The effects of the system in the application of the foregoing method can refer to the descriptions in the foregoing method embodiments, which will not be repeated here.
[0079] The third aspect of the application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the program to realize the method described in the first aspect or any possible implementation manner of the first aspect.
[0080] The fourth aspect of the application provides a non-transitory computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the method described in the first aspect or any possible implementation manner of the first aspect.
[0081] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0082] The present application is described with reference to flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks.
[0083] These computer program instructions can also be stored in a computer-readable storage medium that can guide the computer or other programmable data processing devices to work in a specific manner, so that the instructions stored in the computer-readable storage medium produce a manufactured product including instruction devices that implement the functions specified in the flowcharts and / or block diagrams. Figure 1one or more processes and / or blocks Figure 1 the function specified in the one or more blocks.
[0084] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, so that the instructions executed on the computer or other programmable data processing devices provide processes for implementing the flow Figure 1 one or more processes and / or blocks Figure 1 the function specified in the one or more blocks.
[0085] Obviously, the above embodiments are only examples for clearly illustrating the present application, and are not intended to limit the embodiments. Based on the above description, other different forms of changes or variations can be made by those skilled in the art. Here, all the embodiments are not required to be exhausted, and the obvious changes or variations derived therefrom are still within the protection scope of the present application.
Claims
1. An improved dark channel based traffic scene image defogging method, characterized in that, The method comprises: acquiring a traffic scene image; performing an erosion operation on the traffic scene image to generate an erosion image; calculating the erosion image according to an improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value; the steps of the improved atmospheric light estimation algorithm comprise: acquiring a plurality of pixel points based on a dark channel of the erosion image and a user-defined percentage; sorting all pixel values of the dark channel and acquiring indexes of several brightest pixel points, and calculating color values of the plurality of pixel points by using the indexes; averaging the plurality of color values to obtain the atmospheric light estimation value; calculating the traffic scene image by dark channel estimation to generate a transmission map; performing refinement on the transmission map to generate a refined transmission map; wherein the steps of generating the refined transmission map comprise: performing refinement on the transmission map according to a guided filter to generate a refined transmission map; generating a defogged image according to the traffic scene image, the atmospheric light estimation value and the refined transmission map; performing color fidelity processing on the defogged image to obtain a target image; wherein the steps of obtaining the target image comprise: adjusting the brightness and contrast of the defogged image to generate an initial defogged image; judging whether the initial defogged image reaches color balance; if yes, generating a target image; if no, adjusting the brightness and contrast of the defogged image until color balance is reached; wherein the steps of adjusting color balance comprise: calculating lower and upper bounds of brightness, then limiting color values in the image between the two bounds and remapping to the entire color space.
2. The improved dark channel based traffic scene image defogging method according to claim 1, characterized in that, The steps of performing an erosion operation on the traffic scene image to generate an erosion image comprise: generating a minimum pixel value according to the traffic scene image; calculating the minimum pixel value by a minimum value filter to generate a dark channel value; calculating the dark channel value to generate an erosion image.
3. The improved dark channel based traffic scene image defogging method according to claim 2, characterized in that, The steps of generating a minimum pixel value according to the traffic scene image comprise: converting the traffic scene image into a grayscale image; traversing each pixel of the grayscale image by a sliding window technique; calculating a minimum pixel value in the sliding window.
4. The improved dark channel based traffic scene image defogging method according to claim 2, characterized in that, The steps of calculating the dark channel value to generate an erosion image comprise: selecting a minimum dark channel value in the dark channel value; calculating the minimum dark channel value according to an erode function to obtain an erosion image.
5. An improved dark channel based traffic scene image defogging system for implementing the improved dark channel based traffic scene image defogging method of any one of claims 1 to 4, characterized in that, The system comprises an erosion module, a calculation module and a data processing module; the erosion module is configured to acquire a traffic scene image and perform an erosion operation on the traffic scene image to generate an erosion image; the calculation module is configured to calculate the erosion image according to an improved atmospheric light estimation algorithm to obtain an atmospheric light estimation value and calculate the traffic scene image by dark channel estimation to generate a transmission map; the steps of the improved atmospheric light estimation algorithm comprise: acquiring a plurality of pixel points based on a dark channel of the erosion image and a user-defined percentage; sorting all pixel values of the dark channel and acquiring indexes of several brightest pixel points, and calculating color values of the plurality of pixel points by using the indexes; averaging the color values to obtain an estimate of the atmospheric light; The data processing module is configured to: refine the transmission map to generate a refined transmission map; generate a defogged image according to the traffic scene image, the estimate of the atmospheric light, and the refined transmission map; and perform color fidelity processing on the defogged image to obtain a target image.
6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the improved dark channel based traffic scene image defogging method of any one of claims 1 to 4 when executing the program.
7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the improved dark channel based traffic scene image defogging method of any one of claims 1 to 4.
Citation Information
Patent Citations
Remote sensing image de-fogging method based on dark channel prior model
CN106530257A
Dark channel and image segmentation-based traffic image defogging method and system
CN107301623A
Dark primary color prior image defogging method through image guided filter
CN107798670A
Image defogging improvement method based on dark channel prior
CN110148093A
Image defogging algorithm based on dark channel prior improvement
CN116012236A