Research of Single Image Rain Removal Algorithm Based on LBP-CGAN Rain Generation Method

Rain has an undesirable negative effect on the clarity of the collected images. In situation where images are captured in rain, it can lead to a loss of information and disability in reflecting real images of the situation. Consequently, rain has become an obstacle in outdoor scientific research studies. The reason why images captured in rain are difficult to process is due to the indistinguishable interactions between the background features and rain textures. Since current image data are only processed with the CNN (convolutional neural network) model, a trained neural network to remove rain and obtain clear images, the resulted images are either insufficient or excessive from standard results. In order to achieve more ideal results of clearer images, series of additional methods are taken place. Firstly, the LBP (local binary pattern) method is used to extract the texture features of rain in the image. Then, the CGAN (conditional generative adversarial network) model is constructed to generate rain datasets according to the extracted rain characteristics. Finally, the existing clear images, rain datasets generated by CGAN, as well as the images with rain are used for convolution operation to remove rain from the images, and the average value of PSNR (peak signal to noise ratio) can reach 38.79 by using this algorithm. Moreover, a large number of experiments are done and have proven that this joint processing method is able to successfully and effectively generate clear images despite the rain.


Introduction
With the continuous development of computer vision systems, more convenient methods are provided for outdoor exploration and target tracking. However, the outdoor weather is complex and changeable, especially the severe rain and snow weather. It seriously affects the image quality collected by the vision system, which can mislead the outdoor workers with inaccurate information [1,2]. erefore, it is necessary to solve the problem by removing rain from rainy images [3]. However, the rainy image background scene varies, and the density, shape, and direction of the rain are also diverse. So, the problem of removing rain from images has become an important challenge in the field of computer vision.
Presently, image denoising and rain removal have always been classic problems in the field of computer science. Rain images can also be regarded as a special image noise. e earliest research of the rain removal algorithm is to remove the rain in the video [4]. Due to the temporal and spatial relativity of the video sequence, image characteristics can be extracted from the video sequence of the same pixel at consecutive times to determine the position of the pixel affected by rain. erefore, it is relatively simple to remove the rain from a video. Starik and Werman [5] proposed the method of time-domain median filtering to remove rain from video images, which led to the development of research on image removal from rain. As for the rain removal research of a single image, because a single image does not have a video sequence that can be used, rich information brought by the dynamic changes of rain cannot be used, and different rainy images are due to the diversity of their backgrounds and the random distribution of rain. e complexity of the result of the rain removal research for a single image is greater. Moreover, Luo et al. [6] proposed a method based on sparse coding to remove rain from images. is method is relatively simple to implement, but the algorithm iteration time is longer. After the rain is removed, more rain lines are remained in the image. e resulted rain removal effect is poor, especially for heavy rain. Furthermore, Zhu et al. [7] proposed a joint two-layer optimization method for image rain removal. is method mainly uses the prior information of the image and then obtains the background image after rain removal through the iterative solution. Although this method is good to retain the details of the background information of the image, this method requires the user to intervene according to the picture to get the best rain.
With the continuous development of deep learning in vision applications, since deep learning can achieve complex nonlinear mapping between input data and output data, significant results have been achieved in the application of image denoising and rain removal. Zhang and Patel [8] proposed a DID-MDN (density-aware single image deraining using a multistream dense network) according to the density of rain in the image, which automatically judges the rainfall density information and removes it by the estimated rainfall density label. Although this method can remove raindrops well, it is easy to blur the background image during the rain removal process. Fu et al. [9] and Yang et al. [10] used the CNN to construct a rain-removing model based on the input clean images and rain images, which achieved a certain effect for rain-removing in specific scenes. However, this method only relies on the method of a single CNN, by changing the number of layers, connection mode, activation function, or loss function of the network to build a rain-removing model in the corresponding scenario. It lacks consideration of the dependency between the features of rain and the background. erefore, it is easy to cause insufficient rain removal of the image. ere are sparse streaks in the image after the rain removal, or the image is blurred after the rain removal. Isola et al. [11] proposed a conditional generative adversarial network model, which maps a rain image to a rainless image. is method is a general mapping and does not consider the dependence between rain features and the background. As a result, the generated image has a large pixel loss in detail, and this algorithm lacks flexibility in practical applications.
With the continuous development of deep learning in the visual application, considering the ability of the CGAN model to deal with complex problems, the CGAN model of image rain removal is built by referring to the CGAN model of other fields. References [12][13][14][15] mainly focus on the research of CGAN in the field of image processing, which is used to obtain better visual image super-resolution or improve image contrast. References [16,17] mainly focus on the research of the CGAN model in big data processing, which improves the prediction of complex problems or the construction of big data service framework through the CGAN model.
In this article, aiming at the lack of consideration of the relationship between rain features and background in current rain removal methods [18][19][20], we analyze the pixel features of the rain images, clean images, and rain streak images. Because of the obvious overlap in pixel statistics, it is difficult to separate them from pixel level by physical means. erefore, an LBP (local binary pattern) method is proposed to extract the texture features of rain in the image [21]. According to the extracted approximate rain features and combined with the background image, a CGAN (conditional generative adversarial network) is designed to automatically learn the relationship between rain features and the background to generate the rain datasets. Finally, the convolution operation is performed according to the rain image, the clean image, and the generated rain dataset to realize the rain removal of the rain images.

