Partition Fuzzy Median Filter for Image Restoration

In this paper, a novel adaptive median filter, called the partition fuzzy is proposed. The proposed filter achieves its effect through a summation of the weighted output of the median filter and the related weighted input signal. The weights are set in accordance with the fuzzy rules. In order to design this weight function, a method to partition of observation vector space and a learning approach are proposed so that the mean square error of the filter output can be minimum. Based on constrained least mean square algorithm, an iterative learning procedure is derived and its convergence property is investigated. As details, extensive experimental results demonstrate that the proposed filter outperforms the other median-based filters in literature.


Introduction
Images are often corrupted by impulse noise due to errors generated in noisy sensors or communication channels. It is important to eliminate noise in the images before some subsequent processing, such as edge detection, image segmentation and object recognition. For this purpose, many approaches have been proposed [1]. In the past two decades, median-based filters have attracted much attention because of their simplicity and their capability of preserving image edges [1][2][3][4]. Nevertheless, because the typical median filters are implemented uniformly across the image, they tend to modify both noise pixels and undisturbed good pixels. To avoid the damage of good pixels, the switching scheme is introduced by some recently published works [3][4][5][6][7].
Digital images are often destroyed by impulse noises due to imperfect communications or noisy channels. Many nonlinear filters are suggested to delete the impulse noises and increase the quality of improvement that has led to better results than the linear filters [8]. The median filter is a well-known nonlinear filter that shows effective performance to weaken impulse noises despite its simple structure. Nevertheless, it produces blurred details and often destroys the edges when filtering. It often destroys the shape of the major signal that is not destroyed by the noise. Various filters are suggested to improve the quality of the median filter. Centre-weighted median (CWM) filter is a nonlinear median filter repeating the central pixel of the window even times in an image sampling window and then calculates the median [9]. The more the number of the repeat is, more details are kept CONTACT Alireza Rezaee arrezaee@ut.ac.ir and less noise is deleted. In TSM filter, decision is made based on a threshold value [10]. According to the threshold value, the value of the output pixel in any window will be one of the median values, the central pixel or the value from the CWM filter. The drawback of TSM is finding the optimal threshold. Overall, the threshold function is obtained through costly experiments. In addition, although hard switching ideas may work well for the impulses with constant values, they work weakly for similar random values and vice versa. Fuzzy median filters are controlled by fuzzy rules and judge the probability of the existence of noise [11]. The process of learning is performed by the rules trained on a reference image.
Since the values of the parameters of the membership function depend on the reference image, some positions may remain untrained. In other words, the generalisability is weak. The idea of the regional filter is examined looking at the decrease of the Gaussian noise and has led to a position independent linear filter [12]. In this article, the regional median filter is examined based on training fuzzy rules. PFM filter regionalises the observation space through scalar quantisation according to the fuzzy rules. The optimal weight is obtained by training the filter on a reference image using LMS algorithm. If the reference image is suitable in the training stage, the filter shows a good resistance to the variety of the existence of the impulse noise. In Section 2, the basic concepts are mentioned. In the third section, the details of designing PFM filter are described. In Section 4, the concept of optimising the weights is described. In Section 5, the results and comparisons are examined and finally, in Section 6, conclusions are presented.

The Basic Concepts
Before introducing PFM filter, some notations are introduced. Let X be a two-dimensional H × W image as follows: where H and W are the height and the width of the image, respectively, and x ij is the pixel value of X at the position (i,j). A filter window with N = (2τ + 1) 2 = 2n + 1 covers the image X at the position (i,j) to provide the observation sample matrix w ij (Equation (2)): where 1 ≤ i ≤ H and 1 ≤ j ≤ W. The value of the central pixel of the filter window w ij is x ij . For simplicity, the w ij matrix can be shown as Equation (3) in one-dimensional form: The subscript ij can be replaced by a scalar working subscript Equation (4), i.e. k = (i − 1) × w + j: Then, the central pixel will be x n+1 (k). The observation sample vector x(k) centred at k can be rewritten as Equation (5): Then, x 0 (k) will be the central value of a vector located at k. The common output value of a median filter at the position k is given as Equation (6): where MED means to get the median.

Designing PFM Filter
Median filters belong to the class of nonlinear filters that have been proven very useful for impulse noise suppression. Filters of this class have been subject to growing interest since the discovery of the standard median (SM) filters by Turkey [12] who applied it to the smoothing of statistical data. Pratt [13] was the first to use median filters in image processing. However, median filters are accustomed in replacing pixels which are undisturbed by the noise, thereby causing artefacts including edge jitter and streaking [14].
Modified median-based filters, which retain a rank order structure have been enhanced to eliminate these deficiencies. One of the earliest contributions is the weighted median (WM) filter [15,16], which gives more weight to some pixels within the window than others. It emphasises or de-emphasises specific input samples, because in most applications, not all samples are equally important. The special case of the WM filter is the CWM filters [17], which gives more weight only to the central value of the window.
The major structure of PFM filter is based on fuzzy rules that are shown in Figure 1. This structure includes 3 parts: the median filter, the set of fuzzy rules and decision making about the existence of noise. In Section 3.1, the foundations of fuzzy rules-based PFM filter is described. In Section 3.2, the process of producing fuzzy rules is introduced. In Section 3.3, the method of the regionalisation of the observation vector space is described that includes linguistic variables expressing the fuzzy rules, and in Section 3.4, the details of the way of determining the membership functions of PFM filter are presented.

