# Application of Histogram Equalization for Image Enhancement in Corrosion Areas

Authors: Jianbin Xiong; Dezheng Yu; Qi Wang; Lei Shu; Jian Cen; Qiong Liang; Huanyang Chen; Baocheng Sun
Journal: Shock and Vibration
 (2021)

---

## Abstract

In this paper, an image enhancement algorithm is presented for identification of corrosion areas and dealing with low contrast present in shadow areas of an image. This algorithm uses histogram equalization processing under the hue-saturation-intensity model. First of all, an etched image is transformed from red-green-blue color space to hue-saturation-intensity color space, and only the luminance component is enhanced. Then, part of the enhanced image is combined with the original tone component, followed by saturation and conversion to red-green-blue color space to obtain the enhanced corrosion image. Experimental results show that the proposed method significantly improves overall brightness, increases contrast details in shadow areas, and strengthens identification of corrosion areas in the image.


---

## Body

## 1. Introduction

In several applications, equipment made up of metallic material is widely used. Under the influence of the external environment, the metallic material will be corroded, causing the appearance of several features on the surface of the corrosion area, such as morphology, texture, grayscale, and color. The degree and type of corrosion in the material can be identified by analyzing these features. During visual inspection process, it is difficult to control the influence of the external environment, e.g. [1], light source, distance, and angle [2]. And, therefore, the quality of the corrosion image will be limited to a certain extent especially the corrosion picture inside the metal [3]. For subsequent detection and recognition of corrosion morphology, it is important to enhance this image [4].At present, image enhancement algorithms mainly include single-scale Retinex (SSR) and multiscale Retinex (MSR) enhancement methods, which are based on the color sense consistency model [5–7], direct enhancement method aiming at pixel grayscale [8, 9], homomorphic filtering enhancement method [10, 11], enhancement method of defogging with respect to the dark channel priori theory [12, 13], image enhancement algorithm based on wavelet transform, and histogram equalization algorithm [14, 15]. Each of the above methods has its own advantages and can be used in relevant application scenarios.The Retinex enhancement algorithm is put forward by Ma et al. [16–18]. This method can maintain brightness and details in an image and provide better enhancement for the gray area in the image [19]. Moreover, this method can effectively alleviate the halo phenomenon generated due to color restoration. However, the method is susceptible to color distortion, and the color of the image is different from the original color [20]. Color distortion also occurs when the method of direct processing of pixel values proposed by Mao et al. is used [12]. Although this method improves the dynamic range of image brightness, enhances the low-illumination image to some extent, and deals with Retinex halo artifact. The homomorphic filtering color image enhancement algorithm can improve the image brightness, but it does not deal with metal corrosion images. The dark channel defogging enhancement algorithm put forward by Wang et al. can enhance haze images [17], but it is only limited to images based on the dark channel principle [21]. Xu et al. used wavelet transform for image enhancement [18], and the results show that the wavelet transform can indeed enhance images. However, the image enhancement by this method is not significant. Hao et al. [22] address the problems in Retinex-based methods, such as less-effective image decomposition or strong imaging noise; it requires to carefully model the priori by a regularization term and usually makes the optimization process complicated. So the authors address these issues by proposing a novel Retinex-based low-light image enhancement method, in which the Retinex image decomposition is achieved in an efficient semidecoupled way. The experimental results show that the method has both higher visibility and better visual quality, which outperforms the state-of-the-art low light enhancement methods in terms of several objective and subjective evaluation metrics. Wang et al. [23] proposed a colored image correction method based on nonlinear functional transformation according to the illumination-reflection model and multiscale theory. Compared with the classic algorithm, the proposed algorithm can improve the adaptability of image enhancement in images with low illumination and other issues. Overall brightness and contrast of an image while reducing the impact of uneven illumination. The enhanced images appear clear, bright, and natural.Image processing using a histogram equalization algorithm improves the contrast. However, when there are black parts in an image, enhancing the image will result in the loss of image features [19]. Hou and Liu proposed a metal corrosion image enhancement algorithm called dark details enhancement algorithm [9]. In this algorithm, by enhancing the “I” component in the HSI model, the overall brightness of the image and the recognition degree of the corrosion area can be enhanced. However, the enhancement effect on the hue and saturation of the image is not obvious, and the recognition degree of the corrosion area of the image is not evident.To deal with the problems of the existing algorithms, this paper proposes a new algorithm that combines histogram equalization and dark detail algorithms. These algorithms are chosen as they are known to have good image enhancement performance. Taking advantage of these algorithms and to minimize the image distortion as much as possible, we aim to maximize the information present in an image. The proposed image enhancement algorithm for metal corrosion areas is based on the HSI model [24].The quality of the corrosion image will be limited by the external environmental factors present in an imaging channel. The purpose of this article is to solve this problem.The main contributions and novelty of this paper are as follows:(1)
Aiming at the defects of the metal corrosion image, in order to effectively separate the features and background in the image, the novelty of this paper is to use the histogram equalization to process the metal corrosion image. The experiment shows that the effect is significant.(2)
In this paper, wavelet transform and homomorphic filtering are combined to make the image have a uniform light background and lower distortion rate. At the same time, the combination of them makes the histogram equalization image enhancement better. Finally, a variety of algorithms are compared.(3)
This paper uses histogram equalization and dark detail algorithms to increase the amount of information contained in the image while maintaining a low degree of distortion. The novelty lies in the optimization and adjustment of some parameters in the algorithm in order to better integrate these algorithms.The details of the algorithm proposed in this paper are as follows: firstly, the original corrosion image is converted from RGB color space to HSI color space, and the brightness component is extracted for enhancement. Secondly, the image is enhanced using histogram equalization and dark detail enhancement algorithms. Finally, the enhanced brightness component is restored to RGB color space together with the original saturation and hue components to obtain the enhanced corrosion image. Experimental results show that the enhanced image obtained using this algorithm greatly improves the recognition of corrosion area in the image and facilitates further analysis of corrosion and subsequent damage in metallic materials [25].This paper is organized as follows: in Section2, the theory behind this algorithm is elaborated, and the principles and implementation of the algorithm are described. Section 3 presents an analysis of the results obtained in the specific experimental environment. Section 4 concludes this paper [26].