Analysis of Rain Removal and Design
Principle of Rain Removal Algorithm

Single Image Rain Feature Description.
In the research of image rain removal, the rain image (marked as O) is usually defined as the linear superposition of the rainless background image (marked as B) and the rain streak image (marked as R), which is O � B + R [22,23]. According to this principle, statistical analysis is performed on the pixel features of the background component and the rain component in the rain image, as shown in Figure 1. From the statistical results of pixel distribution, it can be seen that each image has an obvious overlap in pixels, which indicates that there is a mutual influence between rain and background. erefore, it is difficult to separate rain and background by using frequency-domain transform for feature comparison.
In the actual rain removal research of the rain images, due to the diversity of the background, a single deep learning network is used to generate the rain-removed images based on the input rain images. Due to the lack of consideration of the interaction between the background and the rain, it is easy to cause sparse rain lines or image distortion in the process of going to rain. e background features are difficult to grasp due to the diversity of image backgrounds. Relatively speaking, the features of rain are mainly reflected by the shape, size, and direction. It is easier to grasp the characteristics of rain.

Design Principle of Rain Removal Algorithm.
Based on the analysis of the rain removal problem in the rain image, considering the mutual influence between the rain and the background in rain images and the diversity of background features in different rain images, it is difficult to grasp the background features. However, the features of rain mainly include morphological information such as shape, direction, and size, as well as sensory information such as sparse and dense rain lines, which are relatively easy to grasp in different background images. So, the rain removal model is built, as shown in Figure 2.
First of all, the LBP method is introduced to extract the texture features of the rain from the rain images in this article. When the LBP method is used directly, the extracted rainwater texture features are susceptible to interference from other texture features in the background. erefore, the circle and rotation invariance theory is introduced, and the LBP algorithm is used to improve the accuracy of rain feature extraction. And then according to the features of the shape, size, and direction of the obtained rainwater, combined with the rain image, the GAN is designed to generate rain datasets. Considering the interaction between rain and the background, it affects the rain images. On this basis, the generator is trained from the perspective of conditional confrontation loss, and a gradient penalty factor is introduced to constrain the discriminator. e CGAN is reinforced to learn the mutual influence between the rain and the background to generate the rain feature dataset (marked as D). Finally, a rain removal model is constructed to realize the rain

