RECURSIVE MEDIAN 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 signal, 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- smoothing signals. 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 distortion. Re- tence of root signals is a fundamental property of median ®l- cursive median ®lters have stronger noise 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 t 1 t 1 t 1 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 t 1 t 1
+1 t=0
t med
m m m
n;O n +1; ;O n + k ]:
Z (11) (15)
t 1 t 1 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)
t 1 [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;