## 2. Related Theory

In this paper, the HSI model is selected to extract the brightness component of the metal corrosion image. Subsequently, the brightness component is enhanced to improve image identification, which makes it easier to identify the corrosion area of metal. The dark detail enhancement algorithm proposed by Zhao and Sun and histogram equalization algorithm are combined to enhance the image. The best image output is chosen based on the image information entropy [27, 28].Figure1 shows the flowchart of the proposed algorithm: the original corrosion image is converted from RGB color space to the HSI color model, followed by the application of histogram equalization and dark detail enhancement method to the component “I.” The enhanced image is obtained by combining the enhanced “I” component with the original “H” and “S” components [6] and subsequent conversion to the RGB color space. The whole process is implemented using Matlab.Figure 1
Flow chart of combined dark detail and histogram equalization algorithms.


### 2.1. The HSI Model

The HSI model has three components,H, S, and I, which are used to describe the color characteristics. These components represent hue, saturation, and intensity or brightness, respectively. This model reflects the basic attributes of human perception of color. Therefore, the HSI model has been widely used in the image representation and processing system of the human visual perception system. In the HSI model, the color is only related to the “H” and “S” components [26]. Compared with the RGB model, in the HSI model, the correlation degree of each component is relatively small [29]. Thanks to this feature, good color image enhancement can be achieved, albeit with a few distortions [30]. This paper considers the conversion of HSI and RGB and proposes an improved algorithm based on histogram equalization.The formulas for converting the RGB model into HSI model are given by equations (1)–(4) as follows [31]:(1)θ,B≤G,360−θ,B>G,(2)S=3R+G+BminR,G,B,(3)S=13R,G,B,(4)θ=12R−G+R−BR−G2+R−BG−B1/2.In this paper, only the brightness component is enhanced, and after enhancement, it is combined with the original saturation and tonal components.The formulas for converting the HSI model into RGB model are given by equations (5)–(7) as follows [32]:(5)B=I1−S,R=I1+ScosHcos60∘−H,0∘≤H<120∘,G=3I−B+R,(6)R=I1−S,G=I1+ScosH−120∘cos180∘−H,120∘≤H<240∘,B=3I−G+R,(7)G=I1−S,B=I1+ScosH−240∘cos360∘−H,240∘≤H<360∘,R=3I−G+B.


### 2.2. Histogram Equalization

Histogram equalization also known as histogram flattening is a nonlinear stretching of images and redistribution of image pixel values such that the number of pixel values in a certain gray range is roughly the same [26]. The image histogram is relatively flat by enhancing the contrast of the peak portion and reducing the contrast of the valley portions on both sides. In other words, the basic idea behind histogram equalization is that each gray level appears with the same frequency so that the probability of each gray level is evenly distributed, leading to a flat histogram. The image also becomes clear [7].The theoretical formula of histogram equalization is as follows [25]:(1)
Count the number of pixels in each gray level of the original input image. This number corresponding to theith gray level is given by ni, where i=0,1,…,L−1, and L is the total number of gray levels.(2)
Calculate the histogram of the original image, which is the probability density of each grayscale, given byPi (ri) = ni/n, where n is the total number of pixels in the original image.(3)
Calculate the cumulative distribution function as follows:skrk≈∑i=0kPiri,k=0,1,…,L−1.(4)
Calculate the final output grayscalegk = INT [(gmax − gmin) sk(rk) + gmin + 0.5]/(L − 1), k=0,1,…,L−1 and INT⋅ which is an integer operator. Let gmin = 0 and gmax = L-1, this equation can be simplified into gk = INT [(L − 1) sk(rk) + gmin + 0.5]/((L − 1) × I).(5)
According to the mapping relation betweenfk, i.e., the grayscale function of the original image and gk, modify the original grayscale to obtain an output image, whose histogram is approximately evenly distributed.Figures2(a) and 2(b) show the effect of histogram equalization on an image. It can be observed in Figures 2(c) and 2(d) that, after histogram equalization, the number of pixels is spread over all the range of gray levels, the image contrast is significantly improved, and the details in the image can be clearly seen.Figure 2
Comparison of the effect of histogram equalization algorithm. (a) Original image. (b) Histogram of the original image (c) Equalized image. (d) Histogram after equalization.
(a)(b)(c)(d)