Extraction Algorithm of Rain Texture Features Based on
LBP. e local color distribution and light intensity distribution will be affected in rain images due to rain interference. erefore, the extracted rain streaks feature will be fully utilized to achieve rain removal in rain images in this paper's rain removal solution. LBP (local binary pattern), an operator used to describe the local texture features of an image, has the advantages of rotation and grayscale invariant texture classification. LBP, first proposed by Ojala et al. [24,25], was used for texture feature extraction. Later, it was combined with the HOG feature classifier to improve the detection effect on some datasets [26,27]. LBP is used in this paper to extract rain features from rain images. e LBP algorithm combined with the extracted features is constrained by the rotation-invariant method so that the extracted image features are suitable for GAN to generate a reliable rain image dataset for rain removal of rain images. e LBP value can be used to reflect the texture information of the area, and the original LBP operator is defined in a 3 * 3 window. Take the central pixel of the window as the threshold and compare it with the gray values of the adjacent 8 pixels. If the surrounding pixel value is greater than the central pixel value, then the position of the pixel is marked as 1; otherwise, 0. In this way, after comparing 8 points in the 3 * 3 neighborhood, an 8-bit binary number can be generated (usually converted to a decimal number or LBP code, a total of 256 types), and thus the LBP value of the center pixel of the window is obtained as shown in Figure 3. e formula of the LBP algorithm is described as follows: where LBP(x c , y c ) is the pixel coordinate of the center point in the neighborhood of the 3 * 3 image, g i is the gray value of the No. i pixel in the neighborhood, g c is the gray value of the center point, and s(g i − g c ) is the symbolic function. If At present, the proposed LBP operators mainly include circular LBP, rotation-invariant LBP, and uniform mode LBP based on the principle of LBP. e abovementioned operators are used to extract the texture features of rainy images. e results are shown in Figure 4.
In order to ensure the accuracy of rain texture extraction, the LBP algorithm is to operate the original image without gray processing. As shown in Figure 4, it can be seen that the nonlinear variation of illumination causes the uneven distribution of the grayscale gradient of the image.
at is to say, compared with most areas of the image when a small part of the area changes drastically if only circular LBP, rotation-invariant LBP, or uniform LBP operators are adopted, it will highlight its limitations, i.e., easy to lose local details of the image. As such, this paper makes a binary improvement to the LBP algorithm (circular neighborhood enhancement and rotation invariance) to retain the detailed information with strong distinguishing ability.
(1) Feature description is carried out after extending the neighborhood of 3 * 3 feature points to 5 * 5 image areas. e 16 pixels in the center of the feature points, namely, LBP value, are used as the 16-dimensional feature description of the feature area, as shown in Figure 5. (2) e pixels used in the circular expansion of the neighborhood range are expanded from the original 8 to 16. e calculation formula is as follows: where LBP R (x c , y c ) is the coordinate of the sampling point after expansion and g(x i , y i ) is the gray value of the sampling point.
In this extraction algorithm of rain texture features, the symbols used in the LBP formula are shown in Table 1. (3) Based on the extended circle neighborhood, the rotation-invariant LBP is developed. As shown in Figure 6, the values obtained from the original LBP are converted into binary codes. ere will be 16 situations (including itself ) when it is circularly shifted. e smallest LBP value is taken, which is rotation invariant, because the rotation on the image is equivalent to the process of the above 16 kinds of shifts, and the 16 cases all correspond to the same value; that is, they have the rotation-invariant attribute. (4) e rain streaks feature image extracted by the rotation-invariant LBP algorithm after the circle neighborhood expansion is shown in Figure 7.  Figures 4 and 7, the nonrain texture extracted in Figure 7 is significantly reduced, and the accuracy of rainwater texture extraction is improved. erefore, the rain texture extracted by the improved LBP algorithm can play a better role in the later rainwater removal.

Construction of Rain Model Based on CGAN.
is section mainly describes a rain generation model building based on the characteristics of rain. When the existing data samples are used to train the image rain removal network, due to the lack of consideration of the rain details, the rain image is either insufficient or overfitting to remove the rain. erefore, to improve the performance of rain removal, modeling is carried out according to the actual rain streaks features, and then more feature data are generated to form a rain feature dataset, which can obtain samples with more diversity and arbitrariness. Given that GAN can learn the distribution of complex features [28], the GAN is used to estimate the distribution of rain to generate a larger rain sample dataset. e traditional GAN is mainly composed of generator G and discriminator D. e generator G is used to capture the data distribution, and the discriminator D is used to estimate the probability that a sample comes from real data instead of generated data. e rain feature of rain images is easily disturbed by environmental factors, so if the traditional GAN is directly used, to be honest, the environmental conditions are not taken into full consideration. erefore, when building a GAN, additional external information can be used as part of the input layer to build a CGAN (conditional generative adversarial network).
e CGAN architecture studied in this paper uses a fully convolutional network, U-Net, to replace the MLP fully connected network because U-Net ensures that the generated rain dataset is consistent with the underlying structure of the background image to the greatest extent. e traditional GAN mainly completes the mapping from the given    Mathematical Problems in Engineering random noise z to the generated image x. However, according to the analysis of this paper, the interaction between the rain feature and the background image will affect the image's rain removal effect. erefore, this paper takes the rain texture feature f and background image b extracted by LBP as additional input information so as to achieve the mapping of the given random noise z to the generated image x under the conditions f and b. e designed CGAN optimization process can be summarized as a two-person minimax game with conditional probability in which G and D train at the same time. It is to minimize the expectation of log(1 − D(G (z|(f, b)))) by fixing discriminator D and adjusting the parameters of G. And then, it is to maximize the expectation of log D (x|(f, b)) + log(1 − D (G(z|(f, b)))) by fixing generator G and adjusting the parameters of D. Its objective function is as follows: z|(f, b))))].

