Improved Dark Channel Defogging Algorithm for Defect Detection in Underwater Structures

. Underwater structures are crucial for national economic and social development. However, because of their complex environment, they are susceptible to damage during service. This damage should be prevented to minimize casualties and economic loss. Therefore, this study investigates the problems of disease identiﬁcation and area statistics of underwater structures. To this end, the Dark-Retinex (DR) algorithm that can enhance the image of underwater structure defects is proposed. The algorithm consists of a combination of a dark channel algorithm and the Retinex algorithm. This study analyzes the current research status of underwater image processing technology, designs the overall framework of the DR algorithm, and uses the underwater structure disease image to verify the algorithm. Comparing the eﬀect of the image with only the dark channel defogging and DR algorithm processing, the DR algorithm is observed to achieve “defogging” processing of underwater structural disease images to achieve better enhancement eﬀects. Moreover, for accurate disease area statistics, the binary morphology and optimal threshold segmentation theories are combined to perform disease edge screening and remove interference information. Finally, accurate statistics of the proportion of diseased pixels are achieved, as well as the quantitative detection of surface diseases of underwater structures. After actual operational veriﬁcation, the improved image dehazing and parallel boundary screening algorithms can achieve better application results to detect underwater structure defects and disease statistics. The objective evaluation shows that the DR algorithm facilitates image processing, can obtain relatively high-quality target images, and can solve the problems of time-consuming and labor-intensive detection of underwater structures, with signiﬁcant risks and limitations. This helps pave the way for (1) the actual engineering of surface structure detection of underwater structures, (2) future storage in the database and assessment of hazard levels, and (3) a guide for engineering technicians to take corresponding maintenance measures.