### 2.3. Wavelet Adaptive Adjustment

#### 2.3.1. Introduction to Wavelet Adaptive Adjustment

As shown in the example given in the previous subsection, histogram equalization enhances the whole image. However, a corrosion image with different scales and corrosion details cannot be effectively enhanced using only the equalization. Wavelet transforms with good localization properties in both the time spatial domain and frequency domain can be used for multiresolution analysis of signals. This paper uses this transform to make differential improvements to the image enhanced using the histogram equalization and modify the image background with different contrast scales.The flow of the wavelet adaptive adjustment algorithm is given in Figure3. Firstly, the two-dimensional discrete wavelet transform is used to decompose the enhanced image obtained after histogram equalization, referred to as enhanced Figure 1. Secondly, nonlinear filtering operation is applied to the decomposed image group to obtain a filtered image group. Based on this image group, the weighting factor Kj is calculated. Lastly, the image group is recombined based on Kj, resulting in an enhanced image referred to as enhanced Figure 2.Figure 3
Wavelet adaptive adjustment algorithm flow.


#### 2.3.2. Two-Dimensional Discrete Wavelet Decomposition

In the process shown in Figure3, two-dimensional discrete wavelets based on Matlab’s fast decomposition algorithm [33] are used to decompose enhanced Figure 1. The wavelet decomposition series cannot be too large, as a large series leads to a higher computational complexity. Moreover, the illumination distribution characteristics cannot be fully reflected by the low-frequency wavelet coefficients, and as a result, the inhomogeneity of illumination cannot be effectively eliminated. However, if a small decomposition level is used, too much detailed information is included in the low-frequency component, which results in a loss of image details. Therefore, enhancement of the image details can be effectively carried out by choosing a decomposition level that keeps the computational complexity low, but at the same time enhances the image details.In this paper, the image is decomposed into two levels to meet the above requirements. In the proposed algorithm, wavelet adaptive adjustment is only a supplementary step, and under other conditions, the number of decomposition stages can be different, such as three or four. The relevant expression for carrying out the decomposition is shown in the following equation:(8)fx,y=∑nDj−1φn,j−1x,y+∑j=0L−1Sn,jϕn,j−1x,y.The resulting image functionf∈Vj, {Vj,j∈Z} gives a multiresolution analysis of the etched image. The first term on the right side of equation (8) is the low-band image, and the second term is the subimage with different frequency bands. The two-dimensional wavelet functions and scale functions are given by φ (x, y) and ϕ (x, y), respectively, Dj−1 is the low-frequency coefficient, and Sn,j is the high-frequency coefficient. The subscript j represents the image level. Taking the algorithm in this paper as an example, the possible values of j are one and two. Figure 4 shows a schematic diagram of secondary decomposition wavelet image, where S1,1, S2,1, S3,1, and S4,1 are four subregions based on level 1 image decomposition, and S1,2, S2,2, S3,2, and S4,2 are secondary subregions based on level 2 decomposition of S4,1.Figure 4
Schematic diagram of the second-order decomposition wavelet.


#### 2.3.3. Nonlinear Filtering

The nonlinear filtering operation is performed on the decomposed image group obtained in the previous group. The purpose of this operation is to correct the differences between contrast levels in the image background and to prepare for calculations in the next step. The operation modifies the brightness of each pixel in the decomposed image group. The modified value is the difference between maximum and minimum values in the neighborhood of each pixel point divided by the difference between the maximum and minimum values in the overall image. The relevant formula for this filtering operation is shown in the following equation:(9)gxj,yj=maxxj−minxjgmax−gmin.In the above equation,gmax and gmin are the maximum and minimum values in the overall image, respectively, and maxxj and minxj are the maximum and minimum values in the 3×3 neighborhood around the filtering center point Q.


#### 2.3.4. Global Contrast Weighting FactorKj

In order to obtain the global contrast weighting factorKj, the global contrast Kglobalj of the j level needs to be calculated first. It is calculated according to the following equation, where gsumj is the pixel sum of the filtered output image at the j level, and k0 is the adjustment coefficient, which is generally equal to one.(10)Kglobalj=k0·gsumjnumgj.Using the above equation, the global contrast-weighting factorKj of the j-level is calculated as follows:(11)Kj=0.5×log1+1Kglobalj.


#### 2.3.5. Image Reconstruction

Image reconstruction is performed according to the global contrast weighting factorKj and luminance coefficient L0 using the formula shown in equation (12). The coefficient L0 is determined by the overall brightness of the image, and it is fixed as one. Generally, as the reconstruction starts from the lowest level, the algorithm uses the second-level reconstruction first, followed by the first-level reconstruction [32].(12)Zxj,yj=L0·S4,2+∑j=21Kj·S1,2+S2,2+S3,2.


### 2.4. Block DCT (Discrete Cosine Transform) Homomorphic Filtering

