{'fraction_non_alphanumeric': 0.03670403459853184, 'fraction_numerical': 0.013315882319467365, 'mean_word_length': 4.586141131595677, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Fast Switching Filter for Impulsive Noise Removal from Color Images

In this paper, we present a fast switching filter for impulsive noise removal from color images. The filter exploits the HSL color space, and is based on the peer group concept, which allows for the fast detection of noise in a neighborhood without resorting to pairwise distance computations between each pixel. Experiments on large set of diverse images demonstrate that the proposed approach is not only extremely fast, but also gives excellent results in comparison to various state-of-the-art filters.


Introduction
The growing use of color images in diverse applications such as content-based image retrieval, medical image analysis, biometrics, remote sensing, watermarking, and visual quality inspection has led to an increasing interest in color image processing. These applications need to perform many of the same tasks as their grayscale counterparts, such as edge detection, segmentation and feature extraction [1]. However, images are often contaminated with noise which is often introduced during acquisition or transmission. In particular, the introduction of bit errors and impulsive noise into an image not only lowers its perceptual quality but also makes subsequent tasks such as edge detection and segmentation more difficult. Therefore, the removal of noise from an image is often a necessary preprocessing step for these tasks. Modern image filtering solutions can eliminate noise without significantly degrading the underlying image structures such as edges and fine details [2]. Recent applications of color image denoising include enhancement of cDNA microarray images [3,4], virtual restoration of artworks [5,6], and video filtering [7][8][9][10].
Numerous filters have been proposed in the literature for noise removal from color images [11][12][13][14]. Among these, nonlinear vector filters have proved successful in dealing with impulsive noise while preserving edges and image details [13]. These filters treat pixels in a color image as vectors to avoid color shifts and artifacts. An important class of nonlinear vector filters is the one based on robust order-statistics with the vector median filter (VMF) [15], the basic vector directional filter (BVDF) [16], and the directionaldistance filter (DDF) [17] being the most well-known examples. These filters involve the reduced ordering [18] of a set of input vectors within a window to compute the output vector.
The fundamental order-statistics based filters (VMF, BVDF, and DDF) as well as their fuzzy [19,20] and hybrid [21] extensions share a common deficiency in that they are implemented uniformly across the image and tend to modify pixels that are not corrupted by noise [22]. This results in excessive smoothing and the consequent blur of edges and loss of fine image details. In order to overcome this, intelligent filters that switch between a robust order-statistics based filter such as the VMF and the identity operation have been introduced [22][23][24][25][26][27][28][29][30][31][32][33][34][35][36][37]. These filters determine whether the pixel under consideration is noisy or not in the context of its neighborhood. In the former case, the pixel is replaced by the output of the noise removal filter; otherwise, it is left unchanged to preserve the desired (noise-free) signal structures. Such an approach is computationally efficient considering that the expensive filtering operation is performed only on the noisy pixels, which often comprise a small percentage of the image.
In this paper, we introduce a new switching filter for the removal of impulsive noise from color images.
The proposed filter exploits the HSL color space [13], and is based on the concept of a peer group [22], which allows for the fast detection of noise in a neighborhood without resorting to pairwise distance computations between each pixel. The center pixel in a neighborhood is considered as noise-free if it has a certain number of pixels that are similar to it. In this case, it remains intact. Otherwise, it is replaced by the VMF output, i.e. the pixel that minimizes the sum of distances to all other pixels in the neighborhood. The method is tested on a large set of images from diverse domains. The results demonstrate that the proposed filter is not only extremely fast, but also gives excellent results in comparison to various state-of-the-art filters.
The rest of the paper is organized as follows. Section 2 describes the proposed method and the motivation behind the choice of the HSL space for the calculation of the similarity metric. Section 3 presents the experimental results. Finally, section 4 gives the conclusions.

Proposed Method
Let y(x): Z 2 → Z 3 denote an RGB color image that is comprised of a two-dimensional array of three component samples. Although natural images are often nonstationary, filters operate on the assumption that they can be subdivided into small regions that are stationary [12]. This is accomplished using a small window that slides through the individual image pixels while performing the filtering operation locally. The most commonly used window is a square-shaped window W = { x i | i = 1, 2, …, n } of a finite size n, where x 1 , x 2 , …, x n is a set of pixels centered around x (n+1)/2 which determines the position of the window.
Most vector filters operate by ordering the vectors inside the filter window. However, calculating the aggregate distances used in the ordering criterion may limit the use of these filters in real-time applications.
One way to reduce the computational requirements of a nonlinear vector filter is to limit the number of comparisons that are performed between the center pixel and the neighboring pixels in the window. The Fast Peer Group Filter (FPGF) [31] uses the concept of the peer group [22] where Tol is the distance threshold, m is the size of the peer group, . is the set cardinality, . p is the L p (Minkowski) norm, and x VMF denotes the VMF output given by: Essentially, the peer group of a pixel represents the neighboring pixels in the window that are sufficiently 'similar' to it according to a particular measure. This concept is due to Lee [38] and has been used extensively in the design of various filters, often under the name of extended spatial neighborhood [31].
The FPGF is much faster than the well-known vector filters mentioned in the previous section because it declares the center pixel to be noise-free as soon as m pixels in the window are determined to be sufficiently similar to it. If m is low, and the level of noise in the image is not very high, this allows for a dramatic reduction in the number of distance computations that need to be performed. In particular, the minimum and maximum number of distance calculations necessary to classify a pixel equal m and n-m, respectively. Therefore, on the average, the number of distance calculations performed by the FPGF is much lower than that performed by the VMF, i.e. ( 1) 2 n n − . However, due to the nature of the L 2 norm, the distance computations performed in highly correlated spaces such as RGB remain expensive. On the other hand, if the image is transformed into a color space which decouples chromaticity and luminance, the distance between two color vectors can be evaluated without such a computation. In this study, we adopted the HSL color space in order to accomplish this.
The HSL (hue, saturation and lightness) color space is an intuitive alternative to the RGB space [13]. It uses approximately cylindrical coordinates, and is a non-linear deformation of the RGB color cube (Figure 1a).
The hue H ∈ [0,360] is a function of the angle in the polar coordinate system and describes a pure color.
The saturation S ∈ [0,100] is proportional to radial distance and denotes the purity of a color. Finally, the lightness L ∈ [0,255] is the distance along the axis perpendicular to the polar coordinate plane and represents the brightness. The distance between two vectors x i = (h i , s i , l i ) and x j = (h j , s j , l j ) in the HSL space is given by:

INSERT FIGURE 1 HERE
Building upon the idea of the peer group in much the same way as the FPGF, we propose a new filtering algorithm called the Fast HSL-based Switching Filter (FHSF). First, the RGB image is transformed to the HSL space [13]. The output vector in a window is then determined according to the following rule:

h h Ht and s s St and l l Lt S x x otherwise
where (h i , s i , l i ) and (h j , s j , l j ) denote the hue, saturation, and lightness of the pixels x i and x j , respectively.
Ht, St, and Lt are the thresholds for the hue, saturation, and lightness, respectively.
The FHSF algorithm works as follows. First, it checks whether the center pixel is noisy or not. If the pixel is determined to be noisy, it is replaced by the VMF output. Otherwise, it remains untouched. A noise-free pixel is one which has a minimum of m peers that are sufficiently similar to it. The similarity is determined by the function S, which checks to see if the hue, saturation and lightness of the pixel are close to those of the center pixel.
The similarity function S is clearly cheaper to evaluate when compared to the L 2 norm in the RGB space.
The superficial similarity between the S function and the L 1 norm can be discounted by the fact that the former operates in the decorrelated HSL space as opposed to the correlated RGB space, and consequently the conjunction involved in this function allows for short-circuit evaluation. That is, for instance, as long as two color vectors differ in hue, the remaining two conditions need not be evaluated. On the other hand, in the L 1 norm the absolute differences between the R, G, and B components always need to be calculated. Table 1 shows the number of elementary operations required by each function. It can be seen that in the worst case, since COMPs and ADDs have the same complexity [39], the S function has the same number of operations as the L 1 norm.

Noise Model and Error Metrics
Several simplified color image noise models have been proposed in the literature [10,11,13]. In this study, the correlated impulsive noise model originally proposed in [10] is adopted. In order to evaluate the filtering performance the following error metrics are used: MAE (Mean Absolute Error) [13], MSE (Mean Squared Error) [13], NCD (Normalized Color Distance) [13], and PCD (Perceptual Color Distance) [40][41][42]. MAE and MSE are based on the RGB color difference and measure the detail preservation and noise suppression capability of a filter, respectively. NCD and PCD are perceptually oriented metrics that measure the color preservation capability of a filter. NCD is based on the CIELAB color difference whereas PCD is based on the S-CIELAB color difference, which is a spatial extension of the former [43]. It should be noted that, to the best of the authors' knowledge, PCD has not been used in the color image filtering literature to date. It is included because it takes into account both the spatial and color sensitivity of the human visual system [41].

Parameter Selection
There are four parameters involved in the proposed filter: m (the peer group size), Ht (Hue Threshold), St (Saturation Threshold) and Lt (Lightness Threshold). Appropriate ranges for these parameters need to be determined to ensure a good filtering performance on a variety of images. Since the filtering operation is very fast, a simple grid search procedure can be used for this task. In order to do this, the parameter space should first be quantized.
The parameters m, Ht, St, and Lt were restricted to [1,8] 1 (step size Δ = 1), [6,20] (Δ = 2), [4,16] (Δ = 2), and [32,64] (Δ = 4), respectively. The sizes of the intervals for the Ht, St, and Lt parameters follow the relative importance of the individual components of the HSL space. This is because the human visual system is most sensitive to changes in hue, followed by saturation, and then lightness [44]. For example, the hue threshold Ht is restricted to the [6,20] interval because for noise removal purposes, two colors that have more than 20º of hue difference can safely be considered as dissimilar (see Figure 1b).
A set of 100 images was collected from the World Wide Web to be used in the grid search. These included images of people, animals, plants, buildings, aerial maps, man-made objects, natural scenery, paintings, sketches, as well scientific, biomedical, and synthetic images and test images commonly used in the color image processing literature. Figure 2 shows several representative images from this set.

INSERT FIGURE 2 HERE
The PCD measure was used to quantify the goodness of a particular set of parameters {m, Ht, St, Lt}. images that are contaminated with 5%, 10%, 15% and 20% impulsive noise.

INSERT FIGURE 3 HERE
As explained in Section 2, the filtering operation is faster for lower values of m. In fact, the performance of the proposed filter (in terms of both the effectiveness and the efficiency) will approach that of the VMF at 1 Assuming a 3x3 window high values of m. It can be seen from Figure 3 that m = 3 provides a good compromise between effectiveness and efficiency. This is in line with the observations of Smolka and Chydzinski [31].
The ranges for the remaining three parameters, Ht, St and Lt, were determined as follows. For each test image, the parameters were varied in the above-mentioned intervals and the corresponding PCD values were calculated. Considering the diversity of the images, it is unreasonable to expect the same parameter combination to give the lowest PCD value for each image. Therefore, the parameter combinations that achieved the lowest 5% PCD values for each image were recorded. It is expected that a parameter combination that will perform well on a variety of images would appear somewhere in these top 5% lists.
The intersection of these lists revealed that the following ranges perform well on the test images, Ht ∈ [8,12], St ∈ [8,14], and Lt ∈ [40,56]. . It can be seen that although the change in the hue threshold is the smallest, the degradation in the filtering result is the greatest. On the other hand, the change in the lightness threshold is the largest, but the filtering result is better than those of (d) and (e).

Comparison with State-of-the-Art Filters
The proposed filter is compared with recent switching filters such as the peer group filter (PGF) [22], the adaptive vector median filter (AVMF) [26], the fast fuzzy noise reduction filter (FFNRF) [32], the fast peer group filter (FPGF) [31], the vector sigma filters based on the mean and lowest ranked vectors (SVMF mean , SVMF rank ) [33], and their adaptive counterparts (ASVMF mean , ASVMF rank ) [33]. The traditional filters  On the other hand, the switching filters, i.e. the FPGF 2 , the FFNRF, the PGF, and the FHSF S preserve the details satisfactorily. Among these, the FHSF S strikes the best balance between noise removal and detail preservation. Figure 6 shows the filtering results for a section of the pig image and the corresponding difference images.

INSERT FIGURE 5 HERE
In order to obtain the difference images, the pixelwise absolute differences between the original and the filtered images are multiplied by 5 and then negated. As expected, the VMF and the DDF outputs show significant differences when compared to the original image. In contrast, the switching filters show a clear improvement in restoring the original image. Among these, it can be seen that the AVMF, the PGF, and the FHSF S give the best performance.

INSERT FIGURE 6 HERE
Tables 2-4 compare the filters using the criteria described in Section 3.1, i.e. MAE, MSE, NCD, PCD and the execution time 2 in seconds. It can be seen that the FHSF S compares favorably with the best filters in terms of filtering effectiveness, as assessed by the first four criteria. The execution time is also a very important factor which determines the practicality of a noise removal filter. From this perspective, due to their high computational requirements, the non-switching filters in general are not appropriate for denoising large images that are common in domains such as astronomy, remote sensing and biology. Regarding the remaining filters, as the image size increases, the computational advantage of the FHSF S over the others becomes apparent. In general, the FHSF S is almost twice as fast as the next fastest filter, i.e. the FPGF 1 .
Note that the timing for the FHSF S includes the RGB to HSL transform, although this is negligible 3 . 2 HERE   INSERT TABLE 3 HERE   INSERT TABLE 4

HERE
In summary, the experiments demonstrate that the FHSF S combines simplicity, excellent filtering performance and significant computational efficiency, which makes it a practical method for impulsive noise removal from color images.

Conclusions
In this paper, we introduced a fast switching filter for the removal of impulsive noise from color images.
The proposed filter exploited the HSL color space in conjunction with the concept of a peer group in order to allow for the fast detection of noise in a neighborhood. The method was tested on a large set of images from diverse domains, as well as classical images used in the color image processing literature. The experiments demonstrated that the new method is much faster than state-of-the-art filters and that the filtering quality is also excellent.             Figure 6. Filtering results for the pig image corrupted with 10% noise and the corresponding absolute difference images