Introduction
e breach of the Oroville Dam, the highest dam in California, caused the evacuation of nearly 200,000 people. When the Fukushima underwater nuclear power plant in Japan leaked, many people were in danger, causing panic over nuclear radiation. In another case, the pier foundation of cross-sea bridges is mostly in the turbid waters of the bay, making it vulnerable to erosion and damage, thus risking lives and economic losses. Accurate and effective damage analysis and assessment are essential to ensure the safety of underwater structures [1]. In recent years, with the rapid developments in computer technology in combination with traditional visual inspection methods for underwater concrete apparent damage, photography and videography methods have been used for detecting underwater structure safety and health [2,3]. e detection method provides objectivity, high diving efficiency, and safety in practical applications [4]. Improving the visibility of underwater images is a crucial step in underwater robot target recognition [5,6]. Commonly used hazy image enhancement methods are histogram equalization [7][8][9], homomorphic filtering [10], and wavelet transforms [11]. ese methods have low complexity and are relatively easy to implement; however, useful information in the image can be lost easily. Although improved methods, such as adaptive mean filtering and weighted median filtering, were later proposed, the effect is enhanced, and the problem of information loss has not yet been solved [12]. Prabhakar and Praveen Kumar proposed an adaptive image wavelet-based denoising method for underwater images. He first used homomorphic filtering to correct nonuniform illumination. After smoothing, he adopted an improved Bayesian shrinkage function to transform the wavelet sub-band threshold method adaptively. However, research shows that the use of wavelet denoising alone to suppress underwater noise is not sufficient [13]. Feifei et al. proposed a new denoising method combining wavelet decomposition and high-pass filter, which also has a specific suppression effect on noise.
is method achieved satisfactory results but was time consuming [14]. van de Weijer et al. gave a more general color constancy hypothesis [15], which unified the hypotheses of "White Patch," "Grey World," and "Shades of Grey" [16][17][18] in one expression. However, owing to the severe attenuation of light underwater, the classic color constancy assumption is typically ineffective. Grewe and Brooks used the wavelet method to fuse multiple foggy images; however, the obtained images could not realize the actual purpose of image dehazing [19]. Yitzhaky et al. used the atmospheric modulation transfer equation to process foggy degraded images; however, the premise of this method is that the fog concentration and the scene depth need to be known in advance [20]. However, these prerequisites are challenging to obtain in practical applications. Tarel and Hautiere supposed that the atmospheric light imaging function is constant in the local range [21]. is method can accomplish the requirements of fast dehazing, but a halo appears on the edges of the scene in the final restored image. He et al. proposed the dark channel priority rule, which accurately determined the fog concentration by estimating the atmospheric transmittance in advance [22]. e statistical results show that most of the outdoor photos use this rule to obtain a good defogging effect and a corresponding depth image. However, this method is prone to blocking effects and affects information discrimination. rough continuous development, the outdoor defogging effect has become very mature. Because the underwater image characteristics are very similar to the haze-day images on land, several scholars have begun to study the restoration of underwater images based on the land-based haze algorithm. Kansal et al. proposed a defogging technique based on color attenuation prior (CAP). Experimental results show that the proposed approach outperforms state-ofthe-art fog removal techniques in terms of efficiency and the defogging effect. In the proposed work, an initial depth map is estimated by using the CAP technique. Because this depth estimation may fail in some cases (e.g., white objects), this method is not suitable for the detection of surface defects in underwater structures [23]. Zuote et al. proposed that the dark channel and Local Maximum Color Value (Local Maximum Color Value, LMCV) prior were directly used for underwater image restoration of ship lock detection. e results showed that the two methods could not be used for the limitation of turbid underwater ship lock detection [24]. e core classifier of LMCV is expressed as follows: (1) Nevertheless, few studies have addressed the detection methods of underwater structure diseases. us, an algorithm should be used which can not only restore the image of the structure disease taken under the turbid water but also alleviate the blocking effect generated when using only the dark channel algorithm for image restoration. Based on computer vision theory that eliminates the limitations of the dark channel algorithm in underwater image processing, this paper proposes a method based on dark channel defogging and the Dark-Retinex algorithm (Dark-Retinex, DR) to capture underwater structure images. e dam images and the underwater structure images of the bridges are processed to obtain the target image. Moreover, the target area obtained is subjected to boundary screening to perform the statistics of the disease area and quantitatively identify the damage of underwater structures. e rest of this paper is organized as follows. Section 2 introduces the algorithm used in this study. Subsequently, the results are presented in Section 3 which shows the processing effect and disease statistical results of the algorithm, and it compares and analyzes the image processing effects and disease ratio statistical results. Finally, Section 4 provides the conclusions of the study and summarizes future research.

Light Degradation in Water.
Water contains a significant amount of dissolved matter and fine particles such that when light is transmitted, it is absorbed, reflected, and refracted by particles in the medium, causing its degradation during transmission [25]. e light degradation model in water is shown in Figure 1. e underwater imaging model is very similar to the foggy imaging model used in foggy image restoration methods [26]. In the following sections, the image enhancement method of DR is introduced, as well as the disease boundary screening process. e verification of the image enhancement method of DR and the effect of the disease boundary screening process is demonstrated in the section describing the results.

