Image Defogging Algorithm Based on Sparse Representation

Aiming at the problems of low contrast and low definition of fog degraded image, this paper proposes an image defogging algorithm based on sparse representation. Firstly, the algorithm transforms image fromRGB space to HSI space and uses two-level wavelet transform extract features of image brightness components. 'en, it uses the K-SVD algorithm training dictionary and learns the sparse features of the fog-free image to reconstructed I-components of the fog image. Using the nonlinear stretching approach for saturation component improves the brightness of the image. Finally, convert from HSI space to RGB color space to get the defog image. Experimental results show that the algorithm can effectively improve the contrast and visual effect of the image. Compared with several common defog algorithms, the percentage of image saturation pixels is better than the comparison algorithm.


Introduction
In fog and haze weather conditions, the image taken by using imaging equipment is prone to quality degradation. e degraded image brings difficulties to the application of image in military, traffic, driverless vehicles, and other fields [1]. erefore, dehazing the foggy image has important practical application value.
In recent years, many scholars at home and abroad have done a lot of research on image dehazing algorithms, among which the representative algorithms are mainly divided into three categories. e first is the method based on image enhancement, which achieves the purpose of dehazing by improving the contrast of the image, mainly including Retinex algorithm [2], wavelet transform algorithm [3], and histogram equalization algorithm [4]. In view of the problem of detail loss and uneven dehazing effect of the adaptive histogram equalization algorithm with limited contrast, Wang et al. [5] proposed a contrast adaptive clipping histogram equalization algorithm, which enhanced image contrast and enriched image detail information.
is method does not consider the cause of image degradation; the image loses some information while enhancing the contrast. e second is the image restoration algorithm based on the imaging model, which constructs the physical model of image degradation, then estimates the unknown parameters in the imaging model through the prior knowledge, and finally recovers the fogless image, for example, dark channel prior algorithm [6], color attenuation prior algorithm [7], atmospheric dissipation function algorithm [8], and so on. He et al. [9] obtained the dark channel prior theory by analyzing statistically a large number of outdoor fogless images, which can be used to better recover fogless images. However, the image after the dehazing is easy to show halo effect, especially in the sky region which does not meet the dark channel prior theory which has serious color distortion. Many scholars put forward improvement measures. Han et al. [6] isolated the sky region of the image for processing by setting the threshold value. In order to improve the real-time performance of the algorithm, the image was reduced, which reduces the time required to figure out the transmittance map, and then interpolation method was used to restore the transmittance map to the size of the original image, and the resulting images achieved a better dehazing effect. Guo et al. [10] divided the image into three regions and adopted different dehazing algorithms for each region, which could well avoid false edges at the junction of sky and scenery. Ti et al. [11] proposed to divide the foggy image into sky region and nonsky region and introduced tolerance parameter correction transmittance to the sky region that does not meet the dark channel prior theory. Fan et al. [12] proposed a dehazing model combining atmospheric scattering model and color attenuation prior, which greatly improved the clarity and contrast of the recovered image. Peng et al. [13] eliminated color distortion while restoring contrast by adding color adaptive correction. Xu et al. [14] proposed an image dehazing algorithm based on the combination of sparse representation and dark channel prior based on K-SVD, which has a good dehazing effect. Liu et al. [15] refined the medium transfer map according to the sparse features of fog gray images and then reversely solved the fog degradation model. Finally, the processing advantage of the sky region in the fog image was obvious. Weijing [16] applied the sparse representation algorithm to the image dehazing. By comparing the dark channel prior model, the new algorithm has a better dehazing effect and a higher fidelity. e third is the neural network dehazing algorithm based on machine learning [17][18][19][20]. is method uses multi-scale convolution operation to extract the feature map of the image, then uses the fog image and its corresponding fogless image as the training set to train different network structures, and finally uses the trained model to image dehazing. However, this method does not consider the degradation of the image, so the phenomenon of incomplete dehazing occurs.
Aiming at the above problems, this paper proposes an image dehazing algorithm based on sparse representation on the basis of analyzing and summarizing the characteristics of existing methods. Firstly, the image is converted from RGB space to HSI space, and the two-stage wavelet transform extract feature extraction of the I component is used. en, the K-SVD algorithm for dictionary training of the extracted features is used, the sparse features of the fogless image are learned, and the I-component of the fogless image is reconstructed. en the S-component is nonlinearly stretched to improve the image saturation. In this paper, the proposed algorithm is tested and a good dehazing effect is obtained.

General Idea of the Algorithm.
is paper proposes a single image defogging algorithm framework based on sparse representation as shown in Figure 1, which is mainly divided into two processes. One is the dictionary training process, first using image pairs (foggy images and their corresponding non-foggy images) to build a training set, then extracting the characteristics of the image pair I-component through wavelet transform, and using the K-SVD algorithm to sparsely combine a large number of image pairs dictionary training to get a dictionary of foggy images and non-foggy images. e other is the reconstruction process, first inputting the I-component of the image to be reconstructed, then extracting the features in the wavelet domain, and obtaining the sparse coefficient α through the orthogonal matching pursuit (OMP) algorithm. e sparse representation coefficient α gets the I-component of the reconstructed image. Compared with fogless image, the pixel value of S-component of foggy image is lower. In order to improve the image saturation, the nonlinear stretching function is used to stretch the image saturation. Finally, the processed HSI space image is converted into RGB color space to obtain the defogged image.

