Filtering of mixed Gaussian and impulsive noise using morphological contrast detectors

.


Introduction
A common problem in image processing is the detection and reduction of noise in digital images. As a result, several methods have been proposed. In [1], grey-level images are cleaned using top-hats [2] and smoothed images. Smoothed images are obtained from alternated filters [3]. In [4,5], a distance criterion to detect noise given by the top-hat transformation is applied, followed by an open-close sequence to remove noise. In [6], a distance criterion in terms of the open-close and close-open filters is presented, and noisy pixels are replaced by those obtained from an adaptive switching median filter. In [7], the Laplacian and gradient masks are used to estimate noise. In [8], the authors present a method to extract the relationship between image intensity and noise variance. In [9][10][11], different techniques to detect noise are provided. In [12,13], noisy pixels are replaced by the mean value of the neighbouring pixels. Methods based on wavelet transformations can be found in [14][15][16]. A filter working similar to a median filter to suppress noise is presented in [17]. A technique based on fuzzy logic is proposed in [18]. The list of references is far from complete, given the intensive research on this topic.
In several of the above mentioned papers, the common steps followed to detect noise are: (i) establish a criterion based on a certain threshold, which most often is an empirical value and (ii) create a noise map. Subsequently, noise is replaced by pixels obtained from a specific transformation.
Currently, the requirements fulfilled to suppress noise in an image are not clearly defined. In [19], the conditions necessary to eliminate noise are: (i) perceptually flat regions must be as smooth as possible, (ii) contours must be preserved, (iii) texture detail must be maintained and (iv) global contrast must remain unchanged.
These points are in conflict, because when noise is removed, global contrast is affected given that noise is replaced by pixels obtained from a smoothed image. Furthermore, edges are also modified notwithstanding whether the smoothed image was filtered by an adaptive transformation. Owing to this situation, in this paper we are going to consider only two aspects that must be fulfilled when denoising an image: (a) modifying image contours as little as possible and (b) the resulting cleaned images must have an improvement in the contrast. The mathematical expressions introduced throughout the paper make use of the following transformations: top-hat by reconstruction [20], internal gradient [21], toggle mappings [22] and the opening by reconstruction [23]. These will be presented in Section 2. The ideas to detect noise were inspired by the proposal in [24], which is briefly presented in Section 2.5. In [24], two interesting things are proposed: (i) a formalisation to detect a threshold P C to identify noise and (ii) noise detection is carried out by means of a contrast measure. The contributions introduced in this paper will be for grey-level images and proposals are presented in Section 3. In Section 3.1, the contrast measure provided in [24] is replaced by a new one in terms of a top-hat by reconstruction transform, also called numerical residue [25]. The new contrast measure involves the image background obtained from a close-open by reconstruction transformation. This proposal gives rise to a toggle mapping to attenuate noise. The toggle mapping uses as primitives the original and the morphological open-close by reconstruction images, which do not create new contours. However, given that the critical point P C represents the mean value defined in [24], this idea is extended to a global parameter for determining when a pixel is noise. The proximity criterion in the toggle mapping is modified and a new one is introduced in Section 3.2 in terms of the top-hat by reconstruction transformation. In Section 3.3, noisy pixels take values in accordance with a rank filter [26] to produce enhanced images with different contrast. In Section 3.4, the mean filter is approximated by morphological transformations, and the toggle mappings proposed so far can be rewritten as purely morphological transformations. In Section 3.5, the top-hat criterion is replaced by the internal gradient operator, and the primitive denoted as α is utilised. The α filter is given in terms of the open-close and close-open by reconstruction transformations. This filter shows a regular performance when compared to the median filter. According to the experiments, two transformations introduced in this paper yield a better performance with respect to the method proposed in [24] to detect noise. To select the transformations producing the best performance, the results obtained from the following indexes are analysed: (i) mean square error (MSE), (ii) peak signal-to-noise ratio (PSNR) and (iii) morphological contour preservation index (MCPI).
Once the two transformations producing better results are detected, one of them is selected to be compared with the following operators reported in the current literature: PDEs [27], wavelets [28], morphological connected rank max opening [29] and connected amoebas [30]. In the comparison process, a set of natural images [31] contaminated with 10% of Gaussian noise and 5% of salt and pepper noise were used. Conclusions are presented in Section 5.