The Principles of Fuzzy Rules -Based PFM Filter
PFM filter is based on the median filter and fuzzy rules. Because fuzzy set theory has the potential capability to efficiently represent input/output relationships of dynamic systems, this theory has gained popularity, especially in pattern recognition and computer vision applications. [18] The output value y(k) of the filter at the pixel being processed x(k) is determined as Equation (7) (Figure 1): The PFM filter affects by the weighted sum of the input and output signals of the median filter. α(k) denotes the membership function and determines how much impulse noise is included at the pixel x(k). To judge whether there is an impulse noise at the entrance position x(k) or not, the membership function α(k) must take a continuous value between 0 and 1 according to the fuzzy rules. Therefore, the major contribution of PFM filter is how to make decision about the membership function at the pixel x(k).

Producing Fuzzy Rules for PFM Filter
Yang and Tou applied heuristic fuzzy rules to improve the performance of the traditional multilevel median filter. Noise filtering can be viewed as replacing the gray-level value of every pixel in the image with a new value depending on the local context [19]. Fuzzy techniques have already been applied in several domains of image processing (e.g. filtering, interpolation, and morphology), and have numerous practical applications (e.g. in industrial and medical image processing). Already several fuzzy filters for noise reduction have been developed, e.g. the well-known FIREfilter from [20] and [21], the weighted fuzzy mean filter from [22] and [23], and the iterative fuzzy control-based filter from [24]. A set of neighbour pixels is chosen to process any pixel of the noisy image. Generally, the domain of most impulse noises is more significant than the signal's variations. Therefore, we define the following two variables to produce the fuzzy rules: So that there is: where x c1 and x c2 are chosen in a way that their values are the closest values to x(k) at the window w(k). According to the definition 1, the following fuzzy rule is used as if-then-else to judge the existence of noise.
Rule A: base on definition 1 if u(k) is large, then it is assumed that there is an impulse noise, else it is assumed that no impulse noise exists.
If we only use u(k) to judge the existence of noise, it will be hard to separate the impulse noises completely. Other rules must be also added to improve the performance of the filter. According to the definition of v(k), the rule B can be also drawn: Rule B: base on definition 2 if v(k) is large, then it is assumed that there is an impulse noise, else it is assumed that no impulse noise exists.
According to the concept of entropy in the image analysis, the rules C and D can be drawn to determine whether the pixel x(k) is noisy or not: Definition 3: for a central pixel at the window of a vector with the magnitude 2n+1, the contrast contribution s i (k) is defined as Equation (11): wherex(k) is the average gray areas at the filter window w(k) and i is the gradient area.
Definition 4: the probability of the local contrast at the position k and at the window w(k) (p i (k)) is defined as Equations (12) or (13): Or p j (k) = Definition 5: The entropy of the local contrast is defined as Equation (14): A pixel is considered as a noise according to its effective contribution to the entropy of the local contrast when its correlated local contrast is very different from its neighbours. Now for simplicity, we use the symbol p(k) instead of p 0 (k) and express the rule C based on the probability of the local contrast p(k): Rule C: base on definitions 3 and 4 if p(k) is large, then it is assumed that there is an impulse noise, else it is assumed that no impulse noise exists.
Similar to the conditions of the rule B, q(k) is defined as Equations (15) or (16): so that where p d1 (k) and p d2 (k) are chosen in a way that the probability of the local contrast of the pixels at the filter window w(k) is the closest value to p 0 (k) among its adjacent pixels. Therefore, the rule D can be drawn as follows: Rule D: if q(k) is large, then it is assumed that there is an impulse noise, else it is assumed that no impulse noise exists.
According to the knowledge of the experts of this field, Table 1 shows the combination of the decision making rules based on the linguistic variables u(k), v(k), p(k) and q(k) and α(k) takes the values of the fuzzy set {very high, very low, low, medium, high} from the natural language according to the values of the variables. According to Table 1, the treatment of the median filter detection can be expressed by 16 combinations of the rules A-D as follows: The first rule: is HIGH Other rules are listed in Table 1. In these 16 fuzzy rules, 7 fuzzy sets can be expressed by one-dimensional membership functions, including large, small, very high, high, medium, low and very low. Providing these membership functions is hard in practice. For solving this problem, a method is introduced to determine the membership functions based on the segmentation of the observation space in the following section.