Feature Extraction in Image Wavelet Domain.
Wavelet transform is the development of Fourier transform. Because of its good time-frequency localization ability [21], it can extract the effective information of the image well, so it is widely used in the field of image processing. In this paper, Haar wavelet is used as an orthogonal function to perform two-layer decomposition of two-dimensional images. Among them, HL_1, LH_1, and HH_1 represent the horizontal, vertical, and diagonal high-frequency components after first-order wavelet decomposition; LL_2 represents the low-frequency component of second-order wavelet decomposition. HL_2, LH_2, and HH_2 represent the horizontal, vertical, and diagonal high-frequency components after the second-order wavelet decomposition, respectively.
In this paper, two-level wavelet transform is used to extract the features of the I-component of the image in the training set. Firstly, the image is first-level decomposed to obtain the feature maps of horizontal, vertical, and diagonal directions and low-frequency components, and then the low-frequency components are decomposed to obtain highfrequency and low-frequency feature maps. e dictionary training is performed through the extracted feature map to recover the I component. Figure 3 shows the extracted feature map after two-stage wavelet decomposition.

Sparse Representation.
Signals generally have sparse characteristics. e sparse representation of a signal represents the original signal through a series of basic signals in the dictionary or a linear combination of some atoms, which makes it easier to perform subsequent processing on the signal, such as encoding, compression, and amplification. For can be used to express [22]. A column in the dictionary is called an atom. Sparse representation is to use a linear combination of a small number of atoms in the dictionary to represent the signal, and its mathematical expression is [23] x � Dα. (1) Among them, α � [α 1 , α 2 , . . . , α L ] T ∈ R L represents the coefficient matrix. If the coefficient matrix is sparse, most of the elements in the matrix are zero, and there are only a few non-zero elements. e linear combination representation is a sparse representation.

Dictionary Training Based on K-SVD.
Dictionary training is the core of the sparse representation of the image. e quality of the dictionary after training will directly affect the effect of the sparse representation. e smaller the residual between the atoms and the signals in the dictionary, the more the structural features match, and the higher the quality of the reconstructed image. Since the images to be reconstructed are very different and the texture details of the images are quite different, the dictionaries obtained by different training methods will have different effects on the reconstruction of the images. Common training dictionary algorithms include MOD algorithm (Method of Optimal Directions, MOD), K-SVD algorithm (K-Singular Value Decomposition, K-SVD), and ODL algorithm (Online Directions Learning, ODL). e K-SVD algorithm uses alternate iteration to update the dictionary, which is more efficient than other algorithms. erefore, this papers uses the K-SVD algorithm for dictionary training. e training process is shown in Figure 4. e K-SVD algorithm was proposed by Aharon. is algorithm improves the decomposition efficiency by reducing the number of atoms in the dictionary; the atoms retained in the dictionary can also represent the original information.
e specific implementation process is as follows [24]: D means complete dictionary, and A means sparse coefficient moment: Assign initial values to the complete dictionary and sparse matrix, and then update a column of atom d j in D; the cost function is where E k is the error matrix, which represents the errors that other atoms than the k column have on the image. en, equation (3) can be expressed as For the above formula, if the singular value decomposition value of E k is directly used to update d j and α j , the updated α j value will not be sparse, so transform E j and α j , and only retain the non-zero values in α j : Select all columns in the error matrix E k that satisfy the set ω j to form E R j , and then perform singular value decomposition: e updated value is

Complexity 3
Among them, σ j 1 is the largest singular value of E R j , and μ j 1 and ] j 1 are the first column vectors of U j and V j , respectively. After traversing each column in the dictionary, the optimized dictionary is obtained. e process of K-SVD algorithm is shown in Table 1.