Since the captured image is affected by uneven illumination, a few parts of the image may have insufficient local brightness, causing the previously enhanced details to be submerged in the dark background.Using the illumination reflection model and the enhanced Figure2, Zxj,yj can be characterized by two features: the total amount of light source, which is incident on the observed scene and the total amount of reflected light from the object in the scene. The incident light is relatively uniform and shows minor spatial variations, mainly in the low-frequency band. However, due to different natural and structural characteristics of an object, the reflected light shows the significant spatial variation in intensity, which is mainly reflected in the high-frequency band. Therefore, to reduce the influence of uneven illumination, it is necessary to reduce the incident light and increase the reflection light.The homomorphic filtering algorithm consists of first taking the logarithm of the image obtained from the previous step and separating the incident and reflected light components. Fast Fourier transform (FFT) is applied to transform an image from the spatial domain into the frequency domain. Next, the appropriate homomorphic filtering functionHu,v is selected to filter the image, and the filtered image is converted from the frequency domain to the spatial domain using inverse fast Fourier transform (IFFT). Then, the enhanced luminance component image is obtained after taking the index. Finally, the enhanced luminance component image is obtained after taking the index, which eliminates the blocking effect caused by insufficient brightness and gives the final processed image.


## 2.1. The HSI Model

The HSI model has three components,H, S, and I, which are used to describe the color characteristics. These components represent hue, saturation, and intensity or brightness, respectively. This model reflects the basic attributes of human perception of color. Therefore, the HSI model has been widely used in the image representation and processing system of the human visual perception system. In the HSI model, the color is only related to the “H” and “S” components [26]. Compared with the RGB model, in the HSI model, the correlation degree of each component is relatively small [29]. Thanks to this feature, good color image enhancement can be achieved, albeit with a few distortions [30]. This paper considers the conversion of HSI and RGB and proposes an improved algorithm based on histogram equalization.The formulas for converting the RGB model into HSI model are given by equations (1)–(4) as follows [31]:(1)θ,B≤G,360−θ,B>G,(2)S=3R+G+BminR,G,B,(3)S=13R,G,B,(4)θ=12R−G+R−BR−G2+R−BG−B1/2.In this paper, only the brightness component is enhanced, and after enhancement, it is combined with the original saturation and tonal components.The formulas for converting the HSI model into RGB model are given by equations (5)–(7) as follows [32]:(5)B=I1−S,R=I1+ScosHcos60∘−H,0∘≤H<120∘,G=3I−B+R,(6)R=I1−S,G=I1+ScosH−120∘cos180∘−H,120∘≤H<240∘,B=3I−G+R,(7)G=I1−S,B=I1+ScosH−240∘cos360∘−H,240∘≤H<360∘,R=3I−G+B.


## 2.2. Histogram Equalization

Histogram equalization also known as histogram flattening is a nonlinear stretching of images and redistribution of image pixel values such that the number of pixel values in a certain gray range is roughly the same [26]. The image histogram is relatively flat by enhancing the contrast of the peak portion and reducing the contrast of the valley portions on both sides. In other words, the basic idea behind histogram equalization is that each gray level appears with the same frequency so that the probability of each gray level is evenly distributed, leading to a flat histogram. The image also becomes clear [7].The theoretical formula of histogram equalization is as follows [25]:(1)
Count the number of pixels in each gray level of the original input image. This number corresponding to theith gray level is given by ni, where i=0,1,…,L−1, and L is the total number of gray levels.(2)
Calculate the histogram of the original image, which is the probability density of each grayscale, given byPi (ri) = ni/n, where n is the total number of pixels in the original image.(3)
Calculate the cumulative distribution function as follows:skrk≈∑i=0kPiri,k=0,1,…,L−1.(4)
Calculate the final output grayscalegk = INT [(gmax − gmin) sk(rk) + gmin + 0.5]/(L − 1), k=0,1,…,L−1 and INT⋅ which is an integer operator. Let gmin = 0 and gmax = L-1, this equation can be simplified into gk = INT [(L − 1) sk(rk) + gmin + 0.5]/((L − 1) × I).(5)
According to the mapping relation betweenfk, i.e., the grayscale function of the original image and gk, modify the original grayscale to obtain an output image, whose histogram is approximately evenly distributed.Figures2(a) and 2(b) show the effect of histogram equalization on an image. It can be observed in Figures 2(c) and 2(d) that, after histogram equalization, the number of pixels is spread over all the range of gray levels, the image contrast is significantly improved, and the details in the image can be clearly seen.Figure 2
Comparison of the effect of histogram equalization algorithm. (a) Original image. (b) Histogram of the original image (c) Equalized image. (d) Histogram after equalization.
(a)(b)(c)(d)


## 2.3. Wavelet Adaptive Adjustment

### 2.3.1. Introduction to Wavelet Adaptive Adjustment

As shown in the example given in the previous subsection, histogram equalization enhances the whole image. However, a corrosion image with different scales and corrosion details cannot be effectively enhanced using only the equalization. Wavelet transforms with good localization properties in both the time spatial domain and frequency domain can be used for multiresolution analysis of signals. This paper uses this transform to make differential improvements to the image enhanced using the histogram equalization and modify the image background with different contrast scales.The flow of the wavelet adaptive adjustment algorithm is given in Figure3. Firstly, the two-dimensional discrete wavelet transform is used to decompose the enhanced image obtained after histogram equalization, referred to as enhanced Figure 1. Secondly, nonlinear filtering operation is applied to the decomposed image group to obtain a filtered image group. Based on this image group, the weighting factor Kj is calculated. Lastly, the image group is recombined based on Kj, resulting in an enhanced image referred to as enhanced Figure 2.Figure 3
Wavelet adaptive adjustment algorithm flow.


