RECURSIVE FILTERING WITH PARTIAL REPLACES

Adrian Burian and Pauli Kuosmanen

Signal Processing Laboratory, Digital Media Institute Tampere University of Technology PO Box 553, FIN-33101, Tampere, Finland E-mail: burian, pqo @cs.tut.®

ABSTRACT To be able to ®lter the outmost input sample, when parts of the ®lter's window fall outsidethe input , the input sig- The median ®lter is a special case of nonlinear ®lter used for nal is appended to the required size by replicating the out- . Since the output of the median ®lter is most input sample as many times as needed. This is the non- always one of the input samples, it is conceivable that cer- recursive median ®lter. If the point X(n) is replaced with the tain signals could pass through the median ®lter unaltered. output of the median ®lter before shifting the window to the These signals, invariant to further passes of the median ®l- next position, we obtain the recursive median ®lter. The out- ter, de®ne the signature of a ®lter and are referred to as root put of the recursive ®lter is given by: signals. This represents the convergence property of median

®lters. The convergence behavior of different schemes of re-

n= [Y n k ; :::; Y n 1;Xn; :::; X n + k ]: Y med cursive median ®lters, and algorithms for image processing (2) using these ®lters will be studied. Recursive median ®lters use also previously ®ltered val- ues as their inputs. In this case the ®ltering operation is per- 1. INTRODUCTION formed 'in-place', so that the output of the ®lter replaces the Since Tuckey suggested thestandard median ®lter for smooth- old input value, before the ®lter window is moved to the next ing statistical time series [1], this concept has been widely position. With the same amount of operations recursive ®l- studied. By repeating the median ®ltering, the root signal, ters can usually providebetter smoothingcapability than non- which is invariant to further ®ltering, is found. The exis- recursive ®lters, at the expense of increased . Re- tence of root signals is a fundamental property of median ®l- cursive median ®lters have stronger attenuation capa- ter, used in characterizing these nonlinear ®lters. bilities than their nonrecursive version, and a faster conver- Frequency analysis and impulse response have no mean- gence. In [6] simple proofs of the convergence properties ing in median and recursive median ®ltering: the impulse re- of median ®lters and the idempotent property (reduction to sponse of a recursive median ®lter is zero. As a result, new a root after one pass) of recursive median ®lters are given.

tools had to be developed to analyze and characterize the be- An upper bound of the number of ®lter passes for median

L 2=2 havior of these nonlinear ®lters, deterministically and statis- ®ltering a ®nite length signal to a root is  ,whereL tically [2], [3], [4]. By associating the nonlinear operation of is the length of the input sequence. This bound is indepen-

median ®ltering with a linear cost function, in [5] was shown dent of the window width of the ®lter. A more tight bound

L 2=[2k + 2] N =2k +1 that median ®ltering is an optimization process in which a is 3 ,where is the ®lter's two-term cost function is minimized. window width. To compute the outputof a 1-D median ®lter, an odd num- For image processing applications, two-dimensionalme- ber of sample values are ranked, and the median value is used dian ®lters have been used with success. In [7] a new ap-

proach for designing the recursive median ®lter for image = as the ®lter output. If the ®lter's window length is N

processing applications was introduced. The original sig-

k +1 2 , the ®ltering procedure is given by: nal replaces the output of the previous pass in the middle of

the operation window. The convergence of this improved

n= [X n k ; :::; X n; :::;Xn + k ]; Y med (1) recursive median ®lter within a ®nite number of iterations was proven. This new scheme of recursive median ®lter pro- where X(n) and Y(n) are the input and the output sequences, vides an improved MSE performance over the standard re-

respectively. It is reasonable to assume that the signal is of cursive median ®lter. In this paper we further investigate the

0 X L 1 ®nite length, consisting of samples from X to . possibility of using partial replaces of the old input value at the ®lter's output, before moving the window to the next po- 3. THRESHOLD DECOMPOSITION sition. We show that even better MSE performances could be attained by different recursive median ®ltering schemes. In [9] a powerful tool called threshold decomposition for an- Proofs of the convergence of these recursive median ®ltering alyzing rank order based ®lters was introduced. Using this schemes are also given. technique, the analysis of these ®lters is reduced to studying their effects on binary signals. The importance of the thresh- old decomposition arises from the fact that binary signalsare

2. CENTER WEIGHTED MEDIAN FILTERS much easier to analyze than multi-valued signals.

X ng Threshold decomposition of a signal vector f M-

An immediate generalization of the median ®lter and a ma-

 X i < valued, where the samples are integer-valued, 0

jor subclass of stack ®lters are the weighted median (WM)

;0  i< L

M means decomposing it into M-1 binary sig-

2 M 1

®lters [6], [8]. The standard median ®lter has a better noise 1

n;X n; :::; X n nal vectors X , according to the attenuation than any WM ®lter, regardless of the noise dis- following rule:

tribution. But, in order to preserve small details, WM ®lters



1 X n  m m

can be the solution. m if

= T X n =

X (6)