Definitions of some morphological transformations
In mathematical morphology (MM), increasing and idempotent transformations are frequently used. Morphological transformations complying with these properties are known as morphological filters [32]. The basic morphological filters are the morphological opening γ μB ( f )(x) and closing j μB ( f )(x) using a given structuring element μB. In this paper, a square structuring element is employed, where B represents the basic structuring element of size 3 × 3 pixels, which contains its origin. Whereas B is the transposed set with respect to its origin, B = {−x:x [ B}, and μ is a size parameter. The number of elements within a structuring element of size μ is (2μ + 1) 2 . Formally, the morphological opening γ μB ( f )(x) is expressed as follows By duality, the closing j μB ( f )(x) is defined as Here, ∧ is the inf operator. By duality, the morphological dilation is written as δ μB ( f )(x) = [ε μB ( f c )(x)] c .

Opening and closing by reconstruction
Transformations by reconstruction are useful operators introduced in MM. These transformations allow the elimination of undesirable regions without substantially affecting the remaining structures of the image, given that these transformations are built by means of geodesic transformations [23]. The geodesic dilation d 1 f (g)(x) of size one is given by , g represents the marker. The reconstruction transformation for grey-level images is defined as follows When the marker g(x) is equal to the erosion of the original function ε μB ( f )(x), and the geodesic dilation is iterated, the opening by reconstructiong mB (f ) is obtained. This can be written asg By duality, the closing by reconstructionw mB (f ) is expressed asw

Top-hat by reconstruction
The white top-hat transformation is used for detecting peaks of certain height and thickness and it is defined as the arithmetical difference between the original and the morphological opening images, that is, The white top-hat by reconstructionTW mB (f ) is built in a similar way, but using the opening by reconstruction transformation. This connected transformation is defined as follows Connected transformations have the property of preserving the contours of the processed image.

Morphological gradients
The morphological gradient is an edge detector. This transformation is expressed as where f represents the original image, whereas δ μB ( f ) and ε μB ( f ) represent the morphological dilation and erosion size μ, respectively. Other expression to obtain the edges of an image is given below. This transformation is called internal gradient In this paper, the following expression will be considered, μB = μ, to simplify the notation. Also, when μ = 1, one has g m (f )(x) =g(f )(x).

Methodology introduced in the current literature to detect noise
A methodology to identify noise was presented in [24]. In this research, a local analysis is developed considering a window W of 3 × 3 pixels or size μ = 1; however, it can be extended to other sizes of μ. By applying a statistical analysis, the authors detect noise at point x of the grey-level image f if is the contrast probability at point x and n−1 x=1 C(x) considers the eight neighbouring points surrounding point x. C(x) is a local contrast measure where f (x) is the background and represents the mean value of the pixels surrounding x. Also, it was demonstrated that P C takes the value This critical probability represents a mean, and all pixel values markedly different from this quantity are considered as noisy elements.

Proposed method to detect noise
An operator that computes the background in terms of the opening and closing by reconstruction is proposed as follows where b μ is the background of size μ, andg m andw m are the opening and closing by reconstruction size μ, respectively. The background operator in (3) indicates that if the size of the structuring element μ is increased, more maxima and minima will merge. Other expressions for the image background in terms of morphological operators can be found in [33,34]. By replacing (3) in (2), the new contrast measure is rewritten as The parameter P C introduced in [24] can be rewritten as P CM m , which considers the size μ of the structuring element. Then P CM m = 1/ (2m + 1)(2m + 1) − 1 with μ ≠ 0. For example, if μ = 1, P CM m=1 = (1/8) and for μ = 2, The contrast measure in (4) produces a family of ordered transformations, that is, for m 1 ≤ m 2 ≤ · · · ≤ m m and Once the contrast measure C μ (x) has been established along with P CM m , the following toggle mapping is proposed to filter noise wherew andg are the closing and opening by reconstruction size 1, and P(x) , P CM m is a noise criterion. The proposed toggle mapping hwg P CM m not only filters noise but also improves the contrast in the output image without introducing new contours. However, hwg P CM m has the disadvantage of eliminating unconnected narrow regions in which the structuring element does not fit. Notwithstanding this drawback, there are many images in which (5) (3), (4) and (5) using μ = 5. Image in Fig. 1e presents the output image following the procedure explained in [24], where noisy points are replaced by those provided by the median filter of size μ = 5, P C = P CM m=5 = (1/120), and the mean filter f also with a size window μ = 5. Image in Fig. 1e exhibits more smoothness than the image in Fig. 1d together with the elimination of narrow regions.
The output image associated with the operator hwg P CM m has a well-defined contrast, which may be explained as follows. The use of the noise criterion to build (5) allows the classification of the points in the domain of definition of f in two sets: (i) a set S P(x),P CM m (f ) composed by the regions below is a consequence of the noise criterion, P(x) , P CM m , used in (5).

Definition 1:
A denoised image is said to have a well-defined contrast if one can classify its points according to a noise criterion.
It is noteworthy to mention that the toggle mappings proposed in this paper fulfil Definition 1. In the next subsection, a new proposal is introduced which is an extension of the one given in this part.

Noise elimination based on the top-hat transformation
The white top-hat by reconstructionTW m (f ) allows the detection of clear components. Hence, this transformation is an excellent operator to detect pixels with high intensity levels. The criterion to detect noise using the white top-hat by reconstruction can be established by analysing the considerations given in [24]. In that study, the critical probability to detect noise is 1/8 when μ = 1. In other words, the central pixel whose value is above the mean of its neighbours is a noisy pixel. This criterion can be extended to one, that is, convenient for detecting noise in the high intensity levels. Thus, f (x) is not a noisy grey level if whereTW m (f ) represents the mean white top-hat by reconstruction. This noise criterion allows to detect noise only in white components. Alternatively, the complement image must also be processed to filter the dark components using the same criterion. The following toggle mapping is proposed to suppress noise in the foreground To clean noise in the complement image, (7) should be applied The differences between (5) and (6) are: (a) Equation (6) does not use a contrast measure nor a probability criterion; and (b) according to (7), (6) must be applied twice, once in the foreground and once in the complement. On the other hand, (5) is applied only once because the contrast measure detects important changes of intensity between the central pixel and the mean of its neighbours. The noisy central pixel is corrected by the filterwg(f ), that is, if the central pixel is a white pixel, the opening by reconstruction comes into action, otherwise the closing by reconstruction is employed. The filterwg(f ) modifies white and dark components when is applied.

Other proposals for selecting the central pixel
When noisy pixels are detected, the contrast of the image is modified depending on the selection of the central pixel that substitutes noise. For example, if the intention is to obtain high contrast, a suggested central pixel can be obtained from the morphological erosion. Then (6) is rewritten as In Fig. 2, the performance of (8) is illustrated. Images in Figs. 2a, b are smoother than the picture in Fig. 2c. The substitution of the central pixel by the morphological erosion produces more intense contours. To corroborate this situation, compare the images in Figs. 2d-f. Contours were obtained by (1). The erosion used as primitive in (8) is very interesting, because it suggests that the central pixel can take any value inside the window W given by the structuring element μB. If the set of pixels in the structuring element is sorted in ascending way, a rank filter ρ μB,k ( f ) is obtained [26], in which ρ μ,k = 1 ( f ) = ε μ ( f ), where μ is the size of the structuring element, and k represents the number of applied filter. For this research, μ = 1, hence 1 ≤ k ≤ 9. To simplify the notation, let us consider that ρ μ, k ( f ) = ρ k ( f ). Given that the rank filters are ordered, then the following proposed contrast mappings are ordered, that is In this case, the inverted image must also be cleaned to obtain a filtered image. This is expressed as follows The filter k r k T m (f ) maintains the following order However, it is not convenient to change the central pixel for a value higher than the one obtained with the median filter, since the proposals to suppress noise in this study consider that the values of the pixels in a small region given by the size of the structuring element μB are not superior to their mean value. Therefore, the following transformations fulfil such requirement

Alternative approximation to the mean filter
On the other hand, to eliminateTW m (f ) from (9), the mean top-hat by reconstruction can be approximated by other morphological transformation. Consider the following relation [26] The order relation in (10) is true for the opening and closing by reconstruction, that is where f is the mean function andwg(f ) andgw are the alternated filters by reconstruction. The next approximation is carried out from (11) f ≃gw(f ) so that,TW m can be replaced by jT H m (f ) = (gw(TW m (f )) in (6), (8) and (9). For example, (6) can be rewritten as To filter noise in the dark components, the next expression

Noise elimination based on the gradient transformation
The internal gradient defined in (1) can be used as morphological contrast criterion C gi m to detect noise. Consider that Here, a variation in the method to detect noise similar to that defined in Section 3.1 is applied, but now the contrast probability is computed directly on the internal gradient. Let a(x) = (1/2)wg(f )(x) + (1/2)gw(f )(x) be a primitive. A similar primitive without reconstruction transformations was used in [1]. A new contrast mapping is defined as follows where P C gi m (x) is the probability computed on C gi m (x).
Equation (12) has the following advantages: (i) it detects noise efficiently by employing the P C gi m (x) ≤ P CM m criterion; (ii) it is applied only once to filter the image and (iii) the primitive α(x) allows less smoothing than when the open-close by reconstruction is used as primitive. Nevertheless, the elimination of narrow regions remains an issue. In the case that noise is filtered first for the white components and then for the dark ones, the following toggle mapping in terms of the internal gradient is useful. This toggle does not use a contrast measure. Let j gi m (f ) =gw(gi m (f )) and To filter noise for the dark components, the next expression must be applied The performance of (13) is illustrated in Fig. 3.  [24] using the median value to substitute noise taken from a window size μ = 1 f Method proposed in [24] using the α(x) filter to substitute noise taken from a window size μ = 1 g Application of (13) taking as primitive the median filter size μ = 1 h Application of (13) taking as primitive the α(x) filter size μ = 1 i Application of (5) taking as primitive the median filter size μ = 1 j Application of (5) taking as primitive the α(x) filter size μ = 1 k Application of (7) taking as primitive the α(x) filter size μ = 1 l Application of (7) taking as primitive the median filter size μ = 1 PSNR and morphological contour preservation will be used to detect the best transformation to suppress noise.  (4) is extended to measure the contrast as a global measure, which is expressed as follows Fig. 4b  where χ μ represents the contrast measure of each processed image and x m Ref is the contrast measure of the original image. Fig. 5a shows the computed values of MSE for each image presented in Fig. 4. The graph of the MSE values is given in Fig. 5b. The best values of MSE are those nearest to 0.

Peak signal-to-noise ratio (PSNR):
The PSNR values can be observed in Fig. 5a, and its corresponding graph in Fig. 5c. The best PSNR measures are associated with the greatest values.

Morphological contour preservation index (MCPI):
This index is used as a measure to survey the contours of the output images with respect to the edges of the original image. To obtain the MCPI index, it is necessary to compute the internal gradient, which was defined in (1), and the edge preservation parameter (EPP). The EPP is obtained from the convolution (denoted as *) of two kernels of size 3 × 3 with the morphological internal gradient. These kernels allow to detect horizontal, G h , and vertical, G v , changes for each point in the internal gradient. EPP is expressed as follows  Fig. 4 are presented in Fig. 5a and the corresponding graph in Fig. 5d. The best MCPI values are those nearest to 1.
According to the graphs in Figs. 5b, c and d, the images presenting the best characteristics -MCPI nearest to 1, high PSNR values and MSE measure close to 0are the images in Figs. 4i, j and k. In particular, operator in (5) with the median filter size μ = 1 as primitive and associated with the image in Fig. 4i will be used to verify its performance with respect to other transformations reported in the current literature. This transformation is expressed as follows where M μ ( f )(x) represents the median filter.  Three images with the codes 66075, 35008 and 65010 were selected from [31] to compare the performance of (14) with other transformations reported in the literature. The three selected images are presented in Figs. 6O-a, b and c. The original images are contaminated with two classes of noise, zero mean Gaussian with 0.01 variance and 5% of salt and pepper noise. These images are displayed in Figs. 6N-a, b and c and will be used to test our operator. Two transformations, the curvature preserving PDE [27] and the wavelet GSM [28] are applied and the results are presented in Figs. 6P-a, b, c, W-a, b and c. For curvature preserving PDE, the smooth anisotropic function is applied with the following parameters: amplitude 60, sharpness 0.70, anisotropy 0.26, gradient smoothness 0.63, tensor smoothness 0.29, spatial precision 0.80, angular precision 30, value precision 2, iterations 1 and tiles 1. Whereas the wavelet function is used with default parameters defined in the MATLAB code provided freely by the authors. In Figs. 6R-a, b and c, the morphological connected rank max opening [29] with parameters μ = 5 and k = 12 is utilised; this operator is an adaptive transformation. The morphological connected rank max opening has the capacity of eliminating white connected regions of certain size. In this case structures smaller than 12 pixels are suppressed. Images in Figs. 6OP-a, b and c are obtained by applying (14) with μ = 1, whereas those in Figs. 6A-a, b and c employ morphological amoebas [30] to suppress noise. In this paper, amoebas use a window of size μ = 5 and λ = 0.05. Morphological amoebas are also adaptive transformations. In order to elucidate which output image presents a better behaviour, PSNR and structural similarity (SSIM) indexes [35] were computed. These indexes are shown in Tables 1 and 2. In terms of PSNR, our technique outperforms the other algorithms. On the other hand, the SSIM index corresponding to the image in Fig. 6P-a indicates that PDEs transformations have a better performance; however, notice that salt and pepper noise has not been completely eliminated.

Conclusions
At the beginning of this paper the methodology studied in [24] was presented. From this technique, two concepts were exploited: (i) P C , the critical threshold to detect noise and (ii) the contrast measure. When the parameter P CM m is used as proximity criterion in the toggle mappings, noise is detected and filtered in one pass; however, it is necessary to compute a contrast probability. If toggle mappings use the extended P CM m criteria, then to supress noise it is necessary to filter the foreground and the inverted image, as typically occurs in MM.
When the primitives applied to filter the images are the original and the transformations by reconstruction images, no new contours are created, but the output image will be smoothed. According to the experimental results summarised in the graphs of Fig. 5, two transformations proposed in this paper present a better performance when they are compared with the proposal introduced in [24]. These operators are: (i) the method that includes the modification of the contrast measure given in Section 3, and (ii) the methods based on the top-hat transformation as noise criterion.
According to the experiments carried on in Section 4, in order to select the best cleaned image from a set of processed images, notice that, it was necessary to apply three indexes, since the use of only one of them can produce an erroneous selection.
Finally, the toggle mappings built with the top-hat as noise criterion are readily implemented and fast to execute.

Acknowledgments
The author Iván R. Terol-Villalobos would like to thank Diego Rodrigo and Darío T.G. for their great encouragement. This work was funded by the government agency CONACyT-México under the grant 133697.