### 2.3.2. Two-Dimensional Discrete Wavelet Decomposition

In the process shown in Figure3, two-dimensional discrete wavelets based on Matlab’s fast decomposition algorithm [33] are used to decompose enhanced Figure 1. The wavelet decomposition series cannot be too large, as a large series leads to a higher computational complexity. Moreover, the illumination distribution characteristics cannot be fully reflected by the low-frequency wavelet coefficients, and as a result, the inhomogeneity of illumination cannot be effectively eliminated. However, if a small decomposition level is used, too much detailed information is included in the low-frequency component, which results in a loss of image details. Therefore, enhancement of the image details can be effectively carried out by choosing a decomposition level that keeps the computational complexity low, but at the same time enhances the image details.In this paper, the image is decomposed into two levels to meet the above requirements. In the proposed algorithm, wavelet adaptive adjustment is only a supplementary step, and under other conditions, the number of decomposition stages can be different, such as three or four. The relevant expression for carrying out the decomposition is shown in the following equation:(8)fx,y=∑nDj−1φn,j−1x,y+∑j=0L−1Sn,jϕn,j−1x,y.The resulting image functionf∈Vj, {Vj,j∈Z} gives a multiresolution analysis of the etched image. The first term on the right side of equation (8) is the low-band image, and the second term is the subimage with different frequency bands. The two-dimensional wavelet functions and scale functions are given by φ (x, y) and ϕ (x, y), respectively, Dj−1 is the low-frequency coefficient, and Sn,j is the high-frequency coefficient. The subscript j represents the image level. Taking the algorithm in this paper as an example, the possible values of j are one and two. Figure 4 shows a schematic diagram of secondary decomposition wavelet image, where S1,1, S2,1, S3,1, and S4,1 are four subregions based on level 1 image decomposition, and S1,2, S2,2, S3,2, and S4,2 are secondary subregions based on level 2 decomposition of S4,1.Figure 4
Schematic diagram of the second-order decomposition wavelet.


### 2.3.3. Nonlinear Filtering

The nonlinear filtering operation is performed on the decomposed image group obtained in the previous group. The purpose of this operation is to correct the differences between contrast levels in the image background and to prepare for calculations in the next step. The operation modifies the brightness of each pixel in the decomposed image group. The modified value is the difference between maximum and minimum values in the neighborhood of each pixel point divided by the difference between the maximum and minimum values in the overall image. The relevant formula for this filtering operation is shown in the following equation:(9)gxj,yj=maxxj−minxjgmax−gmin.In the above equation,gmax and gmin are the maximum and minimum values in the overall image, respectively, and maxxj and minxj are the maximum and minimum values in the 3×3 neighborhood around the filtering center point Q.


### 2.3.4. Global Contrast Weighting FactorKj

In order to obtain the global contrast weighting factorKj, the global contrast Kglobalj of the j level needs to be calculated first. It is calculated according to the following equation, where gsumj is the pixel sum of the filtered output image at the j level, and k0 is the adjustment coefficient, which is generally equal to one.(10)Kglobalj=k0·gsumjnumgj.Using the above equation, the global contrast-weighting factorKj of the j-level is calculated as follows:(11)Kj=0.5×log1+1Kglobalj.


### 2.3.5. Image Reconstruction

Image reconstruction is performed according to the global contrast weighting factorKj and luminance coefficient L0 using the formula shown in equation (12). The coefficient L0 is determined by the overall brightness of the image, and it is fixed as one. Generally, as the reconstruction starts from the lowest level, the algorithm uses the second-level reconstruction first, followed by the first-level reconstruction [32].(12)Zxj,yj=L0·S4,2+∑j=21Kj·S1,2+S2,2+S3,2.


## 2.3.1. Introduction to Wavelet Adaptive Adjustment

As shown in the example given in the previous subsection, histogram equalization enhances the whole image. However, a corrosion image with different scales and corrosion details cannot be effectively enhanced using only the equalization. Wavelet transforms with good localization properties in both the time spatial domain and frequency domain can be used for multiresolution analysis of signals. This paper uses this transform to make differential improvements to the image enhanced using the histogram equalization and modify the image background with different contrast scales.The flow of the wavelet adaptive adjustment algorithm is given in Figure3. Firstly, the two-dimensional discrete wavelet transform is used to decompose the enhanced image obtained after histogram equalization, referred to as enhanced Figure 1. Secondly, nonlinear filtering operation is applied to the decomposed image group to obtain a filtered image group. Based on this image group, the weighting factor Kj is calculated. Lastly, the image group is recombined based on Kj, resulting in an enhanced image referred to as enhanced Figure 2.Figure 3
Wavelet adaptive adjustment algorithm flow.


## 2.3.2. Two-Dimensional Discrete Wavelet Decomposition