0

=2k +1

The output of the WM ®lter of window size N otherwise.

w ; :::w

k k associated with the integer weights is given by: This thresholding scheme can be applied to any signal

that is quantized to a ®nite number of arbitrary signals. The

Y n= [w X n k ;  ; k med

originalmulti-valuedsignal samples X(n) can be reconstruc-

w X 0;  ;w X n + k ]; k 0 (3)

ted from the threshold levels by adding them:

M 1

where the symbol  is used to denote duplication, i.e.,

X

m

n= X n:

X (7)

nx = x;  ;x: =1

(4) m

| {z }

n times Applying a recursive median ®lter to an M-valued sig- nal is equivalent to decomposition the signal to M-1 binary Center weighted median (CWM) ®lters are a subclass of threshold signals, ®ltering each binary signal separately with WM ®lters which combines the simplicity of median ®lters the corresponding binary recursive median ®lter, and then with some of the design freedom of WM ®lters. For these ®l- reversing the decomposition.

ters only the center sample in the window has a weight larger m

g f X n g

The binary sequence f0, 1 of is transferred m

than one. All other weights are equal to one. The CWM m

g f Z n g Z n= into f-1, 1 binary sequence of by

®lters are the simplest WM ®lters and the easiest to be de- m

X n 1 2 . For the recursive median ®ltering of a binary

signed and implemented. A CWM ®lter of window width m

Z ng

sequence f , the output of the ®lter is given by:

=2k +1

N is de®ned as:



+1 S n  0

m if

p

n=

O (8)

n = [X n k ;  ;pX n;  ;Xn + k ]:

Y med 1 otherwise, (5)

where

k + p

After the center is weighted, the ®lter is effectively 2

N

X

p =2m 1

long, with smaller than or equal to k (otherwise m

Z n + j  : n= S (9)

the ®lter would be reduced to the identity ®lter). Different

j =N

p = m = values of p produce different CWM ®lters. When

1 the median ®lter is obtained, which has the convergence

4. DIFFERENT RECURSIVE MEDIAN FILTERING

= k k>1 property. When m , it has been shown that when , SCHEMES the resulting 1-D ®lter is idempotent. A CWM ®lter is completely speci®ed by two parame- It is known that in the case of 2-D signals the recursive me- ters: the window size and the center weight. In general, the dian ®lters are not necessarily idempotent [3]. Thus, in order longer the window size of a CWM ®lter, the better noise at- to ®nd the root signal, it is necessary to apply the recursive tenuation ability the ®lter has. CWM ®lter can be designed median ®lter iteratively. For the recursive median ®lter, at to possess good noise attenuation and preserve small details. each iteration for every point of the image we have to com- In contrast to recursive median ®lters, which are idem- pute the output of the ®lter:

potent, the recursive WM ®lters usually are not. All the re-

m m m m

O [O n= n k ; :::O n; :::; O n + k ];

cursive CWM ®lters corresponding to a WM ®lter make an med 

t t1 t1 t1 arbitrary input signal to converge to a root signal. (10)

j 2 2k

where the subscript t represents the iteration index. The re- Notice that cannot take values greater than ;other- 2=1 cursive median ®ltering is a sequential process and the noise wise, the recursive process became meaningless. If j in¯uence at his output will be accumulated. To alleviate such the only replacement takes place in the middle of the win-

an undesirable effect it may be useful to encourage the ®lter dow of the ®lter. The equation (11) is obtained.

2=2k output to resemble the original signal. The recursive median For the other extreme case j , all values except the

®ltering is an optimization operation in which the output of middle of the window of the ®lter are replaced with the orig-

O n

the ®lter is always set to the minimum of a cost function of inal signal. At the second stage, the value for i will the output state of the ®lter [5]. The ®rst recursive median be zero, even in the 2-D case, so the obtained ®lter structure ®ltering scheme is obtained when the output of the ®lter at is idempotent. This appears because at the second stage we

each iteration for every point of the image is computed with: have:

m m m

O n= [O n k ;  ;O n 1;

n=O n= [Z n k ;  ;Zn + k ]: med O

t t1 t1

+1 t=0

t med

m m m

n;O n +1;  ;O n + k ]:

Z (11) (15)

t1 t1 So, in this case, instead of using the output of the previous In this case, the ®ltering scheme is given by:

pass, the value from the middle of the window of the ®lter

m m m

n= [Z n k ;  ;Z n 1; O med

is replaced by the original signal. The obtained ®lter is con- t

m m m

O n;Z n +1;  ;Z n + k ]:

vergent to a root signal within a ®nite number of iterations  (16)

t1 [7]. This approach is extended by choosing different positions 5. EXPERIMENTAL RESULTS and several points inside the ®lter's window to be replaced by the original signal, instead of the outputs of the previous In order to objectively evaluate the performances of these passes. At each step of the ®ltering process, the following new ®ltering schemes, we have used the Lena image cor-

function is minimized: rupted by impulsive noise. The image considered contained

X

m m