(3)
According to the input rain features, the generator generates real enough samples so that the discriminator considers them as real samples. Based on the constructed CGAN objective function, this paper builds the conditional adversarial loss function L G of the generator and the discriminator conditional adversarial loss function L D with gradient penalty factor, respectively, in order to ensure that the generated rain sample set can reflect the influence of background on rain detail characteristics. e traditional generator loss function of the GAN mainly considers the loss of mapping G: Z ⟶ x from the random noise z to the generated image x.
e CGAN constructed in this paper needs to ensure that the generated rain dataset can fully reflect the relationship between the background image and the rain noise. As such, this paper adopts the mapping relationship of G: (z|f,b) ⟶ x according to the input background image b and the extracted rain feature f and takes into account that the part of the generated image without rain is not affected by the generated raindrops. Starting from the two aspects of conditional mapping and content loss, the following conditional adversarial loss function is constructed to enrich the details of the generated image: z|(f, b))) + E z∼P z (z) ‖x − G (z|(f, b))‖ p .

(4)
Among them, −E z∼P z (z) D (G(z|(f, b))) is the conditional adversarial loss and E z∼P z (z) [‖x − G (z|(f, b))‖ p ] is the content loss of the generated image. e discriminator needs to score the input real sample and the generated sample, and its goal is to give a lower evaluation to the generated sample and a higher evaluation to the real one. As for the loss function of the discriminator, a gradient penalty factor is introduced into the input of the discriminator on the basis of the condition loss of the discriminator in order to avoid the influence of the premature loss of the discriminator on the generator. As a result, the loss function of the discriminator includes the real sample loss, the generated sample loss, and the gradient  Mathematical Problems in Engineering penalty loss term. And the loss function of the discriminator can be expressed as follows: z|(f, b))) − E x∼P data (x) D(x|(f, b)) Among them, the generated sample loss is −E z∼P z (z) D (G(z|(f, b))), the real sample loss is −E x∼P data (x) D(x|(f, b)), the gradient penalty loss term is x|(f, b))‖ p − 1] 2 , and c is the weight coefficient for balancing different loss functions. e symbols used in CGAN are shown in Table 2. In accordance with the above analysis of the CGAN conditional loss function, combined with the input and output of the generator and the discriminator and the corresponding conditional loss function, the CGAN rain dataset generation model is built under the U-Net framework as shown in Figure 8. e generator network structure is shown in Figure 8. Some low-level information is shared between the input and output images (this shared information helps to ensure the quality of the reconstructed image) to ensure that the underlying structure of the reconstructed image and the source image remains unchanged. In terms of generative adversarial networks, we adopt the encoder-decoder structure based on the U-Net [16] network. U-Net network adopts a skip connection to splice the low-level features of the encoder in the network with the high-level features obtained from the corresponding decoding layer and then serve as the input of the next layer. is method can ensure the consistency of the generated image and the underlying structure of the background to the greatest extent. In the first and last layers of the U-net network, batch normalization (BN) is not performed, while BN processing is added to other layers. LReLU (leaky-ReLU) activation function is used for downsampling, while the Tanh activation function is used for upsampling except for the last layer, and the ReLU activation function is used for other convolution layers.
e discriminator as shown in Figure 8 has two types of inputs, the image output by the generator and the real image. In Figure 8, the network structure of the discriminator is used to generate samples for input. At the same time, the conditional adversarial network is adopted and the rain image is taken as the condition. rough channel splicing, the condition is spliced with the reconstructed image output by the generator and then input into the discriminator together. e discriminator network will eventually output a scalar, representing the score of the input by the discriminator network. In the discriminator network structure of Figure 1, LReLU is adopted to the activation function of the convolution layer. Except for the first layer and the last layer, BN is used in other convolution layers. e rain data are used to train CGAN and the traditional GAN designed in this paper. e comparison of the loss curves between the generator and the discriminator in the training process is shown in Figure 9.

Joint Rain Removal Algorithm Based on CGAN and CNN
Convolution. At the moment, most rain removal algorithms mainly use a large number of rain images and clear image datasets to train the CNN for rain removal in the rain images, which have achieved remarkable results [29]. e CNN can learn potential rain images from the paired datasets to remove rain, but it neglects to consider the rain features in the rain images. As such, this paper adjusts the dataset input to the CNN. Eventually, combined with the principle of CNN, the image rain removal is realized in accordance with the reconstructed rain dataset, rain images, and clear images.
e general model of rain image is as follows: O � B + R. O is the collected rain image, B is the background image, and R is the rain streak. Given the traditional method, the density and shape of rain in R are not fully considered. At the same time, there is no local rain removal, resulting in excessive image smoothing. erefore, based on the rain feature dataset D and the rain streak R reconstructed by CGAN, this paper performs convolution operation and proposes a new model.
Each D j is the feature parameter of the No. j group of rain extracted by the generative adversarial network, and α is the harmonic parameter to simulate the mutual influence between the background and the rain. e value of α is adjusted according to the feedback of the operation result during the convolution operation, and the initialization value is 0.5. According to formula (6), the MAP (maximum a posteriori) estimation [30] is established for processing: K B (B), K D (D), and K r (R) in formula (7) represent the prior knowledge of B, S, and R, respectively, which are learned from the training data during the network training process and are implicitly embedded in the network. erefore, the joint rain removal model of CNN convolution operation in this paper is shown in Figure 10.
As shown in Figure 10, firstly, the convolution operation is performed by combining R and D, and the