DR Image Enhancement Model.
Because the light is refracted or scattered in the water, in underwater images, problems such as ghosting and shadowing of the target object occur, making the target object unclear. erefore, these ghosting and shadowing phenomena can be considered as a "layer of fog." e DR image augmentation logic diagram is shown in Figure 2. e traditional defogging model is where I(x) is the original image, which is the foggy image; O(x) is a fog-free image and the target image; t(x) describes the transmission rate of the medium; and A is the transmittance. e term O(x)t(x) describes the direct attenuation caused by light scattering in the medium [27]. e term A(1 − t(x)) is water vapor [28] that is light scattered in water and will cause the color of the scene to shift. Direct attenuation is a multiplicative deformation to scene radiation, and air light is an additive deformation. To solve the target image O(x), the unknown O, A, and t must be determined from the known I, and equation (2) is an undefined equation; therefore, it is not solvable.
For any image I, in a certain area, the lowest pixel value of each channel of all pixels is close to 0 [29]. erefore, the mathematical expression of the dark channel can be defined as where c represents any of the rgb three channels. e purpose of equation (3) is to take the minimum value of the gray value in the three channels of each pixel in an input image to obtain a gray image. In this gray image, a rectangular window of a specific size is taken as the central pixel, and the minimum value in the rectangular window is used to replace the gray value of the central pixel, thereby obtaining a dark channel image. e statistics and observations demonstrate that the grayscale value of the dark channel image is approximately 0, that is, (1) Estimated water light value A: in the dark channel map, the pixel with the largest pixel value in the top 0.15% of the picture and the pixel with the highest pixel value as the water light value A are selected. e estimation method is simple. Equation (2) is transformed into (2) Transmission estimation: after A is determined, supposing that t(x) is constant in each window, the function t(x) is redefined. Calculating the minimum value twice on both sides of equation (4), we obtain the following equation: Combined with equation (4), we obtain the following equation: Original image 1 Underwater haze image 1

Haze image
Original image 2 Underwater haze image 2 Dark channel dehazing algorithm Retinex algorithm

Advances in Materials Science and Engineering
Finally, we obtain equation (8) as follows: e final transmittance expression is shown as follows: where Ω(x) is a partial are of x.
We obtain a reply image of dark channel defogging using the following equation: (3) Retinex defogging algorithm: because the underwater scene contains white scenes, the processed original image 1 (O 1 ) in Figure 2 is prone to the blocking phenomenon and the halo effect, which makes the processing inefficient. us, we added a step of the Retinex defogging algorithm [30].
Based on the basic image, image transformation into the logarithmic field is performed. Assuming that the essential attributes of the image are the causes of the blocking phenomenon and the halo effect of the image, the image model is shown as follows: Equation (9) has logarithm on both sides; subsequently, equation (12) becomes From equation (12), O 2 and L can be obtained. We selected pixels layer by layer using the image pyramid method. We established top-down layer-by-layer iterations to improve efficiency. e schematic of the pyramid is shown in Figure 3.
Combining equations (13) and (14), we obtain the following equation: ④ After the calculation of the mth layer is finished, the calculation result of the mth layer is interpolated. us, the mth layer becomes twice the original size, which is the same size as the m + 1 layer. e final reflectance is ⑤ When the bottom layer is calculated, the final enhanced image is obtained. Table 1 shows the core procedure of Retinex defogging algorithm.

Boundary Filtering.
In this section, disease edge screening is performed based on images processed by the DR algorithm, and disease ratio statistics are performed [31,32]. e flowchart is shown in Figure 4.
(1) Image graying: eliminate image hue and saturation information for DR images while retaining brightness to convert RGB images to grayscale images. e weighted average algorithm for R, G, and B components is In particular, each pixel in the figure can be found in the corresponding three-dimensional space, which was established by R, G, and B as the axis. e point undergoing through the RGB space makes a vertical line to the R � G � B straight line and obtains an image represented by points on the straight line. us, the conversion from three-dimensional space to one-dimensional space is obtained.
(2) Adjust the brightness value of the gray image. Map brightness in the grayscale image gray DR to the new value in J: Among them, r and S represent the grayscale of gray DR , J, respectively. (3) Global threshold processing and threshold estimation: use the maximum interclass variance method to find a reasonable threshold for the image J, which is included in [0, 1] [33]. e solution process is as follows. Assume that the threshold k has been selected, C 1 is the number of pixels including [0, 1, 2, . . . , k], and C 2 is the number of pixels in- e definition of the maximum interclass variance is where P 1J (k) is the probability of the set C 1J occurrence, P 1J (k) � k i�0 P i ; m GJ is the global mean; and L is an integer representing all the possible gray levels in the image. (4) Divide the image and reverse the image: after the optimal threshold is obtained, binarization is performed using e image is converted into a binary image. After being inverted, the white pixels represent the diseased part. (5) Label the connected domain to remove interference information: the concept of the connected domain is used for regional segmentation. e small-area connecting domains in the binary image are deleted