m 256x256 pixel values with 8 bits resolution per pixel. In all

O n = O nO n + j 1

E cases, a 3x3 window was used and the threshold decompo-

j 1

X sition technique was applied. The scanning order was line

m m

O nZ n + j 2;

(12) by line. The results were similar when a column by column 2 j scanning was used.

For the simulations we have considered ®ve different ®l-

1+j 2=2k +1 j 2 where j and represents the number of the points from the original signal that replace the values tering schemes for recursive median and CWM ®lters. In all from the ®lter's window. The ®rst term gives a measure of plots with continuous linewithout markers the traditionalre- the smoothness of the ®ltering process, and the second one cursive median and CWM ®lters were represented. The ®l- measures the discrepancy between the ®lter output and the tering scheme given by (11) is marked with a circle and the original signal. one given by (16) with a star. An intermediate simulation, In the case of the recursive median ®lter, each point of which replaces all the corners of the window of the ®lter with the signal is sequentially visited and the output is updated the original signal is marked with a cross. In order to elim- before moving to the next position. For the whole process, inate as much as possible the discrepancy between the ®lter the following function will be minimized: output and the original signal, the positions of the replace-

ments were varied during the ®ltering process, depending on

L X

X the actual local value of the corruption. The results for this

m m

= O nO n + j 1

E simulation are marked with a triangle. The best results were

n=1 1

j obtained in this case.

L X

X Figure1 presents the computed Mean Square Error (MSE)

m m

nZ n + j 2:

O (13) and Mean Absolute Error (MAE) for different recursive me-

n=1 2 j dian ®ltering schemes. In Figure 2 the computed MSE and

Because the process is sequential and at any time only one MAE for the same recursive median ®ltering schemes, but

p =3 output is changed, the changes of the function E from one with a central weight of value are presented. 'global' step to another are given by:

m 6. CONCLUSIONS

E =O nS n:

 (14) E The value of  is less than or equal to zero (from (8)), so In this paper some recursive median ®ltering schemes for

after a ®nite number of iterations, E will reach its minimum image processing were introduced. The convergence prop- and the ®ltered signal will be reduced to a root. erties of these ®ltering schemes were studied. The results 200 500

400 150

300 100 MSE MSE 200

50 100

0 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0 0.05 0.1 0.15 0.2 0.25 0.3 % corruption % corruption

5 6

5 4

4 3 MAE MAE 3

2 2

1 1 0 0.05 0.1 0.15 0.2 0.25 0.3 0 0.05 0.1 0.15 0.2 0.25 0.3 % corruption % corruption

Figure 1: Performance evaluation results. Figure 2: Performance evaluation results for CWM. of the simulations illustrate the improving of the MSE and [6] B. Zeng, ºConvergence Properties of Median and MAE performances over the traditional methods. Weighted Median Filtersº, IEEE Trans. on Signal Pro- cessing, vol. 42, no. 12, pp. 3515-3519, Dec. 1994.

7. REFERENCES [7] G. Qiu, ºAn Improved Recursive Median Filtering Scheme for Image Processingº, IEEE Trans. on Image Processing, vol. 5, no. 4, pp. 646-648, April 1996. [1] J.W. Tukey, ºNonlinear (NonSuperposable) Methods for Smoothing Dataº, Cong. Rec. EASCON'74, pp. [8] O. Yli-Harja, J. Astola, Y. Neuvo, ºAnalysis of the 673, 1974. Properties of Median and Weighted Median Filters us- ing Threshold Logic and Stack Filter Representationº, [2] J.P. Fitch, E.J. Coyle, N.L. Gallagher Jr., ºRoot Proper- IEEE Trans. on Acoustic, Speech and Signal Process- ties and Convergence Rates of Median Filtersº, IEEE ing, vol. ASSP-39, no. 2, pp. 395-410, Feb. 1991. Trans. on Acoustic, Speech and SignalProcessing, vol. ASSP-33, no. 1, pp. 230-239, Feb. 1985. [9] J.P. Fitch, E.J. Coyle, N.L. Gallagher Jr., ºMedian Fil- tering by Threshold Decompositionº, IEEE Trans. on [3] T.A. Nodes, N.L. Gallagher Jr., ºTwo-Dimensional Acoustic, Speech and , vol. ASSP- Root Structures and Convergence Properties of the 32, no. 6, pp. 1183-1188, Dec. 1984. Separable Median Filterº, IEEE Trans. on Acoustic, Speech and Signal Processing, vol. ASSP-31, no. 6, pp. 1350-1365, Dec. 1983.

[4] T.A. Nodes, N.L. Gallagher Jr., ºMedian Filters: Some Modi®cations and Their Propertiesº, IEEE Trans. on Acoustic, Speech and Signal Processing, vol. ASSP- 30, no. 5, pp. 739-746, Oct. 1982.

[5] G. Qiu, ºFunctional Optimization Properties of Me- dian Filteringº, IEEE Signal Processing Letters, vol. 1, no. 4, pp. 64-66, April 1994.