The proposed detection scheme is based on utilizing both PWS and MAd statistics. Test image *Bridge* corrupted with of artificially added mixed impulse noise is given in Figure 2. Since the position of noisy pixels is known, we can calculate PWS and MAd values for every pixel. Scatter plots of those values are given in Figure 3 for noisy and noise-free pixels separately. Each image pixel in a plot is represented as a dot with coordinates given by its PWS and MAd values. The overlapping area between two plots is relatively large, which can be expected since some noisy pixels are hidden in image details and simply cannot be distinguished from them. Nevertheless, Figure 3(a) contains in total fewer pixels than Figure 3(b), because of the noise distribution in Figure 2. Therefore, the overlapping area contains many more noise-free than noisy pixels. Still, due to this overlapping, we cannot build a detector which is able to separate noisy and noise-free pixels in just one step. It is necessary to apply the whole filtering scheme iteratively, with some bias towards detail preservation—it is more important to preserve noise-free pixels than to leave some impulses undetected. Undetected impulses are likely to be removed in future iterations, while filtered details cannot be recovered.

### 4.1. Detection

Ideally, we would be capable of labeling all the pixels which do not belong to the area where noise-free pixels are concentrated in scatter plot in Figure 3(b). Still, this is not an easy task, and we need a solution which is robust. We introduce the usage of a simple affine classifier to separate the plane defined by PWS and MAd values into two regions: noisy and noise-free. The classifier is given as follows:

where and are parameters which determine the decision boundary of the classifier. Since we propose the usage of an iterative filtering procedure, in the th iteration step the classifier generates a noise map having "1" at positions where noise is detected and "0" at positions labeled as noise-free. Accordingly, the noise map in the th filtering iteration is given as

where and denote the statistics calculated in the th iteration for the pixel at position . The values of the constants and depend on the iteration and they are determined experimentally.

The detector uses a recursive approach for the calculation of the noise map . This means that the pixels detected as noisy are immediately replaced by the initial estimate , and in a subsequent processing the new estimates are used for processing of the neighboring pixels. As the initial estimate we use median value calculated in a filtering window :

where

Therefore, the initial estimate is calculated using estimate as an input instead of if the pixel at position is already processed. In the next filtering iteration the output of the previous iteration is used as the input:

The same recursive approach is used when and values are calculated. Instead of the input values , the initial estimates are always used if they are already calculated. The initial estimates are later replaced by final estimates obtained by edge-preserving regularization. The details about the final estimation are given in Section 4.2.

We denote the proposed detection scheme *PWS detector* since the noise classifier is based on PWS and MAd statistics, but MAd is actually calculated within the calculation of PWS. The detector parameters and are determined experimentally. Parameter defines the slope of the classification line in the PWS/MAd plane, defined by (7), whereas defines the offset from the origin. It has been found through experimentation with images having 8 bits per pixel that the optimal value of should be in the range . In our simulations we set it to be constant in every iteration and to be at the middle of this range, that is, . On the other hand, the slope parameter should change throughout the iterations. In the beginning it should be in the range and it should become smaller in subsequent iterations, in order to become less conservative and allow detection of more noise. We reduce this parameter for a constant factor in each iteration . These parameters are very robust and produce satisfactory results for different noise levels and different images.

Figure 4 shows the distribution of noisy (red) and noise-free (blue) pixels together with the decision boundary. In each iteration the pixels below the boundary are labeled as noisy, and the estimation procedure described in Section 4.2 is applied to them. Modification of the parameter moves the decision boundary slowly upwards, thus allowing more impulses to be detected. In the last iteration the noisy and noise-free regions are overlapping, so any further filtering will not give additional improvements to the filtered image. In Figure 5 the enlarged detail of the actual distribution of noise-free pixels from the scatter plots given in Figures 4(e) and 4(f) is presented. The decision boundaries of detectors are also given. The majority of the noise-free pixels are still labeled correctly in iteration 5 while in iteration 6 the decision boundary passed through the region where the distribution is more dense. Therefore, the filtering should be stopped in this case at iteration 5, before a significant number of noise-free pixels are wrongly marked as noisy. In each iteration a relatively small percent of noise-free pixels are unnecessarily filtered due to misclassification. This undesirable effect cannot be completely avoided but can be possibly reduced by finding the classifier which better fits the border between noisy and noise-free pixels. Accordingly, we should keep in mind that total separation between those pixels is often impossible because some percentage of noise is blended with the image details and cannot be distinguished.