Results
To verify the effectiveness of the algorithm, the study focused on processing dam images [34] and bridge underwater structures [35]. e image information is shown in Table 2.

Image Processing Effect Verification.
In this section, the six groups of pictures in Table 1 are processed by the DR algorithm, and the effects are displayed in Figure 5. As shown in Figure 5, in Image 1(a), the fracture boundary is not clear. Image 1(d) was obtained after applying the DR algorithm, which significantly increased the contrast between the crack and the background. e part of the image surrounded by the orange box can be seen more clearly in Image 1(d) than in Image 1(a). In Image 2(a), the contrast of the image is low, and the color and brightness in the image are not uniform. After the image was processed by the DR algorithm (Image 2(d)), the contrast between the crack and the background was significantly increased. A portion of the crack is deep, and the background is lightened. e orange box highlights this for more clarity and detail. Image 3(a) shows uneven brightness with dark parts. Image 3(d), obtained after processing by the DR algorithm, shows that the color of the crack boundary is deep, but the contrast with the background increased significantly. Image 4(a) shows the blurred crack image. e contrast between the crack and the background image is relatively low, and it is accompanied by noise interference. However, in Image 4(d), the color of the crack boundary deepens, the contrast with the background is significantly increased, the color becomes uniform, and the noise is reduced. In Image 5(a), the color of the image is uneven, and the boundaries are difficult to identify, accompanied by noise. Image 5(d), obtained after processing by the DR algorithm, shows that the color of the exposed border is deepened, the contrast with the background is increased, the brightness is uniform, and the noise was reduced. e features in Image 5(d) are surrounded by the red and orange frames, which are more visible than those in Image 5(a). e image enhancement effect is visible to the naked eye. Image 6(a) is blurred. Image 6(d), obtained after processing by the DR algorithm, shows the main picture. e detail enclosed by the red box in the image is enhanced, the contrast with the background is increased, the picture is bright, and the noise is reduced. Furthermore, subjective visible image enhancement is satisfactory.

Comparison of the Image after Defogging in the Dark
Channel and Image Processing by the DR Algorithm. In this section, for comparison purposes, the six groups of pictures listed in Table 1 are processed by the D, Tarel, Joost, and DR algorithms. e results are displayed in Figure 6.
From the results shown in Figure 6, Image 1, with only dark channel defogging, is compared with the image processed by the DR algorithm. e contrast at the image boundary is low, and the small stone blocks in the frame have a blocky effect boundary. e Tarel algorithm not only reduces the brightness and contrast of the image but also makes the image appear the phenomenon of "halo artifact." is phenomenon exists not only in image 1 but also in image 2-4. e Joost algorithm reduces the brightness of the image by a small margin, but the disease boundary is not clear and the contrast is low, which also exists in Image 2-6(d). Image 2, after the defogging of only the dark channel, still has noise, contrast floor, and insufficient brightness compared with the image processed by the DR algorithm. e gravels in the frame are not prominent because of the blocky effect. Images 3 and 4 still have insufficient contrast and brightness after the defogging of the dark channel. After only defogging the dark channel, compared with the image processed by the DR algorithm, Image 5 illustrates that the frame part is due to the blocky effect. Although the image processed by the Tarel algorithm contains more information, the boundary of the disease is blurred and messy, which makes the contrast decrease. e image also has a small decrease in brightness, which also exists in Image 6. e right corner of Image 6 outlines that the defogging of the dark channel fails to highlight the details owing to the blocky effect.
Using the DR image enhancement method, we obtained brighter, more informative, and clearer target images with high contrast compared with those obtained after defogging in the dark channel. Meanwhile, the DR algorithm presented performed better than the Tarel and Joost algorithms. Because the underwater scene contains white scenes, the image processed by the simple dark channel defogging algorithm is prone to blocky and halo effects, which make the processing unsatisfactory. After adding a step to use the defogging algorithm, the lumpy and halo effects are relieved. e DR algorithm can satisfy the requirements for restoring the diseased images of the structures obtained in the turbid water; it also relieves the blocky effect caused by the dark channel algorithm for image restoration. Moreover, after the boundary filtering of the obtained target images, the diseased part is prominent, which can help identify and improve the statistics of damage on underwater structures.

