1 Introduction

The process of anisotropic diffusion based on partial differential equations (PDE) has been widely used for many years by the researchers since the early work of Perona and Malik [17] which is quite effective for smoothing of the images with edge preservation. The smoothing in the diffusion process is controlled by a gradient dependent diffusion coefficient function which tends to become high in highly homogeneous areas and low in edge abundant areas. This helps in smoothing of the homogeneous portions of the image and the preservation of high gradient edges. The method [17] works well in the images affected by Gaussian noise. However, image quality is mostly compromised by malfunctioning pixels caused by camera sensor’s defects, analog-to-digital converter errors, bit errors in transmission etc. These malfunctioning pixels may take any random value within the dynamic pixel luminance range. These defects are generally termed as random valued impulsive noise (RVIN) [13]. If we denote the dynamic pixel luminance range of an observed image f as [p min, p max] i.e. p min ≤ f ij  ≤ p max where (i, j) is the pixel position in f. Then, the RVIN model is defined as follows [13]:

$$ f_{ij}=\left\{ \begin{array}{ll} p_{ij}, & \hbox{with probability \emph{r};} \\ f_{ij}, & \hbox{with probability \emph{1-r}.} \end{array} \right. $$

where p ij is the gray level of the noisy pixel at location (i, j) which takes the random value from [p min, p max].

Many researchers have suggested different efficient algorithms based on spatial filtering [5, 8, 9, 11] for reduction of RVIN with preservation of image details. In the earlier work of image de-noising, median filters were particularly effective for the removal of impulsive noise but it tends to blur the inter-region edges. An adaptive center weighted median filter has been proposed by Chen et al. [5] where a switching median filter is utilized in the detection process for the separation of uncorrupted pixels from the corrupted ones. Chao [8] extends this work by partitioning the observational vector space of the image into distinct blocks and applied the center weighted median filter to each block. The pixel-wise absolute deviations from the median in order to efficiently separates the noisy pixels from the image details was developed by Crnojevic et al. [9]. Another method for removal of RVIN is directional weighted median filter [11] which is based on the differences between the current pixel and its neighbors aligned in four main directions. It gives the information of the four directions to weight the pixels in the window in order to preserve the details and removing the noisy pixels. Smolka and Chydzinski [19] and Smolka [20] proposed a novel technique of impulse reduction in color images using the Fisher’s linear discriminant aggregated distances [19] assigned to each of the pixels from the filtering window. A fast two phase approach to reduce blur and impulsive noise was presented by Cai et al. [2] in which median type filter is used in first phase to detect the corrupted pixels and then edge preserving restoration in applied in next phase. All the above methods remove the noisy pixels effectively but still blurring of edges degrades the quality of the image.

Some patch based non-local means block matching methods [7, 10, 14] and L1–L1 minimization methods [23, 26] have also been efficiently applied for removal of mixed impulse Gaussian noise. Recently, a moment based non-local means algorithm is developed by Ji et al. [14] in which moment computation is carried out on small local windows of each pixel to obtain the local structure information of the image. A novel block matching method based on sparse representation in transform domain is introduced in [7] which exhibits considerable performance in the removal of mixed impulse Gaussian noise. Very recently, a patch based impulsive noise removal with restoration of textured areas is proposed by Delon and Desolneux [10]. An adaptive non-local means algorithm based on pixel region growing and merging was developed by Zheng et al. [29] for reduction of salt and pepper noise (fixed valued impulsive noise). Our initial research [15] was based on partial unsharp masking [13] and conservative smoothing [13] which was limited upto the de-noising of images affected by low level salt and pepper noise. However, the noise reduction process near edge boundaries in all the above methods has not been addressed properly.

It has been observed that most of the PDE based anisotropic diffusion methods are developed for the removal of Gaussian noise and edge preservation. However, in the presence of RVIN, the noisy pixels gets amplified because of the functional characteristic of anisotropic diffusion and appear as sharp isolated edge pixels in the image. A latest research on the removal of RVIN has been presented by Wu and Tang [25] which shows the effective reduction of RVIN but removal of high level impulsive noise without blurring of edges is still a critical problem. For robust RVIN detection and correction along with edge preservation, we investigated the properties of diffusion coefficient function in anisotropic diffusion and developed a fuzzy based diffusion coefficient function [16] but the preservation of edges was not satisfactory. In this paper, we focus on the detection and removal of impulsive noise with the help of spatial differences between the noisy pixel and its surrounding neighbors in an image window using Laplacian based second order differences (SOD) [13]. The modified anisotropic diffusion is then applied on the noise filtered image to restore the blurred edges destroyed during noise filtering operation. The properties of diffusion coefficient function in the proposed anisotropic diffusion has been adjusted in accordance with the input impulsive noise filtered image. The proposed modified diffusion scheme incorporates an adaptive thresholding function in diffusion coefficient function and made it to vary in accordance with the local gray level variance of the input noise filtered image. The results indicates that the prior removal of impulsive noise before the application of diffusion process is advantageous over the direct application of diffusion for removing the impulsive noise.

The rest of the paper is organized as follows: In Section 2, a brief review of various anisotropic diffusion methods have been presented. In Section 3, the proposed diffusion method has been described. Experimental results and discussions are made in Section 4 and finally, the paper is concluded in Section 5.

2 Related anisotropic diffusion methods

The process of anisotropic diffusion has been applied in many image applications for removal of noise with edge preservation. In the initial work, Witkin [24] has demonstrated that using a linear heat equation, the entire image can be de-noised but it tends to smooth the entire image and blurs some prominent edges. Perona and Malik introduced an image dependent continuous anisotropic diffusion equation [17] for edge preserving smoothing, which is stated as below:

$$ \frac{\partial f_{t}(x,y)}{\partial t}=Div[d_{t}(x,y).\nabla f_{t}(x,y)] $$
(1)

where f t (x, y) is the image at time t; Div is the divergence operator; \(\nabla f_{t}(x,y)\) is the gradient of the image and d t (x, y) denotes the diffusion coefficient function. If diffusion coefficient function in (1) is kept constant, then the anisotropic diffusion will change to isotropic diffusion which is equivalent to a Gaussian smoothing filter as used by Witkin [24]. Perona and Malik used the idea of anisotropic diffusion by choosing diffusion coefficient function in different diffusion iterations so that smoothing across the inter-region edges can be minimized. This was achieved by varying diffusion coefficient function as a function of \(\nabla f_{t}(x,y)\) which speed up the diffusion in low gradient regions and stops the diffusion in high gradient regions. The diffusion coefficient function used by Perona and Malik [17] is as follows:

$$ d_{t}(x,y)=d(|\nabla f|)=\frac{1}{1+(\frac{|\nabla f|}{k})^{2}} $$
(2)

where k is an edge threshold parameter which is tuned to a fixed value for a particular application. Here, \(|\nabla f|\) is taken in place of \(\nabla f_{t}(x,y)\) for simplification in representation.

The diffusion coefficient function introduced in (2) is sensitive to high gradient impulse noise. Catte et al. [3] proposed an improved diffusion coefficient function by calculating the gradient after convolving the image with a Gaussian G σ of standard deviation σ as given below:

$$ \frac{\partial f_{t}}{\partial t}=Div[d(|\nabla (G_{\sigma}\ast f)|).\nabla f] $$
(3)

You and Kaveh [27] revised the diffusion coefficient function by using the Laplacian image \(\triangle f\) instead of the gradient image \(\nabla f\) and proposed the fourth-order PDE model for edge detection as defined in (4)

$$ d(|\triangle f|)=\frac{1}{1+(\frac{|\triangle f|}{k})^{2}} $$
(4)

A statistical and time interpretation of anisotropic diffusion was developed by Chen et al. [6] and proposed new edge-stopping diffusion coefficient function as follows:

$$ \frac{\partial f_{t}(x,y)}{\partial t}= v(t)Div[\frac{\nabla (G_{\sigma}\ast f)}{|\nabla (G_{\sigma}\ast f)|}]-u((G_{\sigma}\ast f)-f) $$
(5)

where v(t) is a function of time and u is a constant. Tschumperle and Deriche [21] redefined the formulations of anisotropic diffusion and proposed a unified expression for vector valued images with the help of Hessian matrices [13, 21].

An improved anisotropic diffusion was developed by Fang et al. [12] which consists of two independent terms for smoothing of noisy background and sharpening of edge features. Yu et al. [28] presented a kernal anisotropic diffusion incorporating a kernalized gradient operator \(|\nabla [\Phi f]|\) in place of \(|\nabla f|\) in diffusion coefficient function in order to apply the diffusion process in small specified window. A local gray level variance controlled diffusion coefficient function for forward and backward diffusion in order to preserve low gray level details was developed by Wang et al. [22]. Some similar approach was proposed by Chao and Tsai [4] where the local gray level variance at each pixel location in conjunction with gradient is used to enhance low gray level details.

The principle objective of all the above methods is to smooth the noisy background and preserve the edges. Therefore, these methods are not sufficient for impulsive noise reduction along with edge preservation. Very recently, a PDE based new diffusion method has been developed by Wu and Tang [25] where the diffusion coefficient function has been redefined as a controlling function based on a classification of image into three categories edge pixels, noisy pixels and interior pixels (ENI). The diffusion coefficient function exhibits selective diffusion process at edge pixels, noisy pixels and interior pixels whose formulation is given in (6).

$$ d_{t}(ENI_{p}(u,w,T))=\frac{1}{2}+\frac{1}{2}cos\left(\frac{2\pi ENI_{p}(u,w,T)}{N}\right) $$
(6)

where p, u, w, T and N are test pixel, gray level intensity, window size, threshold and total number of pixels in the window excluding center pixel respectively. The method efficiently eliminates the RVIN but it tends to leave the noisy pixels when noise density is high.

3 Proposed diffusion method

In the proposed method, the modified diffusion scheme is applied on the noise filtered image for restoration of edges and reducing the effect of blurring. The noise filtered image is obtained by correcting the impulse noisy pixels initially using Laplacian based second order pixel differences. The details are explained below:

3.1 Pre-reduction of impulse noise

Laplacian operator is considered to be more sensitive to the isolated noisy point as compared to the gradient. Therefore, we exploited Laplacian based second order difference (SOD) [13] on the pixels in a test window for reducing the impulsive noisy pixels. We observed that the difference between the noisy pixel value and its neighboring pixel value is quite different than that of the two uncorrupted pixel values. We employed this scheme of impulse detection in a 3 × 3 window M with center pixel c(i, j) and its surrounding neighbor pixels as given below:

$$ M=[c(i+u,j+v)] $$
(7)

where − 1 ≤ u,v ≤ 1. Laplacian based SODs are computed to detect the noisy pixel aligned in four directions (horizontal, vertical, diagonal and back diagonal) of M as shown in Fig. 1 which are as follows:

$$ s_{l}=|c(i+m,j+n)+c(i-m,j-n)-2c(i,j)| $$
(8)

where (l, m, n) = [(1, − 1, 0), (2, 0, 1), (3, 1, 1), (4, − 1, 1)]. The minimum and maximum of these four SODs are then used for the detection of isolated noisy pixel as follows:

$$ s_{\rm min}=min[{s_{l}: 1\leq l\leq 4}] $$
(9)
$$ s_{\rm max}=max[{s_{l}: 1\leq l\leq 4}] $$
(10)

Following three decisions are made based on the values of s min, s max and a predefined threshold T h which is equal to 90 % of the highest absolute difference of the two pixels of the image:

  • if s max < T h , i.e., all the SODs are small and equal to each other, then the test pixel c(i,j) is a noise free pixel;

  • if s min < T h  < s max, i.e., all the SODs are the mixture of distinct small and large values, then the test pixel c(i, j) lies on an edge and considered as a noise free pixel;

  • if s min > T h , i.e., all the SODs are large and equal to each other, then the test pixel c(i, j) represents isolated noisy pixel which needs to be replaced.

The flow chart in Fig. 2 shows the above impulse noise detection method which is applied to each pixel. The noisy pixel value detected above is then replaced by a new appropriate intensity value which should have its gray level nearer to the four directional neighbors. Considering D l (i, j) be the gray level difference between the two neighboring pixels of c(i, j) in the lth direction as given below:

$$ D_{l}(i,j)=|c(i+m,j+n)+c(i-m,j-n)| $$
(11)

The closeness among the four neighboring pixels can be justified by the four corresponding values of D l . Considering S l be the direction of minimum D l . This indicates that the pixels aligned along S l are nearly equal to each other and closer to the center pixel value and thus assigned with some different weight r. During the impulse detection process, any test pixel c(i, j) which is detected to be noisy is replaced by r(i, j) as follows:

$$ r(i,j)=median[M,r\diamond c_{s_{l}}] $$
(12)

where \(c_{s_{l}}\) denotes the two neighboring pixels of c(i, j) along the direction S l and symbol ⋄ is used as a repetition operator [1].

Fig. 1
figure 1

SOPDs aligned in four directions of center pixel c(i, j) and its surrounding neighbor pixels in a 3 × 3 window M

Fig. 2
figure 2

Flow chart showing the SOD operation for impulse noise detection

3.2 Edge preservation using modified anisotropic diffusion

The image initially filtered by SOD operation is a noise reduced image but it also tends to blur the sharp edge boundaries. This problem arises during SOD operation because of the change in gray level value of the pixels located on an edge boundary. To recover the edge boundaries, we have modified the anisotropic diffusion and employed for image deblurring as well as edge preservation. It is observed that the local gray level variance of the image gives the better information of the local gray level intensities than the gradient magnitudes in the regions of blurred edge boundaries [4, 22]. This encourages to utilize local gray level variance at each pixel in conjunction with local gradient in diffusion coefficient function to fulfil the requirement of restoring the blurred edge boundaries of the image damaged by the impulse noise reduction. The flowchart in Fig. 3 shows the adaptivity of modified diffusion scheme based on local gray level variance at each pixel. Let f(x, y) denote the gray level of a pixel at coordinate (x, y) and M × N be the size of the neighborhood centered on (x, y). The local gray level variance in this neighborhood can be given as:

$$ \sigma^{2}(x,y)=\frac{1}{MN}\sum\limits_{x=0}^{M-1} \sum\limits_{y=0}^{N-1} [f(x,y)-m_{f}]^{2} $$
(13)

where m f is the mean of gray levels in M × N neighborhood window. We need to restrict the smoothing process through the edge threshold parameter k in diffusion coefficient function of (2). In this work, the constant edge threshold parameter k in (2) has been formulated as a function of local gray level variance of image to make the threshold function adaptive and defined as follows:

$$ k(x,y)=k(\sigma^{2}(x,y))\approx \frac{k_{0}}{\sigma^{2}(x,y)} $$
(14)

where k(x, y) is inversely proportional to the local gray level variance σ 2(x, y) with k 0 as a positive constant.

Fig. 3
figure 3

Flow chart showing the diffusion operation for edge preservation

Through experimentation, we have found that if \(\sigma^{2}(x,y)> k_{0}\), then the pixel at (x, y) is a point needs to be preserved. Otherwise, if \(\sigma^{2}(x,y)< k_{0}\), then the pixel (x, y) corresponds to low gray level homogeneous region of the image and needs to be smoothed. Based on the above statistical measure at each pixel, the values of function k(x, y) obtained adaptively are summarized in (15).

$$ k(x,y)=\left\{\begin{array}{cc} high & \mbox{when $\sigma^{2}(x,y)<k_{0}$}\\ medium & \mbox{when $\sigma^{2}(x,y)\approx k_{0}$}\\ low & \mbox{when $\sigma^{2}(x,y)>k_{0}$} \end{array} \right. $$
(15)

Therefore, the function k(x, y) which fulfils the above criteria can be defined as:

$$ k(x,y)=k(k_{0}, \sigma^{2}(x,y))=\frac{1}{1+e^{-(k_{0}-\sigma^{2}(x,y))^{2}}} $$
(16)

The function k(x, y) has been chosen in such a way that it is monotonically decreasing function for σ 2(x, y) and monotonically increasing function for the constant k 0 so that the adaptive variational scheme shown in (15) can be fulfilled. The local neighborhood size M × N for the calculation of local gray level variance σ 2(x, y) should be small in order to preserve the details. In this work, we selected the neighborhood size as 3 × 3.

The above stated variation of k(x, y) in accordance with local gray level variance σ 2(x, y) is considered as an adaptive threshold in anisotropic diffusion and the corresponding diffusion coefficient function at iteration t is defined as:

$$ d_{t}(x,y)=\frac{1}{1+(\frac{|\nabla f|}{k(x,y)})^{2}} $$
(17)

On substituting the adaptive thresholding function k(x, y) in the above equation, the modified diffusion coefficient function can be written as follows:

$$ d(x,y)=d(\nabla f(x,y), k(x,y))=\frac{1}{1+|\nabla f(x,y)|^{2}[1+e^{-(k_{0}-\sigma^{2}(x,y))^{2}}]^{2}} $$
(18)

This shows that the proposed diffusion coefficient function incorporates both local gradient and local gray level variance at each pixel in order to fulfil the requirement of restoring the blurred edge boundaries damaged by the impulse noise reduction.

Let us consider f dt (x, y) be the de-noised image by SOD operation at iteration t. If we replace f t (x, y) in (1) by f dt (x, y), then, \(|\nabla f|\) and k(x, y) in (17) will be replaced by \(|\nabla f_{dt}|\) and k dt (x, y) respectively. Now, the modified diffusion coefficient function for SOD filtered de-noised image can be written as:

$$ d_{dt}(x,y)=\frac{1}{1+(\frac{|\nabla f_{dt}|}{k_{dt}(x,y)})^{2}} $$
(19)

After substituting the proposed diffusion coefficient function d dt (x, y) in (1), the modified anisotropic diffusion equation for SOD filtered de-noised image at iteration t can discretely be implemented by using Laplacian operator [13] as shown below:

$$ f_{d(t+1)}(x,y)=f_{dt}(x,y)+\frac{1}{4}\sum\limits_{i=1}^{4}\left[d\left(\frac{|\nabla f_{dt}^{i}(x,y)|}{k_{dt}(x,y)}\right).\nabla f_{dt}^{i}(x,y)\right] $$
(20)

where i = 1, 2, 3 and 4 represents the four directions of four neighbors at location (x, y) respectively for calculation of \(\nabla f_{dt}^{i}(x,y)\).

3.2.1 Interpretation of k(x, y) and k 0

The proposed diffusion scheme in this study is dependent on the value of threshold function k(x, y) and constant k 0 respectively. In (15), the value of k(x, y) varies according to local gray level variance at each pixel of the image. If, a large k 0 is used when the local neighborhood area has small gray level variance, the value of k(x, y) increases which speeds up the smoothing effect. On the contrary, in the area of large gray-level variance, the value of k(x, y) decreases for a small value of k 0 which stops the diffusion process. Conclusively, the high gray level edges and fine details are both restored. The position where gray level variance is constant over the entire image, then, k(x, y) will become constant value and in such condition proposed diffusion equation will behave like normal Perona-Malik diffusion equation [17]. The curve in upper graph of Fig. 4 shows the variation of diffusion coefficient function for Perona and Mali [17] and the proposed modified diffusion with respect to the different values of local gray level variance at a fixed gradient magnitude. It is evident from plot of Fig. 4 that the diffusion coefficient function in Perona and Malik model [17] becomes constant while in the proposed diffusion scheme, the diffusion coefficient function varies based on the local gray level variance to control the emphasis of diffusion adaptively for varying image structure. Accordingly, smoothing of the image takes place which preserves the blurred edge regions of noise reduced image. The lower graph in Fig. 4 demonstrate the variation of diffusion coefficient function d(x, y) in accordance with the variation of local gradient \(\nabla f(x,y)\) and local gray level variance σ 2(x, y). The following four cases are observed:

  • Case 1: If, \(\nabla f(x,y)>k(x,y)\) and \(\sigma^{2}(x,y)>k_{0}\), then (x, y) is the position where image intensity changes abruptly and the value of local gray level variance is very high. In such position, the diffusion coefficient function decreases fast which slows down the smoothing process preserving the high gradient as well as high gray level inter-region edges and fine details.

  • Case 2: If, \(\nabla f(x,y)>k(x,y)\) and \(\sigma^{2}(x,y)<k_{0}\), then (x, y) is the position where image intensity changes abruptly and the value of local gray level variance is very low. In such position, the diffusion coefficient function decreases which slows down the smoothing process preserving the high gradient inter-region edges and fine details.

  • Case 3: If, \(\nabla f(x,y)<k(x,y)\) and \(\sigma^{2}(x,y)>k_{0}\), then (x, y) is the position where image intensity does not change abruptly and the value of local gray level variance is very high. In such position, the diffusion coefficient function increases or decreases with respect to high or low values of k(x, y) respectively. This helps to smooth the defective background of very low gray level regions and recover the inter-region edges and fine details of high gray level values.

  • Case 4: If, \(\nabla f(x,y)<k(x,y)\) and \(\sigma^{2}(x,y)<k_{0}\), then (x, y) is the position where image intensity does not change abruptly and the value of local gray level variance is very low. In such position, the diffusion coefficient function increases which results in fast smoothing of homogenous defective background having low gradient as well as low gray level values.

Fig. 4
figure 4

(Upper Curve) Graphical representation showing the variation of DCF in accordance with local gray level variance at a fixed value of gradient; (Lower Curve) Graph of the DCF with variations in gradient magnitude and local gray level variance

4 Experimental results and discussions

The proposed method has been implemented on MATLAB R2009b and the effectiveness of the same is validated on various test images taken from the internet sources. One of the most popular and frequently used ‘Lena’ image of size 677 × 598 and the images of ‘Cameraman’, ‘Coins’, ‘Baboon’ and ‘Pyramid’ of sizes 204 × 204, 297 × 243, 225 × 225 and 225 × 225 respectively have been demonstrated in this paper. The original images have been corrupted by RVIN from 10 % to 50 % noise densities artificially. The detailed demonstration of the proposed method is shown through ‘Lena’ image. During experimentation, it was observed that the proposed diffusion results are very much affected by the threshold constant k 0 in diffusion coefficient function and number of diffusion iterations T 2. The variation of neighborhood size M × N for the calculation of local gray level variance σ 2(x, y) also effects the diffusion results. Moreover, the choice of threshold T h and number of iterations T 1 during SOD operation are also important. In the following sections, we discuss the choice of these parameters and comparison of the proposed diffusion results with some existing methods independently used for edge preservation and impulse noise reduction.

4.1 Choice of parameters in pre-reduction of impulsive noise

During the impulsive noise reduction process, we tested the SOD result on ‘Lena’ image by varying the values of threshold T h . The graph in Fig. 5 shows variation of the peak signal to noise ratio (PSNR) value with respect to different values of T h for 20 to 50 % RVIN densities in ‘Lena’ image. It is observed from the graph of Fig. 5 that a fixed value of T h can not be used for all noise densities. Therefore, in this work, we have considered the average threshold T h  = 35 which shows the best PSNR performance at different noise densities. Another important parameter in SOD operation is the number of iterations T 1. We studied the behavior of SOD operation for different values of number of iterations T 1 varying from 1 to 5. The variation of PSNR for fixed value of threshold T h  = 35 against the number of iterations is plotted in Fig. 6. It is evident from Fig. 6 that for the noise densities from 20 to 50 %, the best PSNR is achieved at T 1 = 5. Therefore, T h  = 35 and T 1 = 5 are used for SOD operation for rest of the images processed in this work. The original image, noisy image by 30 % RVIN and the de-noised image of ‘Lena’ by the SOD operation using T h  = 35 and T 1 = 5 are shown in the top row of Fig. 7.

Fig. 5
figure 5

Graphical representation of PSNR(dB) value at different threshold values in SOD for 20 % to 50 % corrupted Lena images respectively

Fig. 6
figure 6

Graphical representation of PSNR(dB) value at different numbers of iterations with T h  = 35 in SOD for 20 to 50 % corrupted Lena images respectively

Fig. 7
figure 7

a Original Lena image; b Corrupted Lena image by 30 % RVIN; c Restored SOD filtered image by the SOD operation of the proposed method with T h  = 35 and T 1 = 5; dg Diffusion results by the proposed method with k 0 = 10, 15, 20, 25 respectively at T 2 = 50; hk Diffusion results by the proposed method with T 2 = 50, 100, 150, 200 respectively at k 0 = 10; ln Diffusion results under different sizes of local neighborhood M × N: (3 × 3), (5 × 5) and (9 × 9) respectively at T h  = 35, T 1 = 5, k 0 = 10 and T 2 = 50

4.2 Choice of parameters in modified anisotropic diffusion

During the edge restoration of SOD filtered image, we evaluate the effects of different combinations of the edge threshold constant k 0 in diffusion coefficient function and the number of diffusion iterations T 2. Initially, the value of k 0 is taken as the global gray level variance of the ‘Lena’ image which is varied for different iterations to get the better edge preservation. The first middle row of Fig. 7 presents the diffusion results on ‘Lena’ image (from left to right respectively) under varying values of k 0 = 10, 15, 20, 25 respectively in diffusion coefficient function for a fixed number of diffusion iterations T 2 = 50. On doing a perceptional analysis, it is observed that at k 0 = 10, best diffusion results are obtained. Therefore, in these four values of k 0, the optimal k 0 = 10 is selected for rest of the images in this experiment. Similarly, the choice of an appropriate number of diffusion iterations T 2 is made by comparing the effect of the number of iterations T 2 = 50, 100, 150, 200 respectively for a fixed threshold constant k 0 = 10. The diffusion results under varying number of iterations are shown in the second middle row of Fig. 7. The above experiments reveal that at T 2 = 50, the proposed method show good diffusion results with well-preserved edges. Based on the above experimental observations, we use 10 and 50 respectively as optimal values of k 0 and T 2 for rest of the images in this experiment.

4.2.1 Effect of variation in neighborhood size

The size of the local neighborhood size M × N for calculation of local gray level variance σ 2(x, y) in the proposed thresholding method is another important parameter which affects the diffusion results. The size of the neighborhood area M × N should be as small as possible in order to preserve lowest possible fine details in the image and to keep the computational burden as low as possible. We have selected the regions of three smallest sizes 3 × 3, 5 × 5 and 9 × 9. The diffused images obtained using the three smallest sizes of local areas with T h  = 35, T 1 = 5, k 0 = 10 and T 2 = 50 are shown in bottom row of Fig. 7 which indicates the best result is obtained for window size 3 × 3.

The list of all the parameters and their optimal values used in the proposed method discussed in above Sections are shown in tabulated form in Table 1.

Table 1 List of parameters and their optimal values used in the proposed method

4.3 Comparison with existing diffusion methods

The accuracy of the proposed diffusion scheme has been tested by comparing the diffusion results with that of the other existing anisotropic diffusion methods independently used for edge preservation and impulse noise reduction.

4.3.1 Comparison of edge preservation

To test the accuracy of edge preservation by the proposed diffusion scheme, the de-noised image of ‘Lena’ by the SOD operation is diffused by Perona-Malik diffusion (PMD)[17], Chao-Tsai diffusion (CTD) [4] and proposed diffusion respectively. The diffusion results for 20 % and 40 % impulse noise densities are shown in the top and bottom rows of Fig. 8 respectively. We choose an optimal value of threshold k = 4 in PMD [17] as suggested by Perona and Malik because a high value of k tends to oversmooth the entire image. In CTD [4] and proposed scheme, we used k 0 = 10 with number of diffusion iterations T 2 = 50 respectively. It is evident from Fig. 8 that the proposed diffusion method better preserves the edges and fine details as compared to that of the other diffusion methods. To compare quantitatively, the performance of edge preservation by the three methods, we computed the Pratt’s figure of merit (FOM) [18]. FOM is a parameter used to evaluate the edge preservation ability of any method and is defined as:

$$ FOM = \frac{1}{max[P_{\rm detected}, P_{\rm original}]}\sum\limits_{i=1}^{P_{\rm detected}}\frac{1}{1+\frac{d_{i}^{2}}{9}} $$
(21)

where P detected and P original are number of detected and original edge pixels respectively. d i is the Euclidean distance between the ith detected edge pixel and the closest original edge pixel. The range of values of FOM starts from 0 and varies upto 1 for the ideal edge preservation. The FOM values for the representative ‘Lena’ image at different noise densities are demonstrated in Fig. 9 which shows the better edge preservation by the proposed method as compared to PMD [17] and CTD [4]. In addition to this, a quantitative comparison of the proposed diffusion results with that of the PMD [17] and CTD [4] in terms of PSNR values for the representative ‘Lena’ image at different noise densities are shown in Table 2. It is evident from Table 2 and Fig. 9, that the proposed method is better than the two existing diffusion methods [4, 17].

Fig. 8
figure 8

ac Diffusion results of SOD filtered 20 % corrupted Lena image by PMD [17], CTD [4] and proposed method respectively; df Diffusion results of SOD filtered 40 % corrupted Lena image by PMD [17], CTD [4] and proposed method respectively

Fig. 9
figure 9

FOM curves for comparison of edge preservation under different noise conditions on Lena image

Table 2 Comparison of PSNR(in dB) for SOD filtered Lena images at different noise densities by the three diffusion methods: PMD[17], CTD[4] and the proposed method

4.3.2 Comparison of impulse noise reduction

The proposed diffusion results have also been compared with Jian Wu’s diffusion method (JWD) [25] which has been specifically developed for impulse noise reduction. The impulse noisy images of ‘Lena’ at different noise densities are restored by JWD [25] and the proposed method. The diffusion results for 20 % and 40 % impulsive noise densities by the two methods are shown in Fig. 10 and the values of PSNR at 10 % to 50 % noise densities are shown in Table 3. We observed that there is not much difference between the appearance of the resultant images of the two methods. However, as the noise density increases, JWD [25] tends to leave the noisy pixels and destroys the thin edges. On the other hand, the proposed diffusion scheme reduces the impulsive noisy pixels along with reduced blurring of the image. Through the above comparison with existing diffusion methods independently used for impulse noise removal and edge preservation, it can be concluded that the prior removal of impulsive noise before the application of diffusion process is advantageous over the direct application of diffusion for removing the impulsive noise.

Fig. 10
figure 10

ab Restored 20 % corrupted Lena image by JWD [25] and proposed method respectively; cd Restored 40 % corrupted Lena image by JWD [25] and proposed method respectively

Table 3 Comparison of PSNR(in dB) for original Lena image at different noise densities by JWD[25] and the proposed method

4.4 Comparison with median filter based methods

We also compared the results of the proposed method with some of the median filter based methods i.e., adaptive center weighted median filter (ACWM) [8], directional weighted median filter (DWM) [11] and fast two phase image de-noising method (FTPID) [2] used for the reduction of impulsive noise. The restored results are shown in top and bottom rows of Fig. 11 for 20 % and 40 % of impulse noise density respectively. The magnified sections of the respective restored images of Fig. 11 are shown in Fig. 12 to demonstrate the effectiveness of proposed method for edge preservation along with RVIN reduction over the three median filter based methods [2, 8, 11]. The values of PSNR by the four methods at 10 to 50 % of the impulsive noise densities for the same experiment are demonstrated in the form of graphical representation in Fig. 13. From the simulation results, we observe that the proposed method outperformed the other methods up to 50 % of the impulsive noise densities. However, the performance of the proposed method slightly degrades for noise densities beyond 50 % as compared to (DWM) [11] because at high noise densities, some noisy pixels still remain in the image in the form of patches or spikes which corresponds to the region of high gray level variance. Thus, these patches or spikes gets restored by the proposed diffusion method too.

Fig. 11
figure 11

ad Restored 20 % corrupted Lena image by ACWM[8], DWM[11], FTPID[2] and the proposed method respectively; eh Restored 40 % corrupted Lena image by ACWM[8], DWM[11], FTPID[2] and the proposed method respectively

Fig. 12
figure 12

ad Magnified sections of restored 20 % corrupted Lena image by ACWM[8], DWM[11], FTPID[2] and the proposed method respectively; eh Magnified sections of restored 40 % corrupted Lena image by ACWM[8], DWM[11], FTPID[2] and the proposed method

Fig. 13
figure 13

Graphical representation of PSNR(dB) for original Lena images at different noise densities by the four methods: ACWM[8], DWM[11], FTPID[2] and the proposed two phase method

On comparing quantitatively the performance of edge preservation of the proposed method with that of DWM [11], a significant improvement in terms of FOM is observed which is shown in Table 4. This implies that the proposed method can preserve the edges effectively with impulse noise reduction as compared to DWM [11].

Table 4 Comparison of FOM for original Lena image at different noise densities by DWM [11] and the proposed method

4.5 Quantitative comparison on other images

The diffusion results by the proposed method in the rest of the test images of ‘Cameraman’, ‘Coins’, ‘Baboon’ and ‘Pyramid’ are shown in the top row of Fig. 14. The respective magnified sections for demonstration of edge preservation are shown in bottom row of Fig. 14. Likewise ‘Lena’ image, the existing methods PMD[17], CTD[4], JWD[25], ACWM[8], DWM[11] and FTPID[2] are applied on rest of the four images to compare the results with that of the proposed method. Table 5 summarizes the values of PSNR of the restored images by the above six methods and the proposed method at 20 to 50 % of impulse noise densities respectively. In addition to this, the performance of edge preservation is compared with the existing edge preserving methods in terms of FOM [18] which are shown in Table 6. From the above quantitative comparison, we observed that the proposed method performs well in the images with mild edge structures.

Fig. 14
figure 14

ad Restored 30 % corrupted images of cameraman, coins, baboon and pyramid by the proposed method respectively; eh Magnified sections of the above images respectively showing edge preservation

Table 5 Comparison of PSNR(in dB) for images of cameraman, coins, baboon and pyramid at 20 %, 30 %, 40 % and 50 % RVIN by methods: PMD [17], CTD [4], JWD [25], ACWM[8], DWM[11], FTPID[2] and the proposed method
Table 6 Comparison of FOM for images of cameraman, coins, baboon and pyramid at 20 %, 30 %, 40 % and 50 % RVIN by methods: PMD [17], CTD [4], DWM[11] and the proposed method

The analysis of experimental study carried out in Section 4 conjectured that the proposed diffusion method for impulse noise reduction as well as edge preservation is more advantageous than the existing methods used only for either impulse noise reduction or edge preservation.

4.6 Computational complexity

Here, the time complexity of the proposed method has been computed. Since the proposed method is a two stage process, the computational complexity depends on the computational parts of the two stages respectively. In the stage of impulse noise reduction, for window size 3 × 3, there are four directions, but in each direction there are only three points. During SOD operation, we need 1 addition, 1 subtraction and 1 multiplication in each direction. Therefore, for all the four directions, we need 4 additions, 4 subtractions and 4 multiplications which are much lesser than existing directional weighted median filter (DWM) [11] where the window size has been considered as 5 × 5 and to calculate weighted difference in each direction, it needs 4 subtractions, 3 additions and 2 multiplications. Overall, it requires 16 subtractions, 12 additions and 8 multiplications for four directions.

In the diffusion stage of the proposed method, the complexity is dependent on the computation of local gradient \(\nabla f(x,y)\) and local gray level variance σ 2(x, y). For an image of size N × N, the computation of four gradients is O(N 2) where as the computation of local gray level variance σ 2(x, y) is dependent on the neighborhood window size. If we consider the window size of local neighborhood area as w × w, then the local gray level variance σ 2(x, y) of these sub-images can be computed as shown in Algorithm 1 where I(i, j) and meanI(i, j) are the input image and mean of the input image respectively at (i, j)th pixel position and initially the local gray level variance var is taken as 0. The inner two loops run for the window size leading to the time complexity of O(w 2). Then, this window is moved around the entire image of N × N size which is captured by the outer two loops which give the time complexity of O(w 2 N 2). As w is taken as 3 and kept constant throughout experimentation, the computation time increases by a constant multiplier as compared to Perona-Malik diffusion (PMD) [1]. However, the complexity of the proposed method is almost same as that of Chao-Tsai diffusion (CTD) [4].

5 Conclusion

The existing methods of smoothing random valued impulsive noise inherently has the drawback of blurring the prominent edges in the image. In this paper, an edge preserving diffusion method has been proposed by applying pre-filtering of impulse noise. Impulse noisy pixels have been removed by improved second order pixel difference operation and partial differential equation based modified anisotropic diffusion has been applied for the restoration of edges destroyed during impulse noise reduction process. The proposed diffusion method employs local gray level variance based adaptive thresholding scheme in diffusion coefficient function which preserve the destroyed blurred edges and fine details. The proposed diffusion method has been tested on variety of test images and experimental results have been compared with some of the existing diffusion methods and advanced median filtering methods. It is observed that the proposed method gives better result upto 50 % of impulsive noise density in terms of peak signal to noise ratio.

The future work can be extended by exploring the properties of diffusion coefficient function in anisotropic diffusion in order to deal with the noise content more than 50 % and better edge preservation. Moreover, exploring the possibility of developing parameter optimization technique for best quality results is another important research issue.