It has been experimentally verified that the proposed detection procedure is robust to the variation of parameters and . However, the quality of the output is mainly influenced by the optimal number of iterations , because iterative filtering has to be stopped before it starts to severely destroy image details. This issue is discussed and handled by the algorithm described in Section 4.3.

The last parameter, which is the only one that actually has to be set manually, is the window size , defined in (3). We follow the rules given in [20]: if the noise ratio is higher than , we use window; otherwise the window of the size is applied. This yields satisfactory performance in most cases.

### 4.2. Estimation

Many space-variant filtering methods designed for suppression of the impulse noise use estimators based on the median and its derivatives. We utilize this kind of estimate just as a first approximation during the iterative impulse detection. The final estimate is found by replacing the noisy pixels with values found through the procedure of edge-preserving regularization (EPR) similar to [24]. We combine the proposed PWS detector with edge-preserving regularization and denote it as PWS-EPR filter.

Firstly, the pixels marked as noise-free are estimated by the observed value, that is, . The noisy pixels are estimated by minimizing the functional defined as follows:

where is the set of all pixels marked as noisy in the noise map, is the set of the four closest neighbors of and is the edge-preserving potential function [31]. Particularly, we use the following function:

similarly as in [25], where Note that in contrast to [25] or [32] the functional in (12) contains only a regularization term and not the data term. This is because the data are fitted exactly for the uncorrupted pixels, while for the corrupted pixels it is expected that the difference between observed end estimated values will be large due to the nature of the impulse noise.

A global minimization of the functional is very difficult. Therefore, we apply the optimization procedure for each pixel separately and repeat the procedure iteratively across the whole image until the process converges to the stable solution. Since the edge-regularization potential function is strictly convex, we perform the local optimization by Brent optimization method [33]. The same convergence criteria as in [34] are applied.

### 4.3. Stopping Criteria

The important issue which is common for iterative filtering approaches is to determine the optimal number of iterations. Most of the state-of-the-art algorithms set that parameter to some fixed value which gives satisfactory results in most cases [14, 21, 25] or set it according to noise concentration [20, 23]. Still, this is a challenging problem because the optimal number of iterations usually depends on both image content and noise concentration. The proposed PWS-EPR filter in each iteration calculates the PWS estimate of the variance, and this is utilized to determine the stopping criteria for the iterative filtering.

The PWS can be comprehended as an approximation of the S-estimate of variance. Therefore, the result of the estimation produced by PWS is more susceptible, that is, less robust to the presence of impulse noise. As the filtering with PWS-EPR filter goes through the iterations, the PWS will give a better approximation, since the noise concentration is continuously reduced and PWS estimates between the consequent iteration are becoming more and more similar. At some point, as a result of detector design, further continuation of the filtering starts to significantly destroy image details. The point when the filtering has to be stopped is illustrated in Figure 5 where the decision boundary starts to misclassify a significant number of noise-free pixels and therefore degrade image details. Hence, the difference between two consecutive PWS estimates starts to become more significant. So, the criteria for stopping further filtering by the PWS-EPR filter is to find the point where the similarity between consecutive PWS estimates changes trends from descending to ascending. This simple approach has proven to be very effective. As a similarity measure between consecutive PWS estimates we use mean relative absolute difference calculated across the whole image:

where the summation goes over all pixel coordinates, is the number of pixels in the image, and is the iteration number.