Objective Evaluation of Image Effects.
e original images of the six samples processed only by dark channel defogging, Tarel's algorithm, Joost's algorithm, and the DR algorithm High-ambiguity underwater dam crack Image 4 Soil-damaged underwater dam crack Image 5 Broad beach bridge pile cap scouring Image 6 Exposed aggregate of the pier 6 Advances in Materials Science and Engineering were used for an objective evaluation using the mean, standard deviation, entropy analysis, and execution time. e average value of the image is used to indicate the average brightness change after the image enhancement.
us, the larger the average brightness, the better the image quality. e more dispersed the image, the better the image quality. Entropy is used to evaluate the ability of the image to provide details. From the perspective of information theory, the amount of information in the image is measured. Execution time is used to estimate program speed.
(1) Image evaluation using the mean: the mean value was calculated for the original groups of images after the defogging of the dark channel, Tarel's algorithm, and Joost's algorithm were applied (hereinafter referred to as the D image, Tarel image, and Joost image), and the images were processed by using the DR algorithm. e data in Table 3 indicate that the average value of the DR enhancement effect map has mostly increased compared to that of the original, D, Tarel,  (2) Image evaluation using standard deviation: the standard deviation was calculated on the six sets of images for the original images, D images, Tarel images, Joost images, and images processed by the DR algorithm e data in Table 4 indicate that the standard deviation of the DR enhancement effect map has increased compared to that of the original, D, Tarel, and Joost images. Among them, the increased ratio in the standard deviation of the DR image (compared to that of the original, D, Tarel, and Joost images) is calculated for Image 1 (8.40%, 0.12%, 300.12%, 291.57%), Image 2 (9.48%, 1.97%, 265.96%, 290.55%), Image 3 (7.52%, 0%, 279.10%, 296.75%), Image 4 (2.36%, 0.38%, 336.77%, 328.40%), Image 5 (2.07%, 0.33%, 336.22%, 356.26%), and Image 6 (0.55%, 1.96%, 448.49%, 473.69%), respectively. rough comparison, the DR image presents a small increase, and the image enhancement effect is slightly evident.
(3) Image evaluation using entropy: the entropy was calculated on the six sets of images for the original images, D images, Tarel images, Joost images, and images processed by the DR algorithm. e data in Table 5 indicate that the entropy value of the DR enhancement effect map increases compared to that of the original, D, Tarel, and Joost images. Among them, the increased ratio of the entropy value of the DR image (compared to that of the e DR image presents a small increase in obtaining image details, and the image enhancement effect is good. e original six sets of example images, D images, and images processed by the DR algorithm are evaluated objectively. e images were processed by the DR algorithm for brightness, contrast, and details. All of them improved and met the expected effect of image enhancement. erefore, the image processed by the DR algorithm can be used to calculate the disease ratio after boundary selection. (4) Execution time: the total time required to execute the technique to obtain a final defogged image (O 2 ) from a foggy image (I) is measured in seconds and is given in Table 6. e results shown in the table indicate that the proposed technique is slightly slower than that of the D algorithm, but it is faster than that of the Tarel algorithm and comparable to that of the Joost algorithm, which can meet the work demand.
erefore, it can be concluded that the proposed technique is better than the other three techniques in achieving high speed while maintaining the overall image quality, as shown in Tables 3-5. In summary, for the Tarel and Joost algorithms, the standard deviation data is far lower than the original, D, and DR images; therefore, the contrast of the picture is reduced, and the effect of boundary screening cannot be compared with the dark channel algorithm and the DR algorithm processing. However, the mean, standard deviation, and entropy of the image processed by the dark channel algorithm and the DR algorithm are within one order of magnitude, which means the boundary screening results can be compared separately.

Disease Edge Screening.
In this section, the six images processed by the DR algorithms are used for disease edge screening and verification.

Screening of Disease Edges in Images.
From the results in Figure 7, the black pixel interference information can be obtained from the binarized image in Images 1-4(c), and Image 6(c), leading to an increase in the disease statistics. e details of the picture in Image 5(c) are more complicated to visualize. e interference information of white pixels in the damaged part reduces the statistical ratio of Image 5(c). Moreover, Images 1-6(d) are obtained after the screening has removed the interference information in the orange frame. In Images 1-4(d), the crack direction is consistent with Image (a), the boundaries are clear, and the image processing effect is good. In Image 4(d), although there are   still "burrs" in the crack boundary, overall, the improvement effect is significant.

Disease Ratio Statistics.
e study considers that slight differences in brightness will be present depending on the degree of damage; thus, the brightness 225-235, 235-245, and 245-255 are defined as white, very white, and pure white, respectively, and the ratio statistics are performed. Table 7 summarizes the core procedure of the DR image disease ratio statistics.  Based on the images of Figure 7(d), the disease ratio was performed. Table 8 lists the statistical results.

Comparison of the Filtering Effect between the Image after the Defogging of the Dark Channel and the Image
Processed by the DR Algorithm. As shown in Figure 8, the cracks in Images 1-4 have poor visibility owing to the low surrounding brightness and the blocky effect. When the disease boundary is screened, the low-luminance pixel portion is included in the diseased pixels, resulting in an increase in the statistical results. e image of the underwater structure of the bridge in Images 5-6 has a blocky effect. is increases the brightness of the diseased part and does not count into the diseased pixels, resulting in a reduction in the statistical results.

Conclusions
is paper proposes a DR algorithm based on the combination of the dark channel and Retinex algorithms to achieve the purpose of restoration and accurate statistics of disease images on the surface of underwater structures. Unlike other methods, the DR algorithm not only can recover the structure disease images obtained in turbid water but also can alleviate the blocky effect caused by the dark channel algorithm for image restoration. e enhancement effect is satisfied, which is reflected in the obtained results. After filtering through the boundary, the image processed by the DR image algorithm filters the interference information better, and the percentage of diseased pixels is more accurate than considering only defogging of the dark channel. It can achieve the purpose of quantitative detection of surface diseases on underwater structures. rough practical verification, the following conclusions are reached: (1) e image processed by the proposed algorithm has precise details and prominent features. It shows specific advantages for visual and objective evaluation, which can provide a reference for the study of image dehazing algorithms. (2) e DR parallel boundary screening algorithm can be applied to detect surface diseases of underwater structures quantitatively. Moreover, it can provide practical guidance for the detection of underwater structures in the future.
Although the DR algorithm provides a significant enhancement in image processing, the following improvements are required for the practical application of the algorithm: (1) Although the DR algorithm achieves satisfactory enhancements and outstanding details, it may fail when the model is not valid. First, when the color of the diseased part is very similar to the background color, the disease is difficult to reflect. Second, when the uneven illumination of the picture causes different brightness of the left and right parts of the picture, the water light value estimation would be incorrect. (2) Although the DR algorithm achieves the purpose of enhancing the contrast of the image, the colors of the objects in the DR recovery image are not vivid and need to be further improved in future research.

Data Availability
e data used to support the findings of this study are included in the article.

Conflicts of Interest
e authors declare no conflicts of interest regarding the publication of this paper.