Experimental Environment.
is experiment is based on Windows 10 operating system. e CGAN model is built under the framework of tensorflow platform of keras2.1.4. Tensorflow framework is a deep learning framework based on data flow graph computing developed by Google team in recent years. It has the advantages of high flexibility, strong portability, automatic differential solution, support for multiple programming languages, support for optimal performance, and so on. e experimental hardware parameters are shown in Table 3.

Image Rain Removal Algorithm Comparison Experiment
Verification. In order to verify the rain removal effect of the algorithm used in this paper compared with other algorithms, the algorithm in this paper is compared with the rain removal algorithm in literature [8], literature [10], and literature [11], respectively, such as DID-MDN, CNN, and Pix2Pix. In the experiment, the rain vehicle image dataset, the outdoor rain landscape image dataset, and the building rain image dataset (500 for each dataset) were used to analyze the different rain removal algorithms. e result of rain removal is shown in Figure 11. Figure 11(a) shows the original rainy images. Figure 11(b) shows the effect diagram of the DID-MDN rain removal algorithm. Figure 11(c) shows the effect of the CNN image rain removal algorithm. Figure 11(d) shows the effect diagram of the Pix2Pix graph rain removal algorithm. Figure 11(e) shows the effect diagram of the algorithm used in this paper. e results can be seen from Figure 11. e algorithm in Figure 11(b) does not remove rain well, and there are still a lot of residues. e algorithm in Figure 11(c) basically removes rain, but the details of the image are poorly restored and the texture is blurred. Although the algorithm in Figure 11(d) has a better rain removal effect, the edge information of the image is lost, and the color saturation of the image is not good. Figure 11(e) is the method used in this paper.
e rain removal effect is the best, and the basic chromaticity information of the original rainless image is retained.
e rain removal effect is better than other methods.

Image Quality Evaluation Based on PSNR to Remove Rain.
In order to evaluate the image quality of the image after the above four algorithms are processed to remove the rain, the PSNR image quality evaluation standard is used to evaluate the image quality of the reconstructed image obtained by the four algorithms [31]. Table 4 shows the PSNR value of the images generated after the rain vehicle image dataset, the outdoor rain landscape image dataset, and the building rain image dataset under different rain removal algorithms. e algorithm in this paper is compared with the rain removal algorithm in literature [8], literature [10], and literature [11], respectively, such as DID-MDN, CNN, and Pix2Pix. It can be seen that the evaluation index value of the algorithm in this paper is obviously better than the results of other algorithms for the three images after the rain, and it can restore the image visually. It can be seen from Table 4 that the average value of PSNR can reach 38.79 by using the algorithm of this paper.

Conclusions
Rain will greatly affect the clarity of the collected pictures so that the information provided by the pictures cannot reflect the situation of real things, which becomes an obstacle to the acquisition of image information for outdoor scientific research. is paper considers the interaction between rain texture and background, starting from the perspective of rain image characteristics. From the point of view of rain image features, the problem of removing rain from rainy images is studied. Firstly, the local binary pattern (LBP) method is used to extract the texture features of the rain from rain image, and the LBP algorithm is made better based on the circle and rotation invariance theory to improve the accuracy of the rain texture feature extraction. en, a CGAN was constructed based on the extracted rainwater features. A fully convolutional U-Net network was used to replace the MLP fully connected network when constructing CGAN.
is method can guarantee the generated rain dataset.
is method can ensure that the generated rain dataset is consistent with the underlying structure of the background image to the greatest extent and introduces the conditional adversarial loss, content loss, and gradient penalty loss to train the network. Finally, the rain feature dataset generated by CGAN and the existing clear image as well as the image with rain is used to perform convolution operation to remove the rain in the rainy image. It can be seen that the algorithm described in this article can improve the consideration of the mutual influence between the rain texture and the background according to the experimental comparison results and the PSNR image quality evaluation standard so that the image has better details, contrast, and saturation after the rain has been removed.

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