In the process shown in Figure3, two-dimensional discrete wavelets based on Matlab’s fast decomposition algorithm [33] are used to decompose enhanced Figure 1. The wavelet decomposition series cannot be too large, as a large series leads to a higher computational complexity. Moreover, the illumination distribution characteristics cannot be fully reflected by the low-frequency wavelet coefficients, and as a result, the inhomogeneity of illumination cannot be effectively eliminated. However, if a small decomposition level is used, too much detailed information is included in the low-frequency component, which results in a loss of image details. Therefore, enhancement of the image details can be effectively carried out by choosing a decomposition level that keeps the computational complexity low, but at the same time enhances the image details.In this paper, the image is decomposed into two levels to meet the above requirements. In the proposed algorithm, wavelet adaptive adjustment is only a supplementary step, and under other conditions, the number of decomposition stages can be different, such as three or four. The relevant expression for carrying out the decomposition is shown in the following equation:(8)fx,y=∑nDj−1φn,j−1x,y+∑j=0L−1Sn,jϕn,j−1x,y.The resulting image functionf∈Vj, {Vj,j∈Z} gives a multiresolution analysis of the etched image. The first term on the right side of equation (8) is the low-band image, and the second term is the subimage with different frequency bands. The two-dimensional wavelet functions and scale functions are given by φ (x, y) and ϕ (x, y), respectively, Dj−1 is the low-frequency coefficient, and Sn,j is the high-frequency coefficient. The subscript j represents the image level. Taking the algorithm in this paper as an example, the possible values of j are one and two. Figure 4 shows a schematic diagram of secondary decomposition wavelet image, where S1,1, S2,1, S3,1, and S4,1 are four subregions based on level 1 image decomposition, and S1,2, S2,2, S3,2, and S4,2 are secondary subregions based on level 2 decomposition of S4,1.Figure 4
Schematic diagram of the second-order decomposition wavelet.


## 2.3.3. Nonlinear Filtering

The nonlinear filtering operation is performed on the decomposed image group obtained in the previous group. The purpose of this operation is to correct the differences between contrast levels in the image background and to prepare for calculations in the next step. The operation modifies the brightness of each pixel in the decomposed image group. The modified value is the difference between maximum and minimum values in the neighborhood of each pixel point divided by the difference between the maximum and minimum values in the overall image. The relevant formula for this filtering operation is shown in the following equation:(9)gxj,yj=maxxj−minxjgmax−gmin.In the above equation,gmax and gmin are the maximum and minimum values in the overall image, respectively, and maxxj and minxj are the maximum and minimum values in the 3×3 neighborhood around the filtering center point Q.


## 2.3.4. Global Contrast Weighting FactorKj

In order to obtain the global contrast weighting factorKj, the global contrast Kglobalj of the j level needs to be calculated first. It is calculated according to the following equation, where gsumj is the pixel sum of the filtered output image at the j level, and k0 is the adjustment coefficient, which is generally equal to one.(10)Kglobalj=k0·gsumjnumgj.Using the above equation, the global contrast-weighting factorKj of the j-level is calculated as follows:(11)Kj=0.5×log1+1Kglobalj.


## 2.3.5. Image Reconstruction

Image reconstruction is performed according to the global contrast weighting factorKj and luminance coefficient L0 using the formula shown in equation (12). The coefficient L0 is determined by the overall brightness of the image, and it is fixed as one. Generally, as the reconstruction starts from the lowest level, the algorithm uses the second-level reconstruction first, followed by the first-level reconstruction [32].(12)Zxj,yj=L0·S4,2+∑j=21Kj·S1,2+S2,2+S3,2.


## 2.4. Block DCT (Discrete Cosine Transform) Homomorphic Filtering

Since the captured image is affected by uneven illumination, a few parts of the image may have insufficient local brightness, causing the previously enhanced details to be submerged in the dark background.Using the illumination reflection model and the enhanced Figure2, Zxj,yj can be characterized by two features: the total amount of light source, which is incident on the observed scene and the total amount of reflected light from the object in the scene. The incident light is relatively uniform and shows minor spatial variations, mainly in the low-frequency band. However, due to different natural and structural characteristics of an object, the reflected light shows the significant spatial variation in intensity, which is mainly reflected in the high-frequency band. Therefore, to reduce the influence of uneven illumination, it is necessary to reduce the incident light and increase the reflection light.The homomorphic filtering algorithm consists of first taking the logarithm of the image obtained from the previous step and separating the incident and reflected light components. Fast Fourier transform (FFT) is applied to transform an image from the spatial domain into the frequency domain. Next, the appropriate homomorphic filtering functionHu,v is selected to filter the image, and the filtered image is converted from the frequency domain to the spatial domain using inverse fast Fourier transform (IFFT). Then, the enhanced luminance component image is obtained after taking the index. Finally, the enhanced luminance component image is obtained after taking the index, which eliminates the blocking effect caused by insufficient brightness and gives the final processed image.


## 3. Experimental Results and Analysis

### 3.1. Experimental Environment

This paper proposes an image enhancement algorithm for observation of metal corrosion areas. The algorithm is mainly applied for image enhancement after pipeline image acquisition, and it is useful for detection and identification of subsequent corrosion morphology. Therefore, in order to verify the enhancement effect of the algorithm on the metal pipe image, images of a metal pipe corroded due to exposure to natural environment are selected. The photos of the metal pipes are given in Figure5, where the corrosion can be observed.Figure 5
Corroded metal pipe.
(a)(b)(c)


