A method for defogging images from tugboat perspective by enhancing local contrast
Through the combination of atmospheric optical model and CLAHE algorithm, the problem of defog removal on sea images is solved, and the accuracy and real-time defog removal of the tug viewing image is improved, providing more natural and clear visual support, ensuring that the tug in bad weather Safe navigation.
Patent Information
- Application Number
- CN202410673208.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-05-28
AI Technical Summary
The existing defog removal technology is difficult to accurately process images of large-area sky areas in marine environments, resulting in unsatisfactory defog removal and insufficient real-time and accuracy in bad weather conditions, affecting the safe navigation of the tugboat.
The mathematical relationship between color and atmospheric light value and transmittance is established by using atmospheric optical model, and the atmospheric light value is estimated through quad-tree iteration and statistical analysis, and the optimal transmittance is selected. The rapid guide filtering and CLAHE algorithm are combined to enhance local contrast and optimize images. Defog removal effect.
It significantly improves the naturalness and color saturation of the image, reduces artifacts, improves the real-time and applicability of the fog removal algorithm, ensures clear visual support under harsh navigation conditions, and reduces the risk of tugboat collisions.
Smart Images

Figure CN118505565B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of tugboat intelligent perception, and in particular relates to a tugboat perspective image defogging method for enhancing local contrast. Background Art
[0002] With the rapid development of tugboats, navigation, communications, and computer vision, human activities in water ports have become increasingly frequent. As an important means of maritime transportation, tugboats assist large ships in entering and leaving ports, which is crucial to improving the efficiency of maritime logistics. In navigation activities, the tugboat's visual image plays an indispensable role in the driver's navigation and operation. However, in severe weather conditions, especially dense fog, the field of vision is often severely affected, posing a challenge to the safe navigation of the tugboat.
[0003] Defogging technology, as a core technology to improve the safety of tugboat operations, aims to quickly and effectively process images affected by fog and restore the clarity of vision to support tugboat drivers in making accurate decisions. Although there are many image defogging technologies, most methods are mainly designed and optimized for images in land environments. The particularity of tugboat perspectives, such as the monotony of sea colors, most of the sky area, and the real-time requirements of sea navigation, make these traditional defogging methods have poor defogging performance when used at sea.
[0004] For example, some dehazing techniques are mainly applicable to land images. When processing marine images, it is often difficult to accurately estimate the atmospheric light value and transmittance, resulting in unsatisfactory dehazing effects. Similarly, although other technologies have proposed brightness contrast enhancement and derivative image fusion strategies, they are still limited in real-time and specific requirements of marine images. In addition, although some researchers meet the real-time requirements, their processing steps may have artifact problems from the perspective of a fast-moving tugboat.
[0005] Therefore, the existing defogging technology fails to fully solve the defogging problem of tugboat perspective images under adverse weather conditions, especially for image processing of large sky areas. The purpose of the present invention is to improve the accuracy and real-time performance of defogging images from the tugboat perspective, especially for marine images with large sky areas, to provide a feasible defogging method, and to provide real-time and effective visual support for tugboats sailing in dense fog. Summary of the invention
[0006] The purpose of the present invention is to provide a tugboat perspective image defogging method with enhanced local contrast to address the defects of the prior art, so as to solve the problems raised by the above-mentioned background technology.
[0007] The present invention proposes a method for defogging a tugboat perspective image by enhancing local contrast, and the method comprises the following steps:
[0008] S1: Establishment of atmospheric optical model: Input foggy images from the perspective of the tugboat, use the atmospheric optical model to explain the color changes in the image, and establish the mathematical relationship between color and atmospheric light value and transmittance;
[0009] S2: Atmospheric light value estimation: Estimate the atmospheric light value in the foggy image through quadtree iteration and statistical analysis method to ensure the accuracy of the estimation;
[0010] S3: Optimal transmittance estimation: By calculating the contrast under different transmittances, the transmittance that makes the dehazed block have the maximum contrast is selected;
[0011] S4: Fast guided filtering: Apply fast guided filtering technology to optimize the transmission image, improve the image detail performance and defogging effect;
[0012] S5: CLAHE local contrast enhancement: Use the CLAHE algorithm to perform local contrast enhancement on the processed image, especially in large single-color areas such as the sky, to improve the overall clarity and details of the image;
[0013] S6: Outputting the defogging tugboat image: showing the final defogging effect and providing a clearer visual image for use.
[0014] As a preferred technical solution of the present invention, the establishment of the atmospheric optical model described in step S1 specifically includes the following steps:
[0015] S1-1: input foggy image from the perspective of the tugboat;
[0016] S1-2: Apply an atmospheric optical model to analyze and explain the color changes observed in foggy images. The atmospheric optical model calculation formula is:
[0017] I(p)=t(p)J(p)+(1-t(p))A (1)
[0018] Where J(p)=(J r (p),J g (p),J b (p)) T and I(p)=(I r (p),I g (p),I b (p)) T Respectively represent the original color at pixel point p and the color observed at the corresponding position p; A=(A r ,A g ,A b ) TIt represents the global atmospheric light value, that is, the atmospheric ambient light; t(p) represents the transmittance of the reflected light, and its value range is between 0 and 1. When the transmittance is 0, it means that the light is completely absorbed or reflected by the medium without penetrating; and when the transmittance is 1, it means that the light is completely transmitted through the medium without being absorbed or reflected;
[0019] S1-3: According to the scattering and attenuation of light under atmospheric conditions, the transmittance t(p) is calculated. The transmittance t(p) is used to indicate the attenuation degree of light during propagation. The transmittance t(p) is affected by the distance between the scene point and the camera. The calculation formula of t(p) is:
[0020] t(p)=e -ρd(p) (2)
[0021] Among them, d(p) represents the depth from the camera to the scene at pixel position p, ρ is the attenuation coefficient determined by weather conditions, and ρ is specifically set to 1.
[0022] As a preferred technical solution of the present invention, the atmospheric light value estimation described in step S2 has the following characteristics: the atmospheric light A is estimated to be the brightest color in the image; in foggy areas, the variance of pixel values is low, the color and brightness are relatively uniform, the brightness changes of other objects are relatively small, and the atmospheric light is one of the brightest parts.
[0023] As a preferred technical solution of the present invention, the atmospheric light value estimation described in step S2 specifically adopts a hierarchical search method based on quadtree iteration, and the method specifically comprises the following steps:
[0024] S2-1: The input foggy image is initially divided into four rectangular regions. The quadtree is a recursive data structure that first decomposes the image into four sub-blocks of equal size, and then repeats the search process for each sub-block until the termination condition is met;
[0025] S2-2: Then define the score of each region as the average pixel value minus the standard deviation of the pixel values in the region, and calculate the score for each region;
[0026] S2-3: Select the region with the highest score and further subdivide it into four smaller rectangular regions;
[0027] S2-4: repeating steps S2-2 and S2-3 until the size of the selected area is smaller than a preset threshold;
[0028] S2-5: In the finally selected small area, a color vector with the smallest distance from a pure white vector is selected as the atmospheric light value, wherein the pure white vector is specifically (255, 255, 255).
[0029] As a preferred technical solution of the present invention, the optimal transmittance estimation described in step S3 specifically includes the following steps:
[0030] S3-1: Correlate the observed image with the real scene radiation and atmospheric conditions through each block with a fixed transmission value t, as calculated by:
[0031]
[0032] Where J(p) represents the recovered scene radiance. After estimating the atmospheric light A, J(p) depends on the choice of transmittance t. A foggy block will have a lower contrast, while the contrast of the restored block will increase as the estimated transmittance t becomes smaller.
[0033] S3-2: Define the mean square error contrast of a color channel as the variance of the pixel value, estimate the optimal t, and the specific calculation formula of the mean square error is:
[0034]
[0035] Among them, c represents the index of the color channel, It's J c The average value of (p), N is the number of pixels in a block, where the index of the color channel specifically includes red, green and blue;
[0036] The calculation formula of the mean square error contrast of the restored block is:
[0037]
[0038] in, It is the input block I c The average value of (p), the mean square error contrast is a decreasing function of the transmittance t;
[0039] S3-3: Estimate the optimal transmittance t for each block by minimizing the overall cost function, which takes into account the contrast cost and information loss cost. The contrast cost is defined by the negative sum of the mean square error contrast of the three color channels of the block, and the information loss cost is represented by the sum of the squares of the truncated values. The contrast cost E contrast It is obtained by the negative sum of the mean square error contrast of the three color channels of each block B. The specific calculation formula is:
[0040]
[0041] in, and They are J in block B c (p) and I c The average value of (p), N Bis the number of pixels in block B, by minimizing the contrast cost E contrast Maximize the mean squared error contrast, the information loss cost E of block B loss The formula for calculating the sum of squares of the truncated values is:
[0042]
[0043]
[0044] Among them, h c (i) is the histogram of input pixel value i in color channel c, α c and β c They represent the intercept where truncation occurs, min{0,J c (p)} and max{0,J c (p)-255} represent the truncated values due to underflow and overflow, respectively. For block B, the optimal transmittance t is found by minimizing the overall cost function * , and its calculation formula is as follows:
[0045] E=E contrast +λ L E loss (9)
[0046] Among them, λ L is a weight parameter used to control the relative relationship between contrast cost and information loss cost, where a larger λ L The value will reduce information loss. L = 1, the optimal transmittance value should not cause any information loss, and its calculation formula is:
[0047] min c∈{r,g,b} min p∈B J c (p)0 (10)
[0048] max c∈{r,g,b} max p∈B J c (p)255 (11)
[0049] Among them, the transmittance t is characterized by the existence of two constraints, and the calculation formula of the constraints is:
[0050]
[0051]
[0052] Among them, E contrast is an increasing function of t, the optimal transmission t *It is determined to be the minimum value that satisfies the constraint mixing condition (14), and the minimum value calculation formula (15) is:
[0053]
[0054]
[0055] Among them, adjusting λ L The parameters are used to strike a balance between contrast enhancement and information loss.
[0056] As a preferred technical solution of the present invention, the fast guided filtering described in step S4 has the following characteristics: the transmittance image is processed using guided filtering technology; the brightness, contrast or gradient of the original image is selected as the guide image; the guided image is combined with the transmittance image to be filtered for guided filtering processing, and the structural characteristics of the guide image are adjusted through the filtering process.
[0057] As a preferred technical solution of the present invention, the CLAHE local contrast enhancement described in step S5 has the following characteristics:
[0058] S5-1: When processing foggy images, especially in high fog areas such as the sky, apply the CLAHE algorithm to improve the contrast and detail clarity of these areas;
[0059] S5-2: The CLAHE algorithm dynamically adjusts the contrast of each image region according to the illumination and contrast differences in each image region by locally adaptively adjusting the histogram equalization process, thereby effectively restoring the details of the sky;
[0060] S5-3: The CLAHE algorithm pays special attention to retaining more detail information while enhancing the image contrast, preventing the common detail smoothing or loss problems in the dehazing process, making the restored image more visually realistic and natural;
[0061] S5-4: In the dehazing process, the CLAHE algorithm is specially designed to meet the processing requirements of large homogeneous color areas such as the sky, ensuring that these areas do not visually lose their natural colors and layering due to the processing process.
[0062] Compared with the related prior art, the present invention has the following main technical advantages and the beneficial effects of the present invention are:
[0063] Significantly improve the naturalness and color saturation of images: Traditional dehazing algorithms often ignore the unique environmental characteristics of the sea, resulting in unnatural colors and insufficient detail recovery of dehazed images. The present invention uses a local contrast enhancement algorithm to specially optimize large areas of homogeneous color such as the sky, effectively avoiding the generation of artifacts, making the image more natural and the colors more saturated.
[0064] Reduce preprocessing and dependence: The algorithm of the present invention does not require a specific data set for training, nor does it rely on convolutional neural networks to perform complex preprocessing of data images. This feature greatly simplifies the implementation process of the defogging system, reduces processing time, and increases the applicability and flexibility of the algorithm.
[0065] Optimizing computational complexity and ensuring real-time performance: The defogging algorithm of the present invention has low time complexity, simple algorithm structure, and high execution efficiency, which ensures its application in real-time navigation operations, especially in adverse navigation conditions such as low visibility or foggy days, and can quickly provide clear images and reduce the risk of tugboat collision.
[0066] Improving the environmental adaptability of tugboats: Through effective defogging, the present invention enables tugboats to better adapt to different navigation environments and application scenarios, which is of great practical value for ensuring the navigation safety of tugboats, especially in complex marine environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 is a flow chart of a method for defogging a tugboat perspective image with enhanced local contrast according to the present invention;
[0068] Figure 2 The quadtree iteration method of embodiment 1 provided by the present invention is used to find the atmospheric light value area map;
[0069] Figure 3 is a subjective evaluation diagram under different defogging methods provided in Example 2 of the present invention;
[0070] Among them: (a) the original input fog image, (b) the defogging result of the dark channel prior algorithm, (c) the defogging result of the contrast enhancement algorithm, (d) the defogging result of the local contrast enhancement algorithm;
[0071] Figure 4 is a subjective evaluation diagram of different defogging methods provided in Example 3 of the present invention;
[0072] Among them: (a) the original input fog image, (b) the defogging result of the dark channel prior algorithm, (c) the defogging result of the contrast enhancement algorithm, and (d) the defogging result of the local contrast enhancement algorithm.
[0073] Figure 5 is a subjective evaluation diagram of different defogging methods provided in Example 4 of the present invention;
[0074] Among them: (a) the original input fog image, (b) the defogging result of the dark channel prior algorithm, (c) the defogging result of the contrast enhancement algorithm, and (d) the defogging result of the local contrast enhancement algorithm. DETAILED DESCRIPTION
[0075] The present invention is further described below in conjunction with the accompanying drawings and examples. However, the present invention can be implemented in many different ways and should not be construed as being limited to the embodiments shown; on the contrary, these embodiments provide those skilled in the art with implementation methods that meet applicable legal requirements.
[0076] Example 1: According to Figure 1 As shown, this embodiment describes in detail a method for defogging a tugboat perspective image with enhanced local contrast to solve the problems existing in the prior art. The present invention provides a method for defogging a tugboat perspective image with enhanced local contrast, and the steps of the method are as follows:
[0077] Step S1: Establishment of atmospheric optical model: Input the foggy image from the perspective of the tugboat. Based on the atmospheric optical model, the color of the input image can be explained by the model. Under atmospheric conditions such as haze, the propagation of light will be affected, causing the color of the object to change when it is displayed in the image. Therefore, the atmospheric optical model is used to understand the reasons and laws of this color change:
[0078] I(p)=t(p)J(p)+(1-t(p))A (1)
[0079] Where J(p) = (J r (p),J g (p),J b (p)) T and I(p)=(I r (p),I g (p),I b (p)) T A=(A r ,A g ,A b ) T Represents the global atmospheric light value, that is, the atmospheric ambient light. t(p) represents the transmittance of the reflected light, and its value range is between 0 and 1. Because the transmittance represents the relative attenuation of light when it passes through a medium (such as the atmosphere). When the transmittance is 0, it means that the light is completely absorbed or reflected by the medium and does not penetrate. When the transmittance is 1, it means that the light completely passes through the medium without being absorbed or reflected. That is, the transmittance t(p) ranges from 0 to 1, which is used to represent the attenuation of light during propagation. It is affected by the distance between the scene point and the camera. Since light is affected by scattering and attenuation during propagation, the transmittance t(p) is inversely proportional to the scene depth. As shown in formula (2):
[0080] t(p)=e -ρd(p) (2)
[0081] Where d(p) represents the depth from the camera to the scene at pixel position p, and ρ is the attenuation coefficient determined by weather conditions, which is usually assumed to be 1 under typical haze conditions. From the above formula, it can be seen that the original color J(p) at pixel point p will be attenuated by the transmittance t(p). On the other hand, the atmospheric light A is affected by the weight (1-t(p)), which plays a more important role if the scene point is farther away from the camera. Because the transmittance t(p) usually becomes smaller when the scene point is farther away from the camera, because the light needs to pass through more atmosphere. In this case, the weight (1-t(p)) of the atmospheric light A will increase because the light is more likely to be absorbed or scattered after a longer path. Therefore, at scene points far away from the camera, the contribution of atmospheric light will be more significant because it can compensate for the light attenuation caused by the decrease in transmittance t(p).
[0082] Step S2: Estimation of atmospheric light value: Usually, atmospheric light A is estimated as the brightest color in the image, because a lot of haze will cause bright colors. However, if there are objects in the image that are brighter than the atmospheric light, it may cause problems in the selection of atmospheric light. So in order to estimate the atmospheric light more reliably, this method takes advantage of the fact that the variance of pixel values is usually low in foggy areas (such as the sky). Because haze causes the color and brightness in the image to become more uniform, reducing the difference between pixel values. Therefore, in these areas, the variance of pixel values will be relatively small, which means that the color and brightness in the area are relatively uniform, the brightness changes of other objects are relatively small, and the atmospheric light is usually one of the brightest parts. The atmospheric light is more prominent relative to other objects, so the atmospheric light can be more easily identified in foggy areas.
[0083] In addition, this method proposes a search method based on quadtree iteration. Figure 2 The image is a foggy image from the perspective of a tugboat at the Lianyungang Port. First, the input image is divided into four rectangular regions, and the score of each region is defined as the average pixel value minus the standard deviation of the pixel values in the region. Then, the region with the highest score is selected and further subdivided into four smaller regions. The present invention repeats this process until the size of the selected region is less than a pre-specified threshold. For example, in Figure 2In the example, the blue square is finally selected. Within the selected area, the present invention selects a color vector that minimizes the distance to the pure white vector (255, 255, 255), so that the present invention attempts to select atmospheric light that is as bright as possible. Within a small area (in this case, a block of 32×32 pixels), the depth or distance of objects in the scene is assumed to be similar. Because in actual scenes, the depth of objects usually does not change very drastically in relatively small areas. Especially when the distance from the camera is close, such as in a picture, objects in an area of 32×32 pixels usually do not have much depth change. This assumption makes it more reasonable to estimate the transmittance in local areas, because the depth changes of objects in these areas are relatively small, so it can be assumed that the influence of the atmosphere is also relatively uniform, thereby simplifying the processing of the defogging algorithm. This assumption is common in various defogging algorithms. A single transmittance value is found for each 32×32 block. In defogging, estimating the transmittance helps to restore the true scene color and details.
[0084] Step S3: Optimal transmittance estimation: Equation (1) generally relates the observed image to the real scene radiation and atmospheric conditions. With each block having a fixed transmittance value t, Equation (1) can be written as follows:
[0085]
[0086] After estimating the atmospheric light A, the restored scene radiance J(p) depends on the choice of transmittance t. In general, a foggy block will have a lower contrast, and the contrast of the restored block will increase as the estimated transmittance t becomes smaller. The present invention attempts to estimate the optimal t so that the defogged block has the maximum contrast. For simplicity, the present invention defines the contrast of a color channel. The present invention uses mean square error contrast because it is a common indicator for measuring image quality. Mean square error contrast can help the present invention evaluate the clarity and detail of the image, so as to better understand the quality of the image. Mean square error contrast represents the variance of pixel values, which is defined as:
[0087]
[0088] Here, c represents the index of the color channel (e.g. red, green, blue), It's J c (p), N is the number of pixels in a block. From equation (3), the mean square error contrast of the restored block can be rewritten as:
[0089]
[0090] Here, It is the input block Ic According to equation (5), the mean square error contrast is a decreasing function of the transmittance t.
[0091] Since the contrast measurement is inversely proportional to the transmittance t, the present invention can select a smaller t value to increase the contrast of the restored block. In formula (3), the function converts the input pixel value I c (p) is mapped to the output value J c (p). The input values are mapped to the full dynamic range of the output values [0, 255] in the interval [a, b], where the transmittance t determines the effective input range of [a, b]. When most of the input values belong to [a, b], the present invention can obtain an output block with higher contrast. However, when many input values are outside [a, b], the converted output values do not belong to the valid output range [0, 255]. In this case, some pixel values will be under- or overflowed and truncated to 0 or 255. This means that information is lost in the restored area, reducing the quality of the restored block.
[0092] Therefore, information loss can usually be reduced by choosing a larger t value. However, when a block contains dense haze, it has a relatively narrow input value range. Therefore, even given a small t value, most pixel values still belong to the interval [a, b] and are not truncated. In contrast, a block without haze exhibits a wider input value range and should be assigned a larger t value to reduce information loss due to truncation. As t decreases, more and more pixel values are truncated in the restored image.
[0093] Therefore, the present invention should not only enhance contrast but also reduce information loss. To this end, the present invention designs contrast cost and information loss cost, and then minimizes these two cost functions simultaneously. First, the present invention defines the contrast cost E by taking the negative sum of the mean square error contrast of the three color channels of each block B. contrast .
[0094]
[0095] in, and They are J in block B c (p) and I c The average value of (p), N B is the number of pixels in block B. Note that by minimizing the contrast cost E contrast , the present invention can maximize the mean square error contrast. Secondly, the present invention defines the information loss cost E of block B loss is the sum of squares of the truncated values:
[0096]
[0097]
[0098] Among them, h c (i) is the histogram of input pixel value i in color channel c, α c and β c They represent the intercepts where truncation occurs. In formula (7), the term min{0,J c (p)} and max{0,J c (p)-255} represent the truncated values due to underflow and overflow, respectively. The present invention uses a histogram to express the sum of the squares of the truncated values as equation (8). Finally, for block B, the present invention finds the optimal transmittance t by minimizing the overall cost function * .
[0099] E=E contrast +λ L E loss (9)
[0100] Among them, λ L is a weight parameter that controls the relative relationship between contrast cost and information loss cost.
[0101] In formula (9), the larger λ L The value will reduce the information loss. L = 1, the optimal transmittance value should not cause any information loss, that is:
[0102] min c∈{r,g,b} min p∈B J c (p)0 (10)
[0103] max c∈{r,g,b} max p∈B J c (p)255 (11)
[0104] These inequalities, together with the relationship in equation (3), give two constraints on the transmittance t, namely:
[0105]
[0106]
[0107] Combines two constraints into a single constraint.
[0108]
[0109] Note that E contrast is an increasing function of t. Therefore, the optimal transmission t* is determined as the minimum value that satisfies constraint (14).
[0110]
[0111] The first constraint in (12) is the same as the constraint used as the dark channel prior in the algorithm of He et al. This constraint requires that the object is brighter than the atmospheric light. When some objects are brighter than the atmospheric light, the transmission rate cannot be estimated correctly. In contrast, the proposed algorithm uses the additional constraint in (13) to prevent the overflow of the restored pixel values. Therefore, the proposed algorithm can estimate the transmission rate more reliably. In addition, by controlling λ in (9), L ,The algorithm of the present invention can strike a balance between contrast enhancement and information loss.
[0112] Step S4: Fast guided filtering: Fast guided filtering is a technique for image processing, which is usually used to remove noise and enhance details in images. In the defogging algorithm, fast guided filtering can be used to assist in estimating the transmittance (transmission) image. The defogging algorithm usually uses the local contrast information in the image to estimate the transmittance, because the transmittance is related to the depth information in the scene and the degree of atmospheric scattering. By guiding the filter, the transmittance image can be smoothed while retaining the image details, so as to more accurately restore the scene under the influence of haze. In fast guided filtering, the guide image is usually some variant of the original image, such as the brightness, contrast or gradient of the original image. By combining the guide image with the target image to be filtered, the guide filter can adjust the filtering process according to the structure of the guide image, so as to achieve a more accurate filtering effect.
[0113] The present invention uses a guided filter to better restore the tugboat's visual angle image, so that the present invention can retain the details and contrast of the defogging image more quickly and accurately in real time.
[0114] Step S5: CLAHE local contrast enhancement: In foggy images with most of the sky area, the sky usually presents lower contrast and lower detail clarity due to the presence of haze. Using the CLAHE (Contrast Limited Adaptive Histogram Equalization) algorithm to defog the tugboat view image can obtain a clear and natural restored image. First, the CLAHE algorithm can enhance the contrast of the image, making the details of the sky area clearer. This is especially important for the sky in foggy images, because haze can reduce the contrast of the sky area, making the sky appear monotonous and blurred. Secondly, the CLAHE algorithm is a local adaptive histogram equalization method that can be adjusted according to the contrast of different areas in the image. In foggy images, there may be obvious differences in the illumination and contrast between the sky area and the ground area. CLAHE can perform different degrees of contrast enhancement according to the characteristics of these areas, so as to better restore the details of the sky. Finally, the CLAHE algorithm can retain more detail information while enhancing the contrast. This is very important for the sky in foggy images, because the problem of detail loss often occurs in the process of removing haze. CLAHE can help to retain more sky details while removing fog, making the sky look more real and clear. In summary, the CLAHE algorithm can enhance the contrast of the sky area and retain detail information during the dehazing process, and it has local adaptability. Therefore, it is an effective method to use the CLAHE algorithm to remove fog in foggy images in most sky areas.
[0115] Step S6: outputting the defogging image of the tugboat according to the present invention: outputting the defogging image to achieve the defogging effect of the tugboat perspective image.
[0116] Example 2: In order to verify the actual effect comparison of the method described in the present invention, the port side perspective image of the main deck of the tugboat "Yungang Electric Tug No. 2" built by Lianyungang Port Barge Hongyun Industrial Co., Ltd. was selected for verification. Tugboats often encounter foggy days or low-visibility severe weather when operating in ports. The port side perspective image of the main deck of the tugboat "Yungang Electric Tug No. 2" was selected for defogging operation. First, the port side perspective image of the main deck of the tugboat was selected as input, and the algorithm of the present invention was used for defogging. The classic dark channel prior algorithm and contrast enhancement algorithm were used to compare the defogging effect of the algorithm of the present invention. The algorithm defogging effect was evaluated through subjective and objective evaluations. The subjective evaluation is as follows: Figure 3As shown in Table 1, objective evaluation uses PSNR, SSIM, and MSE to evaluate images. PSNR is the peak signal-to-noise ratio, which is an indicator for measuring image quality. PSNR is the most common and widely used objective evaluation indicator for images. The larger the PSNR value, the better the image quality. SSIM is the similarity structure ratio, which is an indicator for measuring the similarity between two images. SSIM is a number between 0 and 1. The larger the value, the smaller the difference between the output image and the undistorted image, that is, the better the image quality. When the two images are exactly the same, SSIM = 1. MSE is the mean square error, which is an indicator for measuring the difference between the model prediction value and the actual observation value. It is obtained by calculating the average of the squares of the difference between the prediction value and the actual observation value. The smaller the MSE, the smaller the difference between the prediction result of the dehazing algorithm and the true value, which usually means that the dehazing algorithm has better performance.
[0117] Table 1: Comparison of objective evaluation indicators under different algorithms
[0118]
[0119] It can be seen from the subjective evaluation that the defogging effect of the algorithm of the present invention can retain the details of the original image and can accurately defog the image from the tugboat's perspective. It can be seen from the objective evaluation indicators that the PSNR value of the algorithm of the present invention is the largest, indicating that the defogging image is of high quality. The SSIM is closest to 1, indicating that the image is distortion-free and the quality is better. The MSE value is the smallest, indicating that the difference between the prediction result of the algorithm of the present invention and the true value of the original image is the smallest, which means that the performance of the present invention is better. Through this comparative experiment, it can be seen that the present invention can achieve effective and accurate defogging effect for defogging images from the tugboat's perspective.
[0120] Example 3: In order to verify the actual effect comparison of the method of the present invention, the remote image at sea from the perspective of the tugboat "Yungang Electric Tug No. 2" built by Lianyungang Port Barge Hongyun Industrial Co., Ltd. was selected for verification. Tugboats often encounter foggy days or low-visibility bad weather when operating in ports. The remote image at sea from the perspective of the tugboat "Yungang Electric Tug No. 2" was selected for defogging. First, the remote image from the perspective of the tugboat was selected as input, and the algorithm of the present invention was used for defogging. The classic dark channel prior algorithm and contrast enhancement algorithm were used to compare the defogging effect of the algorithm of the present invention. The algorithm defogging effect was evaluated through subjective and objective evaluations. The subjective evaluation is as follows: Figure 4 As shown in Table 2, objective evaluation uses PSNR, SSIM, and MSE to evaluate images.
[0121] Table 2: Comparison of objective evaluation indicators under different algorithms
[0122]
[0123] It can be seen from the subjective evaluation that the defogging effect of the algorithm of the present invention can retain the details of the original image and can accurately defog the image from the tugboat's perspective. It can be seen from the objective evaluation indicators that the PSNR value of the algorithm of the present invention is the largest, indicating that the defogging image is of high quality. The SSIM is closest to 1, indicating that the image is distortion-free and the quality is better. The MSE value is the smallest, indicating that the difference between the prediction result of the algorithm of the present invention and the true value of the original image is the smallest, which means that the performance of the present invention is better. Through this comparative experiment, it can be seen that the present invention can achieve effective and accurate defogging effect for defogging images from the tugboat's perspective.
[0124] Example 4: In order to verify the actual effect comparison of the method described in the present invention, the bow perspective image of the tugboat "Yungang Electric Tug No. 2" built by Lianyungang Port Barge Hongyun Industrial Co., Ltd. was selected for verification. The tugboat is operating in the port and often encounters foggy days or low visibility inclement weather. The bow perspective image of the tugboat "Yungang Electric Tug No. 2" was selected for defogging operation. First, the bow perspective image of the tugboat was selected as input, and the algorithm of the present invention was used for defogging. The classic dark channel prior algorithm and contrast enhancement algorithm were used to compare the defogging effect of the algorithm of the present invention. The algorithm defogging effect was evaluated through subjective and objective evaluations. The subjective evaluation is as follows: Figure 5 As shown in Table 3, objective evaluation uses PSNR, SSIM, and MSE to evaluate images.
[0125] Table 3: Comparison of objective evaluation indicators under different algorithms
[0126]
[0127] From the subjective evaluation, it can be seen that the defogging effect of the algorithm of the present invention can retain the details of the original image and can accurately defog the image from the bow perspective of the tugboat. From the objective evaluation indicators, it can be seen that the PSNR value of the algorithm of the present invention is the largest, indicating that the defogging image is of high quality. The SSIM is closest to 1, indicating that the image is distortion-free and the quality is better. The MSE value is the smallest, indicating that the difference between the prediction result of the algorithm of the present invention and the true value of the original image is the smallest, which means that the performance of the present invention is better. Through this comparative experiment, it can be seen that for the defogging of the tugboat perspective image, the present invention can achieve an effective and accurate defogging effect.
[0128] By using a large number of tugboat perspective images of different sizes for time comparison evaluation, the present invention can well ensure the real-time defogging of tugboat perspective images, as shown in Table 4, which shows the processing time of different defogging methods for images of different sizes. The time complexity of the algorithm of the present invention is O(m×n×r), where m×n is the size of the image and r is the local area of a selected neighborhood.
[0129] Table 4: Time consumption of different algorithms
[0130]
[0131]
[0132] The experimental results show that the algorithm can maintain real-time performance for images from the perspective of tugboats of different sizes, consumes the least time and can meet the real-time requirements of the tugboat during navigation. The method can perform real-time defogging operations on images from the perspective of tugboats.
[0133] The above embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A method for defogging a tugboat perspective image by enhancing local contrast, characterized in that: The method comprises the following steps: S1: Establishment of atmospheric optical model: Input the foggy image from the perspective of the tugboat, use the atmospheric optical model to explain the atmospheric scattering phenomenon in the image, and establish the mathematical relationship between the atmospheric light value and transmittance; The establishment of the atmospheric optical model specifically includes the following steps: S1-1: input foggy image from the perspective of the tugboat; S1-2: Apply an atmospheric optical model to analyze and explain the color changes observed in foggy images. The atmospheric optical model calculation formula is: I(p)=t(p)J(p)+(1-t(p))A (1) Where J(p)=(J r (p),J g (p),J b (p)) T and I(p)=(I r (p),I g (p),I b (p)) T denote the original color at pixel point p and the observed color at pixel position p respectively; A=(A r ,A g ,A b ) T It represents the global atmospheric light value, that is, the atmospheric ambient light; t(p) represents the transmittance of the reflected light, and its value range is between 0 and 1. When the transmittance is 0, it means that the light is completely absorbed or reflected by the medium without penetrating; and when the transmittance is 1, it means that the light is completely transmitted through the medium without being absorbed or reflected; S1-3: According to the scattering and attenuation of light under atmospheric conditions, the transmittance t(p) is calculated. The transmittance t(p) is used to indicate the attenuation degree of light during propagation. The transmittance t(p) is affected by the distance between the pixel position p and the camera. The calculation formula of t(p) is: t(p)=e -ρd(p) (2) Where d(p) represents the depth from the camera to the scene at pixel position p, ρ is the attenuation coefficient determined by weather conditions, and ρ is specifically set to 1; S2: Atmospheric light value estimation: The atmospheric light value area is accurately located in the foggy image through the quadtree iteration method, and then the atmospheric light value of this area is estimated using the statistical analysis method to ensure the accuracy of the atmospheric light value estimation; The atmospheric light value estimation has the following characteristics: the atmospheric light A is estimated as the brightest color in the image; in foggy areas, the variance of pixel values is low, the color and brightness are relatively uniform, the brightness changes of other objects are relatively small, and the atmospheric light is one of the brightest parts; The atmospheric light value estimation specifically adopts a quadtree-based iterative method, which specifically includes the following steps: S2-1: The input foggy image is initially divided into four rectangular regions. The quadtree is a recursive data structure that first decomposes the image into four sub-blocks of equal size, and then repeats the search process for each sub-block until the termination condition is met; S2-2: Then define the score of each region as the average pixel value minus the standard deviation of the pixel values in the region, and calculate the score for each region; S2-3: Select the region with the highest score and further subdivide it into four smaller rectangular regions; S2-4: Repeat steps S2-2 and S2-3 until the score of the selected area is less than a preset threshold; S2-5: In the finally selected small area, a color vector with the smallest distance from a pure white vector is selected as the atmospheric light value, where the pure white vector is specifically (255, 255, 255); S3: Optimal transmittance estimation: Calculate the loss function through the mean square error, minimize the loss function under different transmittances, and select the transmittance with the maximum contrast of the block after dehazing; The optimal transmittance estimation specifically includes the following steps: S3-1: Relate the observed image to the real scene radiation and atmospheric conditions through each block with a fixed transmission value t, as calculated by: Where J(p) represents the recovered scene radiance. After estimating the atmospheric light A, J(p) depends on the choice of transmittance t. A foggy block will have a lower contrast, while the contrast of the restored block will increase as the estimated transmittance t becomes smaller. S3-2: Define the mean square error contrast of a color channel as the variance of the pixel value, estimate the optimal t, and the specific calculation formula of the mean square error is: Among them, c represents the index of the color channel, It's J c The average value of (p), N is the number of pixels in a block, where the index of the color channel specifically includes red, green and blue; The calculation formula of the mean square error contrast of the restored block is: in, It is the input block I c The average value of (p), the mean square error contrast is a decreasing function of the transmittance t; S3-3: Estimate the optimal transmittance t for each block by minimizing the overall cost function, which takes into account the contrast cost and information loss cost. The contrast cost is defined by the negative sum of the mean square error contrast of the three color channels of the block, and the information loss cost is represented by the sum of the squares of the truncated values. The contrast cost E contrast It is obtained by the negative sum of the mean square error contrast of the three color channels of each block B. The specific calculation formula is: in, and They are J in block B c (p) and I c The average value of (p), N B is the number of pixels in block B, by minimizing the contrast cost E contrast To maximize the mean square error contrast, the information loss cost E of block B loss The formula for calculating the sum of squares of the truncated values is: Among them, h c (i) is the histogram of input pixel value i in color channel c, α c and β c They represent the intercept where truncation occurs, min{0,J c (p)} and max{0,J c (p)-255} represent the truncated values due to underflow and overflow, respectively. For block B, the optimal transmittance t is found by minimizing the overall cost function * , and its calculation formula is as follows: E=E contrast +λ L AND loss (9) Among them, λ L is a weight parameter used to control the relative relationship between contrast cost and information loss cost. A larger λ L The value will reduce information loss. L = 1, the optimal transmittance value should not cause any information loss, and its calculation formula is: my c∈{r,g,b} my p∈B J c (p)≥0 (10) max c∈{r,g,b} max p∈B J c (p)≤255 (11) Among them, the transmittance t is characterized by the existence of two constraints, and the calculation formula of the constraints is: Among them, E contrast is an increasing function of t, and the optimal transmittance t * It is determined to be the minimum value that satisfies the constraint mixing condition (14), and the minimum value calculation formula (15) is: Among them, adjusting λ L Parameters to strike a balance between contrast enhancement and information loss; S4: Fast guided filtering: Apply fast guided filtering technology to optimize the transmission image, improve the image detail performance and defogging effect; S5: CLAHE local contrast enhancement: Use the CLAHE algorithm to perform local contrast enhancement on the processed image, especially for large single-color areas such as the sky from the tugboat’s perspective, to improve the overall clarity and details of the image; S6: Outputting the defogging tugboat image: showing the final defogging effect and providing a clearer visual image for use.
2. The method for defogging a tugboat perspective image with enhanced local contrast according to claim 1, characterized in that: The fast guided filtering described in step S4 has the following characteristics: The transmittance image is processed by using guided filtering technology; the brightness, contrast or gradient of the original image is selected as the guide image; the guided image is combined with the transmittance image to be filtered for guided filtering processing, and the structural characteristics of the guide image are adjusted through the filtering process.
3. The method for defogging a tugboat perspective image with enhanced local contrast according to claim 2, characterized in that: The CLAHE local contrast enhancement algorithm described in step S5 has the following characteristics: S5-1: When processing foggy images, especially in dense fog areas such as the sky, the CLAHE algorithm is applied to improve the contrast and detail clarity of these areas; S5-2: The CLAHE algorithm dynamically adjusts the contrast of each image region according to the illumination and contrast differences in each image region by locally adaptively adjusting the histogram equalization process, thereby restoring the details of the sky; S5-3: The CLAHE algorithm pays special attention to retaining more detail information while enhancing the local contrast of the image, preventing the common problem of detail smoothing or loss in the dehazing process, making the restored image more visually realistic and natural; S5-4: In the dehazing process, the CLAHE algorithm is specially designed to meet the processing requirements of large homogeneous color areas such as the sky, ensuring that these areas do not visually lose their natural colors and layering due to the processing process.