Image Defog Reconstruction.
Signal sparse representation also involves another key issue, namely, sparse coding. e so-called sparse coding refers to the process of solving the sparse coefficient α when the overcomplete dictionary D is known. e solution of this coefficient is an NP-hard problem. e common methods to solve the sparse coefficient include MP algorithm (Matching Pursuit algorithm, MP), OMP algorithm (Orthogonal Matching Pursuit algorithm, OMP), and SOMP algorithm (Simultaneous Orthogonal Matching Pursuit algorithm, SOMP). Atoms selected the OMP algorithm are orthogonal, which ensure that the signal and the selected atoms meet the orthogonal condition at each step of the iteration. Meanwhile, selected atoms cannot be selected again in the next iteration, which greatly reduces algorithm processing time and the number of atoms to decompose the original signal. In view of the above advantages, this paper uses the orthogonal matching pursuit algorithm [24] to solve the sparse coefficients.
For an image with fog, in the HSI color space, the fog is mainly distributed in the I-component. is paper reconstructed the I-component to improve the image brightness to achieve the purpose of fog removal. After dictionary training, a dictionary of the I-component of the foggy image and the I-component of the nonfoggy image is obtained, and the trained dictionary is used to reconstruct the foggy image I-component. e process is shown in Figure 5. First, feature extraction is performed on the I-component of the foggy image to obtain image feature blocks, and then OMP algorithm is used to obtain the sparse representation coefficient α in combination with the trained dictionary of the foggy image. e dictionary of the I-component of the fogfree image is brought into equation (1) to obtain the wavelet domain features of the reconstructed image I-component, and finally the inverse wavelet transform is used to obtain the reconstructed image I-component.
In order to improve the image saturation and make the image color more vivid, it is necessary to stretch the saturation. Due to uneven illumination at different locations of the same image, different regions have different saturations. In order to achieve different stretching effects under different lighting conditions, this paper uses a piecewise function to perform nonlinear stretch. Assuming that the In the formula, S ′ (x) represents the value of the Scomponent of the original image and S(x)represents the value of the S-component after stretching.
In the HSI color space, the H-component determines the essence of the color of an object. It is determined by the wavelength reflected by the object, and different wavelengths reflect different colors. For a color, the hue of the image before and after defogging is approximately invariant.

Experimental Platform and Data Set.
e experiment in this paper is carried out on Windows 7 operating system and MATLAB 2017a development platform, using the D-HAZY data set as the training set. e data set includes 80 RGB foggy and non-foggy images in indoor and outdoor scenes, some of which are shown in Figure 6. In order to improve the speed of the algorithm, the size of the image is standardized to 512 * 512.

Experiment and Result Analysis.
e five images in the data set were compared with literature [5], literature [6], literature [10], and the algorithm of this paper. e results are shown in Table 2.
It can be seen from Table 2 that, after [5] algorithm processing, the image contrast is improved, the color is brighter, and the fog removal is more thorough, but the fourth image is overenhanced, resulting in white light on the wall area. After the algorithm [6] processed the image, the whole image appeared blue, the contrast was reduced, the color was dark, and there was a color disorder. For example, the first and second images were severely distorted due to excessive enhancement. e image processed by the algorithm in [10] can achieve good results. e overall color of the image is natural, but part of the image is not completely dehazed. For example, in the first image, there is a layer of fog in the distant trees. After the algorithm is processed in this paper, the effect of defogging is better for different images, the brightness of the image is moderate, and it is full of layering. For images that are not well-processed by other algorithms, such as the second and third images, the algorithm does not appear dark or distorted.
In order to objectively compare several algorithms, this paper uses the blind contrast enhancement evaluation method, using three indicators e, r, σ, SSIM (structural similarity, SSIM), and PSNR (peak signal-to-noise ratio, PSNR) to compare the image defogging effect, where e is the ratio of the newly added visible edges of the restored image, r is the ratio of the average gradient, and σ is the percentage of saturated pixels (pure black or pure white) in the restored image, and their calculation method is as follows [25]: where n 0 represents the number of visible edges in the original image I(x), n r represents the number of visible edges in the defog image J(x), ϕ r is the set of visible edges in the fog-free image J(x), and P i is the i pixel of the visible   edges in the fog-free image. r i is the ratio of the gradient of the non-foggy image J(x) and the foggy image I(x) at P i , n s is the number of pure black or pure white pixels, and dim x and dim y represent the width and height of the image, respectively. In general, when e, r, SSIM, and PSNR are relatively large and the σ value is relatively small, it means that the image has good dehazing effect. e objective evaluation results of the defog quality of the five images in Table 2 are shown in Table 3. It can be seen that the percentage of saturated pixels of the image processed by the algorithm in this paper is significantly lower than that of the other three algorithms, which is not much different from the algorithm in [10]; the newly added visible edge ratio is slightly lower than the other three algorithms, and SSIM and PSNR values are higher than the other three algorithms. From the average point of view, the e and r values of the algorithm in this paper are slightly lower than those of the other three algorithms, but the σ values are significantly better than other algorithms. e PSNR value is significantly higher than the other three algorithms.

Conclusions
Based on the image sparse representation theory, this paper proposes a new image defogging algorithm. e algorithm uses two-stage wavelet transform to extract image features for the I-component of the image, uses the extracted features for dictionary training in the sparse domain, learns the sparse features of the fog-free image, reconstructs the I-component of the fog image, andapplies the nonlinear stretching method to increase image brightness.
Experimental results show that the algorithm can effectively improve the contrast of the image and improve the visual effect of the image. Compared with the common defogging algorithm, the percentage of saturated pixels, SSIM, and PSNR in the image is better than the comparison algorithm. Although the algorithm in this paper has achieved good results, it is relatively simple in feature extraction, resulting in partial image dehazing and color cast problems. e next step will be to study how to extract more useful features for dictionary training and improve the algorithm effect.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

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