### 3.2. Experimental Procedure

Three corrosion images with different corrosion patterns, uneven brightness, and low contrast in the corrosion areas are used for testing the performance of the proposed algorithm. These images are shown in Figure6. The pipeline corrosion images shown in Figure 6 are enhanced by dark detail enhancement algorithm, defogging algorithm, homomorphic filtering, histogram equalization, and the algorithm proposed in this paper. The Matlab software is used for plotting the histogram of the enhanced images. The information entropy values of these images are also calculated and compared.Figure 6
Corroded metal pipe. (a) Corrosion image 1. (b) Corrosion image 2. (c) Corrosion image 3.
(a)(b)(c)


### 3.3. Experimental Results

The gray histograms of the three corrosion images enhanced by the dark detail enhancement algorithm, the defogging algorithm, the homomorphic filtering, the histogram equalization, and the proposed algorithm are shown in Figures7–9.Figure 7
Comparison of enhanced corrosion image 1 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Figure 8
Comparison of enhanced corrosion image 2 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Figure 9
Comparison of enhanced corrosion image 3 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Table1 gives the information entropy of the original images and the images enhanced using different enhancement algorithms shown in Figure 6. Table 2 is the mean and variance of the information entropy of an image set consisting of 20 corrosion images and the image set enhanced using different algorithms. Entropy is an important indicator to measure the amount of information present in an image. A large entropy value indicates the presence of a higher amount of information in an image, which means a better image quality.Table 1
Information entropy of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image5.78525.30785.6116Dark detail enhancement [24]6.30036.31146.4265Defogging algorithm [17]7.37927.12807.2139Homomorphic filtering [15]7.29136.89007.1972Histogram [26]7.47147.39787.4569Proposed algorithm7.41857.61967.3890Table 2
Information entropy indicators of image sets.
Enhanced methodInformation entropy meanInformation entropy varianceOriginal image5.95190.1883Dark detail enhancement [24]6.62810.0820Defogging algorithm [17]7.37010.0331Homomorphic filtering [15]6.85410.1929Histogram [26]7.52770.0313Proposed algorithm7.52810.0168Firstly, it can be observed from the original corrosion images shown in Figures7–9 that their overall brightness tends to be low, due to which some details in parts of the images cannot be recognized and distinguished from the background. Therefore, the corrosion degree detection of the tested area is directly affected due to low brightness. Figures 9(c) and 9(d) are the results after enhancement by the defogging algorithm and the homomorphic filtering. Although the information entropy values calculated after the use of these algorithms indicate improved image quality, some distortions occur.The data of Tables1 and 2 show that all algorithms increase the information entropy of the image to different extents. According to the data, the proposed algorithm and the histogram equalization algorithm achieve the highest increase in the entropy values. By using the latter algorithm, the information entropy values of corrosion Figure 1 and corrosion Figure 3 are the highest among all the algorithms. However, it can be seen from Figures 7–9 that, after histogram equalization, the dark portions in the original images are enlarged, and consequently, they engulf the image details. The brightness of the images enhanced by the proposed algorithm is obviously improved, which can be seen from the gray histograms of the images. The enhanced images further show significant image improvement offered by the proposed algorithm. From the data in Table 2, it can be observed that the proposed algorithm obtains the highest mean entropy value and the lowest entropy variance. Tables 3 and 4 show the evaluation criteria of each method applied to the image. The average value reflects the brightness of the image. The larger the average value, the greater the image brightness and vice versa. The standard deviation reflects the degree of dispersion between the image pixel value and the average value. The larger the standard deviation, the better the image quality. Based on the images, histograms, and quantitative evaluation shown in this section, it can be concluded that the proposed algorithm has superior and consistent performance.Table 3
Mean of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image87.556284.307885.6116Dark detail enhancement [24]92.300394.311493.4265Defogging algorithm [17]97.379297.128097.2139Homomorphic filtering [15]95.291396.890097.1972Histogram [26]100.4714102.3978101.4569Proposed algorithm107.4185106.6196108.3890Table 4
Standard deviation of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image42.506244.407643.7615Dark detail enhancement [24]48.765247.621549.7351Defogging algorithm [17]52.351753.871452.9013Homomorphic filtering [15]55.542656.091857.8872Histogram [26]60.541262.761561.0195Proposed algorithm63.381265.391164.3075


## 3.1. Experimental Environment

This paper proposes an image enhancement algorithm for observation of metal corrosion areas. The algorithm is mainly applied for image enhancement after pipeline image acquisition, and it is useful for detection and identification of subsequent corrosion morphology. Therefore, in order to verify the enhancement effect of the algorithm on the metal pipe image, images of a metal pipe corroded due to exposure to natural environment are selected. The photos of the metal pipes are given in Figure5, where the corrosion can be observed.Figure 5
Corroded metal pipe.
(a)(b)(c)


## 3.2. Experimental Procedure

