A Trilateral Weighted Sparse Coding Scheme for Real-World Image Denoising
Jun Xu, Lei Zhang, David Zhang
Introduction
Noise will be inevitably introduced in imaging systems and may severely damage the quality of acquired images. Removing noise from the acquired image is an essential step in photography and various computer vision tasks such as segmentation , HDR imaging , and recognition , etc. Image denoising aims to recover the clean image from its noisy observation , where is the corrupted noise. This problem has been extensively studied in literature, and numerous statistical image modeling and learning methods have been proposed in the past decades .
Most of the existing methods focus on additive white Gaussian noise (AWGN), and they can be categorized into dictionary learning based methods , nonlocal self-similarity based methods , sparsity based methods , low-rankness based methods , generative learning based methods , and discriminative learning based methods , etc. However, the realistic noise in real-world images captured by CCD or CMOS cameras is much more complex than AWGN , which can be signal dependent and vary with different cameras and camera settings (such as ISO, shutter speed, and aperture, etc.). In Fig. 1, we show a real-world noisy image from the Darmstadt Noise Dataset (DND) and a synthetic AWGN image from the Kodak PhotoCD Dataset (http://r0k.us/graphics/kodak/). We can see that the different local patches in real-world noisy image show different noise statistics, e.g., the patches in black and blue boxes show different noise levels although they are from the same white object. In contrast, all the patches from the synthetic AWGN image show homogeneous noise patterns. Besides, the realistic noise varies in different channels as well as different local patches . In Fig. 2, we show a real-world noisy image captured by a Nikon D800 camera with ISO=6400, its “Ground Truth” (please refer to Section 4.3), and their differences in full color image as well as in each channel. The overall noise standard deviations (stds) in Red, Green, and Blue channels are 5.8, 4.4, and 5.5, respectively. Besides, the realistic noise is inhomogeneous. For example, the stds of noise in the three boxes plotted in Fig. 2 (c) vary largely. Indeed, the noise in real-world noisy image is much more complex than AWGN noise. Though having shown promising performance on AWGN noise removal, many of the above mentioned methods will become much less effective when dealing with the complex realistic noise as shown in Fig. 2.
In the past decade, several denoising methods for real-world noisy images have been developed . Liu et al. proposed to estimate the noise via a “noise level function” and remove the noise for each channel of the real image. However, processing each channel separately would often achieve unsatisfactory performance and generate artifacts . The methods perform image denoising by concatenating the patches of RGB channels into a vector. However, the concatenation does not consider the different noise statistics among different channels. Besides, the method of models complex noise via mixture of Gaussian distribution, which is time-consuming due to the use of variational Bayesian inference techniques. The method of models the noise in a noisy image by a multivariate Gaussian and performs denoising by the Bayesian non-local means . The commercial software Neat Image estimates the global noise parameters from a flat region of the given noisy image and filters the noise accordingly. However, both the two methods ignore the local statistical property of the noise which is signal dependent and varies with different pixels. The method considers the different noise statistics in different channels, but ignores that the noise is signal dependent and has different levels in different local patches. By far, real-world image denoising is still a challenging problem in low level vision .
Sparse coding (SC) has been well studied in many computer vision and pattern recognition problems , including image denoising . In general, given an input signal and the dictionary of coding atoms, the SC model can be formulated as
In this paper, we propose to lift the SC model (1) to a robust denoiser for real-world noisy images by utilizing the channel-wise statistics and locally signal dependent property of the realistic noise, as demonstrated in Fig. 2. Specifically, we propose a trilateral weighted sparse coding (TWSC) scheme for real-world image denoising. Two weight matrices are introduced into the data-fidelity term of the SC model to characterize the realistic noise property, and another weight matrix is introduced into the regularization term to characterize the sparsity priors of natural images. We reformulate the proposed TWSC scheme into a linear equality-constrained optimization program, and solve it under the alternating direction method of multipliers (ADMM) framework. One step of our ADMM is to solve a Sylvester equation, whose unique solution is not always guaranteed. Hence, we provide theoretical analysis on the existence and uniqueness of the solution to the proposed TWSC scheme. Experiments on three datasets of real-world noisy images demonstrate that the proposed TWSC scheme achieves much better performance than the state-of-the-art denoising methods.
The Proposed Real-World Image Denoising Algorithm
Under the traditional sparse coding (SC) framework , the sparse coding matrix of over can be obtained by
where is the regularization parameter. Once is computed, the latent clean patch matrix can be estimated as . Though having achieved promising performance on additive white Gaussian noise (AWGN), the tranditional SC based denoising methods are very limited in dealing with realistic noise in real-world images captured by CCD or CMOS cameras. The reason is that the realistic noise is non-Gaussian, varies locally and across channels, which cannot be characterized well by the Frobenius norm in the SC model (2) .
Note that in this paper, we are not aiming at proposing a new dictionary learning scheme as did. Once obtained from SVD, the dictionary is fixed and not updated iteratively. Finally, the proposed trilateral weighted sparse coding (TWSC) model is formulated as:
Note that the parameter has been implicitly incorporated into the weight matrix .
2 The Setting of Weight Matrices
In this paper, we set the three weight matrices , , and as diagonal matrices and grant clear physical meanings to them. is a block diagonal matrix with three blocks, each of which has the same diagonal elements to describe the noise properties in the corresponding R, G, or B channel. Based on , the realistic noise in a local patch could be approximately modeled as Gaussian, and each diagonal element of is used to describe the noise variance in the corresponding patch . Generally speaking, is employed to regularize the row discrepancy of residual matrix (), while is employed to regularize the column discrepancy of (). For matrix , each diagonal element is set based on the sparsity priors on .
We determine the three weight matrices , , and by employing the Maximum A-Posterior (MAP) estimation technique:
The log-likelihood term is characterized by the statistics of noise. According to , it can be assumed that the noise is independently and identically distributed (i.i.d.) in each channel and each patch with Gaussian distribution. Denote by and the th column of the matrices and , respectively, and denote by the noise std of . We have
From the perspective of statistics , the set of can be viewed as a contingency table created by two variables and , and their relationship could be modeled by a log-linear model , where . Here we consider of equal importance and empirically set . The estimation of can be transferred to the estimation of and , which will be introduced in the experimental section (Section 4).
The sparsity prior is imposed on the coefficients matrix , we assume that each column of follows i.i.d. Laplacian distribution. Specifically, for each entry , which is the coding coefficient of the th patch over the th atom of dictionary , we assume that it follows distribution of , where is the th diagonal element of the singular value matrix in Eq. (3). Note that we set the scale factor of the distribution as the inverse of the th singular value . This is because the larger the singular value is, the more important the th atom (i.e., singular vector) in should be, and hence the distribution of the coding coefficients over this singular vector should have stronger regularization with weaker sparsity. The prior term in Eq. (5) becomes
Put (7) and (6) into (5) and consider the log-linear model , we have
and is the dimensional identity matrix. Note that the diagonal elements of and are determined by the noise standard deviations in the corresponding channels and patches, respectively. The stronger the noise in a channel and a patch, the less that channel and patch will contribute to the denoised output.
3 Model Optimization
Letting , we can transfer the weight matrix into the data-fidelity term of (4). Thus, the TWSC scheme (4) is reformulated as
Since the objective function is separable w.r.t. the two variables, the problem (11) can be solved under the alternating direction method of multipliers (ADMM) framework. The augmented Lagrangian function of (11) is:
where is the augmented Lagrangian multiplier and is the penalty parameter. We initialize the matrix variables , , and to be comfortable zero matrices and . Denote by () and the optimization variables and Lagrange multiplier at iteration (), respectively. By taking derivatives of the Lagrangian function w.r.t. and , and setting the derivatives to be zeros, we can alternatively update the variables as follows: (1) Update by fixing and :
This is a two-sided weighted least squares regression problem with the solution satisfying that
Eq. (14) is a standard Sylvester equation (SE) which has a unique solution if and only if , where denotes the spectrum, i.e., the set of eigenvalues, of the matrix . We can rewrite the SE (14) as
and the solution (if existed) can be obtained via , where is the inverse of the vec-operator . Detailed theoretical analysis on the existence of the unique solution is given in Section 3.1. (2) Update by fixing and :
This problem has a closed-form solution as
where is the soft-thresholding operator. (3) Update by fixing and :
(4) Update : , where .
The above alternative updating steps are repeated until the convergence condition is satisfied or the number of iterations exceeds a preset threshold . The ADMM algorithm converges when , , and are simultaneously satisfied, where is a small tolerance number. We summarize the updating procedures in Algorithm 1.
Convergence Analysis. The convergence of Algorithm 1 can be guaranteed since the overall objective function (11) is convex with a global optimal solution. In Fig. 3, we can see that the maximal values in , , approach to simultaneously in 50 iterations.
4 The Denoising Algorithm
Given a noisy color image, suppose that we have extracted local patches and their similar patches. Then noisy patch matrices can be formed to estimate the clean patch matrices . The patches in matrices are aggregated to form the denoised image . To obtain better denoising results, we perform the above denoising procedures for several (e.g., ) iterations. The proposed TWSC scheme based real-world image denoising algorithm is summarized in Algorithm 2.
Existence and Faster Solution of Sylvester Equation
The solution of the Sylvester equation (SE) (14) does not always exist, though the solution is unique if it exists. Besides, solving SE (14) is usually computationally expensive in high dimensional cases. In this section, we provide a sufficient condition to guarantee the existence of the solution to SE (14), as well as a faster solution of (14) to save the computational cost of Algorithms 1 and 2.
Before we prove the existence of unique solution of SE (14), we first introduce the following theorem.
The proof of Theorem 3.1 can be found in the supplementary file. Then we have the following corollary.
Since in (14) are both symmetric and positive definite matrices, according to Theorem 3.1, the SE (14) has a unique solution.
2 Faster Solution
The solution of the SE (14) is typically obtained by the Bartels-Stewart algorithm . This algorithm firstly employs a QR factorization , implemented via Gram-Schmidt process, to decompose the matrices and into Schur forms, and then solves the obtained triangular system by the back-substitution method . However, since the matrices and are of dimensions, it is computationally expensive () to calculate their QR factorization to obtain the Schur forms. By exploiting the specific properties of our problem, we provide a faster while exact solution for the SE (14).
Since the matrices in (14) are symmetric and positive definite, the matrix can be eigen-decomposed as , with computational cost of . Left multiply both sides of the SE (14) by , we can get . This can be viewed as an SE w.r.t. the matrix , with a unique solution . Since the matrix is diagonal and positive definite, its inverse can be calculated on each diagonal element of . The computational cost for this step is . Finally, the solution can be obtained via . By this way, the complexity for solving the SE (14) is reduced from to , which is a huge computational saving.
Experiments
To validate the effectiveness of our proposed TWSC scheme, we apply it to both synthetic additive white Gaussian noise (AWGN) corrupted images and real-world noisy images captured by CCD or CMOS cameras. To better demonstrate the roles of the three weight matrices in our model, we compare with a baseline method, in which the weight matrices are set as comfortable identity matrices, while the matrix is set as in (8). We call this baseline method the Weighted Sparse Coding (WSC).
Noise Level Estimation. For most image denoising algorithms, the standard deviation (std) of noise should be given as a parameter. In this work, we provide an exploratory approach to solve this problem. Specifically, the noise std of channel can be estimated by some noise estimation methods . In Algorithm 2, the noise std for the th patch of can be initialized as
and updated in the following iterations as
where is the th column in the patch matrix , and is the th patch recovered in previous iteration (please refer to Section 2.4).
Implementation Details. We empirically set the parameter and . The maximum number of iteration is set as . The window size for similar patch searching is set as . For parameters , , , we set , , for ; , , for ; , , for ; , , for . All parameters are fixed in our experiments. We will release the code with the publication of this work.
2 Results on AWGN Noise Removal
We first compare the proposed TWSC scheme with the leading AWGN denoising methods such as BM3D-SAPCA (which usually performs better than BM3D ), LSSC , NCSR , WNNM , TNRD , and DnCNN on 20 grayscale images commonly used in . Note that TNRD and DnCNN are both discriminative learning based methods, and we use the models trained originally by the authors. Each noisy image is generated by adding the AWGN noise to the clean image, while the std of the noise is set as in this paper. Note that in this experiment we set the weight matrix since the input images are grayscale.
The averaged PSNR and SSIM results are listed in Table 1. One can see that the proposed TWSC achieves comparable performance with WNNM, TNRD and DnCNN in most cases. It should be noted that TNRD and DnCNN are trained on clean and synthetic noisy image pairs, while TWSC only utilizes the tested noisy image. Besides, one can see that the proposed TWSC works much better than the baseline method WSC, which proves that the weight matrix can characterize better the noise statistics in local image patches. Due to limited space, we leave the visual comparisons of different methods in the supplementary file.
3 Results on Realistic Noise Removal
We evaluate the proposed TWSC scheme on three publicly available real-world noisy image datasets .
Dataset 1 is provided in , which includes around 20 real-world noisy images collected under uncontrolled environment. Since there is no “ground truth” of the noisy images, we only compare the visual quality of the denoised images by different methods.
Dataset 2 is provided in , which includes noisy images of 11 static scenes captured by Canon 5D Mark 3, Nikon D600, and Nikon D800 cameras. The real-world noisy images were collected under controlled indoor environment. Each scene was shot 500 times under the same camera and camera setting. The mean image of the 500 shots is roughly taken as the “ground truth”, with which the PSNR and SSIM can be computed. 15 images of size were cropped to evaluate different denoising methods. Recently, some other datasets such as are also constructed by employing the strategies of this dataset.
Dataset 3 is called the Darmstadt Noise Dataset (DND) , which includes 50 different pairs of images of the same scenes captured by Sony A7R, Olympus E-M10, Sony RX100 IV, and Huawei Nexus 6P. The real-world noisy images are collected under higher ISO values with shorter exposure time, while the “ground truth” images are captured under lower ISO values with adjusted longer exposure times. Since the captured images are of megapixel-size, the authors cropped 20 bounding boxes of pixels from each image in the dataset, yielding 1000 test crops in total. However, the “ground truth” images are not open access, and we can only submit the denoising results to the authors’ Project Website and get the PSNR and SSIM results.
Comparison Methods. We compare the proposed TWSC method with CBM3D , TNRD , DnCNN , the commercial software Neat Image (NI) , the state-of-the-art real image denoising methods “Noise Clinic” (NC) , CC , and MCWNNM . We also compare with the baseline method WSC described in Section 4 as a baseline. The methods of CBM3D and DnCNN can directly deal with color images, and the input noise std is set by Eq. (20). For TNRD, MCWNNM, and TWSC, we use to estimate the noise std () for each channel. For blind mode DnCNN, we use its color version provided by the authors and there is no need to estimate the noise std. Since TNRD is designed for grayscale images, we applied them to each channel of real-world noisy images. TNRD achieves its best results when setting the noise std of the trained models at on these datasets.
Results on Dataset 1. Fig. 4 shows the denoised images of “Dog” (the method CC is not compared since its testing code is not available). One can see that CBM3D, TNRD, DnCNN, NI and NC generate some noise-caused color artifacts across the whole image, while MCWNNM and WSC tend to over-smooth a little the image. The proposed TWSC removes more clearly the noise without over-smoothing much the image details. These results demonstrate that the methods designed for AWGN are not effective for realistic noise removal. Though NC and NI methods are specifically developed for real-world noisy images, their performance is not satisfactory. In comparison, the proposed TWSC works much better in removing the noise while maintaining the details (see the zoom-in window in “Dog”) than the other competing methods. More visual comparisons can be found in the supplementary file.
Results on Dataset 2. The average PSNR and SSIM results on the 15 cropped images by competing methods are listed in Table 2. One can see that the proposed TWSC is much better than other competing methods, including the baseline method WSC and the recently proposed CC, MCWNNM. Fig. 5 shows the denoised images of a scene captured by Nikon D800 at ISO = 6400. One can see that the proposed TWSC method results in not only higher PSNR and SSIM measures, but also much better visual quality than other methods. Due to limited space, we do not show the results of baseline method WSC in visual quality comparison. More visual comparisons can be found in the supplementary file.
Results on Dataset 3. In Table 3, we list the average PSNR and SSIM results of the competing methods on the 1000 cropped images in the DND dataset . We can see again that the proposed TWSC achieves much better performance than the other competing methods. Note that the “ground truth” images of this dataset have not been published, but one can submit the denoised images to the project website and get the PSNR and SSIM results. More results can be found in the website of the DND dataset (https://noise.visinf.tu-darmstadt.de/benchmark/#results_srgb). Fig. 6 shows the denoised images of a scene captured by a Nexus 6P camera. One can still see that the proposed TWSC method results better visual quality than the other denoising methods. More visual comparisons can be found in the supplementary file.
Comparison on Speed. We compare the average computational time (second) of different methods (except CC) to process one image on the DND Dataset . The results are shown in Table 4. All experiments are run under the Matlab2014b environment on a machine with Intel(R) Core(TM) i7-5930K CPU of 3.5GHz and 32GB RAM. The fastest speed is highlighted in bold. One can see that Neat Image (NI) is the fastest and it spends about 1.1 second to process an image, while the proposed TWSC needs about 195 seconds. Noted that Neat Image is a highly-optimized software with parallelization, CBM3D, TNRD, and NC are implemented with compiled C++ mex-function and with parallelization, while DnCNN, MCWNNM, and the proposed WSC and TWSC are implemented purely in Matlab.
4 Visualization of The Weight Matrices
The three diagonal weight matrices in the proposed TWSC model (4) have clear physical meanings, and it is interesting to analyze how the matrices actually relate to the input image by visualizing the resulting matrices. To this end, we applied TWSC to the real-world (estimated noise stds of R/G/B: 11.4/14.8/18.4) and synthetic AWGN (std of all channels: 25) noisy images shown in Fig. 1. The final diagonal weight matrices for two typical patch matrices () from the two images are visualized in Fig. 7. One can see that the matrix reflects well the noise levels in the images. Though matrix is initialized as an identity matrix, it is changed in iterations since noise in different patches are removed differently. For real-world noisy images, the noise levels of different patches in are different, hence the elements of vary a lot. In contrast, the noise levels of patches in the synthetic noisy image are similar, thus the elements of are similar. The weight matrix is basically determined by the patch structure but not noise, and we do not plot it here.
Conclusion
The realistic noise in real-world noisy images captured by CCD or CMOS cameras is very complex due to the various factors in digital camera pipelines, making the real-world image denoising problem much more challenging than additive white Gaussian noise removal. We proposed a novel trilateral weighted sparse coding (TWSC) scheme to exploit the noise properties across different channels and local patches. Specifically, we introduced two weight matrices into the data-fidelity term of the traditional sparse coding model to adaptively characterize the noise statistics in each patch of each channel, and another weight matrix into the regularization term to better exploit sparsity priors of natural images. The proposed TWSC scheme was solved under the ADMM framework and the solution to the Sylvester equation is guaranteed. Experiments demonstrated the superior performance of TWSC over existing state-of-the-art denoising methods, including those methods designed for realistic noise in real-world noisy images.