Segmentation of the Observation Space
For segmenting the observation space, the observation vector is taken according to four linguistic variables including u(k), v(k), p(k) and q(k) as Equation (17): A region is defined in a way that the observation vector space S, the subset R 4 , is divided into a set of M pair wise-inconsistent blocks called 1 , 2 , . . . , M in Equation (18): Overall, the classifier c(·) can in different ways determine to which block the vector O(k) belongs. For simplicity and efficiency of the calculations, scalar quantiser is used to design PFM filter. The quantisation includes the coding and decoding stages. The coding process divides the distance of the values from 0 to 255 in a way that any scalar component O d (k) ∈ {u(k), v(k), p(k), q(k)} belongs to one of the five distances shown in Figure 2.
The decoding process receives the input value O d (k) and produces an output word in terms of its distance. When the retrieval values j 1 , j 2 , j 3 and j 4 are related to O(k) in order of the components u(k), v(k), p(k) and q(k), the vector Z i (k) = (j 1 , j 2 , j 3 , j 4 ) will be described as c(O(k)) = i, i ∈ {1, 2, . . . , M}. Any unique vector Z i (k) defines a certain block i . Therefore, the observation vector space includes M unique blocks whose collection is the observation vector space S. This regionalisation can be applied as a four-dimensional array A as According to Figure 2 where the quantisation distances are divided into 5 distances, the total number of blocks will be M = 5 4 = 625. Despite the computational simplicity, PFM filter applied by scalar classifier is resistant to every impulse noise.

Adjusting the Membership Functions of PFM Filter
According to the regionalisation of the observation vector space, the pixel's membership function x(k) can be expressed by α i (k), i = 1, 2, . . . , M. For the output value of the filter to be closest to the major signal, the weight of α i (k) corresponding to the block i is modified by LMS method as Equation (20) [1]: where η i is the rate of learning, e(k) is the physical output error and t is the point of time when the pixel x(k) is processed. When the next pixel x(k) is classified in the ith block, the point of time will be t+1. For any α i (k) related to the block i , the value of α i (k) is updated repetitively by Reference [22]. After α i (k) is converged enough, the value of α i (k) will be the optimal value that leads to the least mean squares error. The convergence condition of the relation (18) is as Equation (21) [1]: After finding the optimal α i (k), the output of PFM filter is determined as Equation (22): The existence of i means that the pixel x(k) is classified inside the block i , where i is determined by the classifier c(·). The value of α i (k) is a continuous value between 0 and 1. For any block i , there is a specific filtration. The block of the diagram of the performance of the fuzzy median filter based on regionalisation is shown in Figure 3. The procedure of the performance of PFM filter is as follows. First, the conventional median filter m(k) and the observation vector O(k) are computed. Then using the function c(O(k)), the ith block is determined for any input data x(k). Then, the value of α i (k) related to the block i is drawn. Finally, the output of y(k) is computed using the relation (24).

Experimental Results
Various experiments are carried out to evaluate the performance of PFM filter. For these experiments, the test images with the dimensions 512 × 512 are used. PSNR and MAE are two criteria to evaluate and compare the performance of the filters in Equations (23) and (24): where 255 is the maximum gray areas of the image, d(k) is the desirable output value and y(k) is the physical output. MAE is a quantitative measurement to evaluate the areas of the edges and the details kept. Nevertheless, quantitative measurements can be misleading. So the visual measurements can be also used. In our experiments, the reference images are destroyed by impulse noises with the probability p, that is shown in Equation (25): where n(k) denotes the image with the impulse noise and the rate of p and f (k) denotes the non-noisy pixels. There are two types of impulse noises: constant value impulse noise and random value impulse noise. Constant value impulse noise takes one of the values of 1 or 255 with the probability p/2; while the random value impulse noise takes a random value from 0 to 255 with the probability p uniformly. The optimal weights α i (k) retrieving the fuzzy rules are obtained in the training stage by a reference image. If a block is not trained because it was not in any input observation vector, the performance of the restoration is affected. PFM filter will be more effective than other median filters due to its generalisability. In addition, its performance is not strongly dependent on the training reference image. As the first experiment, Lena image was destroyed by Poisson noise and then, it was restored by median and PFM filters. As it is seen in Figure 4, the image seems blurred when it is restored using the median filter, while it has more details when it is restored using PFM filter.  The PSNR value from the median and PFM filters is 25.7074 and 29.5822 dB, respectively. In the second experiment, the performance of PFM filter is compared with that of the standard median filter (MED), CWM filter and TSM filter. The results of this comparison are presented in Table 2. As it is seen, PFM filter shows better performance to delete both types of impulse noises.

Conclusions
In this article, an adaptive median filter was introduced to delete the noise from the images. In this filter, any pixel is classified inside one of M inconsistent blocks and the equivalent trained weight α i (k) is extracted and applied. The classifier is based on the fuzzy sets related to the fuzzy rules. This classifier produces the observation vector space. The optimal coefficients of the filter are extracted by LMS algorithm. Experiments show that PFM filter shows better performance to delete the noise and keep the details of the image than other median filters, and in addition to being resistant, it can increase the quality of the image.