Three corrosion images with different corrosion patterns, uneven brightness, and low contrast in the corrosion areas are used for testing the performance of the proposed algorithm. These images are shown in Figure6. The pipeline corrosion images shown in Figure 6 are enhanced by dark detail enhancement algorithm, defogging algorithm, homomorphic filtering, histogram equalization, and the algorithm proposed in this paper. The Matlab software is used for plotting the histogram of the enhanced images. The information entropy values of these images are also calculated and compared.Figure 6
Corroded metal pipe. (a) Corrosion image 1. (b) Corrosion image 2. (c) Corrosion image 3.
(a)(b)(c)


## 3.3. Experimental Results

The gray histograms of the three corrosion images enhanced by the dark detail enhancement algorithm, the defogging algorithm, the homomorphic filtering, the histogram equalization, and the proposed algorithm are shown in Figures7–9.Figure 7
Comparison of enhanced corrosion image 1 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Figure 8
Comparison of enhanced corrosion image 2 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Figure 9
Comparison of enhanced corrosion image 3 and the corresponding gray histograms: (a) original corrosion image, (b) dark detail enhancement, (c) defogging, (d) homomorphic filtering, (e) histogram equalization, and (f) proposed algorithm.
(a)(b)(c)(d)(e)(f)Table1 gives the information entropy of the original images and the images enhanced using different enhancement algorithms shown in Figure 6. Table 2 is the mean and variance of the information entropy of an image set consisting of 20 corrosion images and the image set enhanced using different algorithms. Entropy is an important indicator to measure the amount of information present in an image. A large entropy value indicates the presence of a higher amount of information in an image, which means a better image quality.Table 1
Information entropy of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image5.78525.30785.6116Dark detail enhancement [24]6.30036.31146.4265Defogging algorithm [17]7.37927.12807.2139Homomorphic filtering [15]7.29136.89007.1972Histogram [26]7.47147.39787.4569Proposed algorithm7.41857.61967.3890Table 2
Information entropy indicators of image sets.
Enhanced methodInformation entropy meanInformation entropy varianceOriginal image5.95190.1883Dark detail enhancement [24]6.62810.0820Defogging algorithm [17]7.37010.0331Homomorphic filtering [15]6.85410.1929Histogram [26]7.52770.0313Proposed algorithm7.52810.0168Firstly, it can be observed from the original corrosion images shown in Figures7–9 that their overall brightness tends to be low, due to which some details in parts of the images cannot be recognized and distinguished from the background. Therefore, the corrosion degree detection of the tested area is directly affected due to low brightness. Figures 9(c) and 9(d) are the results after enhancement by the defogging algorithm and the homomorphic filtering. Although the information entropy values calculated after the use of these algorithms indicate improved image quality, some distortions occur.The data of Tables1 and 2 show that all algorithms increase the information entropy of the image to different extents. According to the data, the proposed algorithm and the histogram equalization algorithm achieve the highest increase in the entropy values. By using the latter algorithm, the information entropy values of corrosion Figure 1 and corrosion Figure 3 are the highest among all the algorithms. However, it can be seen from Figures 7–9 that, after histogram equalization, the dark portions in the original images are enlarged, and consequently, they engulf the image details. The brightness of the images enhanced by the proposed algorithm is obviously improved, which can be seen from the gray histograms of the images. The enhanced images further show significant image improvement offered by the proposed algorithm. From the data in Table 2, it can be observed that the proposed algorithm obtains the highest mean entropy value and the lowest entropy variance. Tables 3 and 4 show the evaluation criteria of each method applied to the image. The average value reflects the brightness of the image. The larger the average value, the greater the image brightness and vice versa. The standard deviation reflects the degree of dispersion between the image pixel value and the average value. The larger the standard deviation, the better the image quality. Based on the images, histograms, and quantitative evaluation shown in this section, it can be concluded that the proposed algorithm has superior and consistent performance.Table 3
Mean of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image87.556284.307885.6116Dark detail enhancement [24]92.300394.311493.4265Defogging algorithm [17]97.379297.128097.2139Homomorphic filtering [15]95.291396.890097.1972Histogram [26]100.4714102.3978101.4569Proposed algorithm107.4185106.6196108.3890Table 4
Standard deviation of each image before and after enhancement.
Enhanced methodCorrosion image 1Corrosion image 2Corrosion image 3Original image42.506244.407643.7615Dark detail enhancement [24]48.765247.621549.7351Defogging algorithm [17]52.351753.871452.9013Homomorphic filtering [15]55.542656.091857.8872Histogram [26]60.541262.761561.0195Proposed algorithm63.381265.391164.3075


## 4. Conclusion

In this paper, an algorithm for enhancing metal corrosion images was proposed. The proposed algorithm used histogram equalization combined with dark detail enhancement algorithm, which resulted in enhanced metal corrosion image, and improved image quality and recognition degree. The algorithm makes it easier to observe the metal corrosion area and reduces the difficulty in carrying out research on metal products affected by corrosion, which can be important in practical applications. As the proposed algorithm combined two algorithms, the resulting computational complexity was high. Furthermore, image information entropy was the only metric used for selecting and evaluating the images, which can be simplistic for practical applications. Therefore, the next step of our work is to select a set of image quality evaluation metrics to evaluate the algorithm performance in an all-round way and establish a direction for the optimization of the algorithm. At the same time, the logic and structure of the algorithm should be optimized to improve its real-time performance.



---

*Source: 8883571-2021-01-23.xml*