7th International Scientific and Expert Conference TEAM 2015
Technique, Education, Agriculture & Management
Belgrade, October 15-16, 2015
ADAPTIVE CENTER WEIGHTED MEDIAN FILTER
Vedran Novoselac* and Zlatko Paviฤ
Mechanical Engineering Faculty in Slavonski Brod, J. J. Strossmayer University of Osijek, Croatia
* Corresponding author e-mail: vedran.novoselac@sfsb.hr
Abstract
In this paper, the weighted median is presented
and its propertie distance to center data. This
relation is implemented in the image denoising
filter. In the paper impulse image noise model is
considered. The quality of reconstructed images
provided with proposed filter are measured with
PSNR metric.
Keywords:
Weighted median, image processing, impulse
noise, PSNR
1. Introduction
The weighted medina [1] is a natural extension of
the medina. While the median of data vector ๐ =
[๐ฆ1 , … , ๐ฆ๐ ]๐ , ๐ฆ๐ ∈ ๐น, minimizes the ๐ฟ1 -distance (or
least absolute deviation, LAD), the weighted
median
of
๐ = [๐ฆ1 , … , ๐ฆ๐ ]๐
with
positive
corresponding weight vector ๐ = [๐ค1 , … , ๐ค๐ ]๐ ,
minimizes the weighted ๐ฟ1 -distance
adaptive center weighted median filter (ACWMF) is
constructed and tested on various experimental
images. Proposed algorithm has been developed
under the PSNR criteria.
2. Weighted median and its application
In this section is given a solution of the weighted
median problem [1]. The following theorem proofs
minimization problem of the weighted ๐ฟ1 -distances.
Theorem 1 Let ๐ฆ(1) ≤ โฏ ≤ ๐ฆ(๐) denote the ordered
observation and ๐ค(1) , … , ๐ค(๐) the corresponding
positive weights. Then the weighted median of ๐ =
[๐ฆ1 , … , ๐ฆ๐ ]๐ is med(๐, ๐) = ๐ฆ(๐+1) , where
๐
l = max {โ: ∑ ๐ค(๐)
๐=1
๐ฅ
(2)
๐=1
Proof. Let ๐น: ๐น → ๐น be a function defined as
๐
๐น(๐ฅ) = ∑ ๐ค๐ |๐ฆ๐ − ๐ฅ|.
๐
med(๐, ๐) = argmin ∑ ๐ค๐ |๐ฆ๐ − ๐ฅ|.
๐
1
< ∑ ๐ค๐ }.
2
(3)
๐=1
(1)
Notice that on each interval
๐=1
If ๐ค1 = โฏ = ๐ค๐ = 1, the global minimum is denoted
by med(๐) and called the median of data vector. In
case that the number of observation ๐ is an odd
number (๐ = 2๐ − 1), the distance between center
weight median and center observation ๐ฆ๐ can be
observed. It is shown that distance between center
weight median and ๐ฆ๐ decrease as the ๐ฅ increase.
The weighted median problem is used in many
methods for outlier detection [4] and can be found
in various branches of applied research (robotics,
signal and image processing [2,3], etc.). In image
processing the reconstruction of noise image is a
problem which can be solved with different
methods. For that purpose the class of stack filter
is developed. Standard median filter removes
impulse noise and preserve image edges [2].
However, median filter has detail preserving
difficulties. Weighted median is useful because of
their flexibility. In weighted median filter weights
are used to preserve image details and suppress
noise as well [3]. For that purpose the new filter
represented by thresholds are developed based on
relation between center weight median and
distance to center observation. In that case an
(−∞, ๐ฆ(1) ), [๐ฆ(1) , ๐ฆ(2) ), … , [๐ฆ(๐−1) , ๐ฆ(๐) ), (๐ฆ(1) , ∞),
(4)
๐น is a linear function and slopes of those linear
function are consecutively ๐โ , โ = 0, … , ๐, where
๐
๐
๐0 = − ∑ ๐ค๐ , ๐๐ = ∑ ๐ค๐ ,
๐=1
(5)
๐=1
and for โ = 1, … , ๐ − 1
โ
๐
๐0 = 2 ∑ ๐ค(๐) − ∑ ๐ค๐ = ๐โ−1 + 2๐ค(โ) .
๐=1
(6)
๐=1
Since ๐โ+1 − ๐โ = 2 ๐ค(โ+1) > 0, the sequence
(๐โ ) is increasing and
๐0 < ๐1 < โฏ < 0 ≤ ๐๐+1 < โฏ < ๐๐ .
(7)
It fallows from (7)
that ๐น is decreasing on
(−∞, ๐ฆ(๐+1) ) and increasing on
(๐ฆ(๐+1) , ∞),
therefore the minimum of ๐น is attained for
med(๐, ๐) = ๐ฆ(๐+1) .โ
Vedran Novoselac and Zlatko Paviฤ
1
7th International Scientific and Expert Conference TEAM 2015
Technique, Education, Agriculture & Management
Belgrade, October 15-16, 2015
The next theorem shows relation between the
center weight vector ๐(๐ฅ) = [1, … , ๐ฅ, … ,1]๐ and
|๐ฆ๐ − med(๐(๐ฅ), ๐)|.
Theorem 2 Let ๐ = [๐ฆ1 , … , ๐ฆ๐ ]๐ , ๐ = 2๐ − 1, be
data vector with weight vector
๐(๐ฅ) =
[1, … , ๐ฅ, … ,1]๐ . Then
๐น(๐ฅ) = |๐ฆ๐ − med(๐(๐ฅ), ๐)|,
(8)
is monotonically decreasing on ๐ท๐น = [1, ∞).
Proof. Let 1 ≤ ๐ฅ1 ≤ ๐ฅ2 . If ๐ฆ๐ = ๐ฆ(๐) the function ๐น is
constant an the proof in this case is trivial.
Suppose that ๐′ correspond to position of ๐ฆ๐ in
ordered observation and ๐ ′ ≤ ๐. In this case from
Theorem 1 it is easy to see that med(๐, ๐) = ๐ฆ(๐+1)
where ๐ + 1 ∈ [๐ ′ , ๐]. So it is sufficiently to indicate
that ๐1 ≥ ๐2 where
med(๐(๐ฅ1 ), ๐) = ๐ฆ(๐1 +1) ,
(9)
and
med(๐(๐ฅ2 ), ๐) = ๐ฆ(๐2 +1) .
Situation when center weights are ๐ฅ1 , ๐ฅ2 ≥
1
(10)
1
2
(or
๐ฅ2 ≥ ) indicate that ๐1 + 1 = ๐2 + 1 = ๐′, and
2
statement of theorem is proven. neighborhoods
๐
Observed nontrivial case is when ๐ฅ1 , ๐ฅ2 ≤ , i.e.
2
๐1 + 1, ๐2 + 1 > ๐′. In that situation, according to
Theorem 1, it can be conclude that
๐ − ๐ฅ1 − 1
(11)
๐1 = max {โ: โ <
},
2
and
๐ − ๐ฅ2 − 1
(12)
๐2 = max {โ: โ <
},
2
what directly implies statement of theorem
because ๐ฅ1 ≤ ๐ฅ2 .
Situation when ๐ ′ > ๐ is considered also when
๐
๐ฅ1 , ๐ฅ2 ≤ , otherwise the proof is trivial. Considered
2
that case, it can be conclude that ๐1 + 1, ๐2 + 1 < ๐′,
and it is sufficiently to indicate that ๐1 ≤ ๐2 .
According to Theorem 1 it can be conclude that
๐1 = max {โ: โ <
๐ + ๐ฅ1 − 1
},
2
(13)
๐2 = max {โ: โ <
๐ + ๐ฅ2 − 1
}.
2
(14)
and
From (13) and (14) the theorem is proven, i.e. ๐1 ≤
๐2 , because ๐ฅ1 ≤ ๐ฅ2 .โ
3. Adaptive center weighted median filter
X = [๐ฅ๐๐ ](๐,๐)∈๐บ
โฏ
โฑ
โฏ
๐ฅ0,๐−1
โฎ
].
๐ฅ๐−1,๐−1
(15)
In such a system, the indices (๐, ๐) ∈ ๐บ of the
image matrix correspond to (๐, ๐)-th image intensity
๐ฅ๐๐ . The term grey level is often to refer to the
intensity of monochrome image. In that situation
the matrix elements (image pixels) are integers in
the range [0, … ,255].
Digital images are often corrupted by impulse
noise
during
the
transmission
through
communication channels. It appears as black or
withe impulses on the image. It can be modeled as
follows:
๐๐๐ ,
๐ฆ๐๐= {
๐ฅ๐๐ ,
with probability ๐,
with probability 1 − ๐,
(16)
where X = [๐ฅ๐๐ ](๐,๐)∈๐บ denote original image, Y =
[๐ฆ๐๐ ](๐,๐)∈๐บ noisy image, and ๐ noise ratio. For a
impulse noise ๐๐๐ is probability distribution with
corresponding probability density function
๐๐ ,
๐(๐๐๐ ) = { ๐๐ ,
0,
for ๐๐๐ = ๐,
for ๐๐๐ = ๐ ,
otherwise,
(17)
where ๐๐ + ๐๐ = 1 and ๐๐ , ๐๐ ≥ 0. Most usually
observed situation is when ๐ = 0, ๐ = 255, and
๐๐ = ๐๐ = 0,5.
In image processing, filters are constructed to
process every image element ๐ฆ๐๐ , (๐, ๐) ∈ ๐บ. In that
way reconstructed image ๐ ∗ = [๐ฅ ∗ ๐๐ ](๐,๐)∈๐บ is
constructed. Filter process different neighborhoods
of ๐ฆ๐๐ where 3 × 3 filtering window are most
commonly used for impulse noise. In that case
filtering window is defined as
๐๐๐ = {๐ฆโ๐ : |โ − ๐| ≤ ๐ & |๐ − ๐| ≤ ๐},
(18)
where ๐ denotes size window which is in our case
is ๐ = 3. Filtering window ๐๐๐ can be presented as
a vector ๐๐ = [๐ฆ1 , … , ๐ฆ๐ ]๐ , ๐ = ๐2 , where ๐ = ๐ โ
๐ + ๐ correspond to (๐, ๐)-th position.
In this paper adaptive center weighted median filter
(ACWMF) is proposed. Ideally the filtering should
be applied only to the noisy pixels, and noise-free
pixels should be kept unchanged. So, in filter is
implemented a noise detector. We proposed an
scheme by successfully combining center
weighted median filters [3] and compares them
with the observed pixel value. The output of
proposed ACWMF is obtained by
The digital image can be represented ๐ × ๐ matrix
of the form:
2
๐ฅ0,0
=[ โฎ
๐ฅ๐−1,0
Adaptive Center Weighted Median Filter
7th International Scientific and Expert Conference TEAM 2015
Technique, Education, Agriculture & Management
Belgrade, October 15-16, 2015
๐ฆ๐๐ ,
๐ฅ ∗ ๐๐ = {med(๐(๐ฅ1 ), ๐๐ ),
med(๐(๐ฅ2 ), ๐๐ ),
๐ ≥ ๐1 ,
๐ < ๐2 ,
๐2 ≤ ๐ < ๐1 .
(19)
In proposed method ๐1 and ๐2 are defined as ๐1 =
|๐ฆ๐๐ − med(๐(๐ฅ1 ), ๐๐ )|,
and
๐2 = |๐ฆ๐๐ −
med(๐(๐ฅ2 ), ๐๐ )| respectively, where 1 ≤ ๐ฅ1 ≤ ๐ฅ2 .
The definition of (19) follows the property that ๐1 ≥
๐2 , showed by Theorem 2. Note that threshold ๐
affects the performance of impulse detection. As a
results, impulse noise can be removed while
uncorrupted pixels remain unchanged in order to
preserve the image details. Consequently, the
trade off between suppressing noise and
preserving detail is well balanced. In the following
section we study influence of center weights ๐ฅ1 , ๐ฅ2 ,
and threshold ๐ on the filtering performance using
variety of the test images.
4. Experimental results
range [30,60]. In figure 2 are presented PSNR
filtering results of median filter (MF) [2], and
ACWMF (๐ = 40) for Lena and Mandrill test
images for a noise ratio ๐ ∈ [0,05, 0,5].
(a)
(b)
Figure 2. Filtering results: (a) Lena, (b) Mandrill
Referring to figure 3, one can see that the noise
suppression
and
detail
preservation
are
satisfactorily compromised by using our proposed
method (d) as compared to using standard median
filter (c).
The quality measure of proposed ACWMF has
been experimented with center weights ๐ฅ1 = 1 and
๐ฅ2 = 2. The measures are provided via PSNR
(Peak Signal-to-Noise Ratio) metric defined as
PSNR = 20 log10
255
√MSE
,
(20)
where MSE (Mean Squared Error) is defined as
MSE =
๐−1
∗
2
∑๐−1
๐=0 ∑๐=0 (๐ฅ๐๐ − ๐ฅ ๐๐ )
๐×๐
(a)
(b)
(c)
(d)
(21)
.
PSNR quality measure is appropriate for insight of
impulse reducing because of its robust properties
to outliers [4]. The PSNR via threshold ๐ is
graphically presented in figure 1 for 256 × 256 test
images Lena and Mandrill corrupted with impulse
noise ๐ = 0,2.
.
Figure 3. Results of filtering for: (a) original, (b)
noisy image (๐ = 0,2), (c) MF, (d) ACWMF
5. Conclusion
Figure 1. Results of PSNR via threshold ๐
It can be seen that the PSNR performance is
significantly improved by using threshold ๐ in the
In this work a new median filter ACWMF is
introduced. By incorporating the weighted median
into an impulse noise detection framework is
formed for effectively reducing impulse noise while
preserving image details. Given a specified
threshold ๐ the output of our proposed ACWMF
may correspond to one of three possible states,
namely the origin pixel value (i.e., the pixel is
noise-free), or one of the center weighted output.
Vedran Novoselac and Zlatko Paviฤ
3
7th International Scientific and Expert Conference TEAM 2015
Technique, Education, Agriculture & Management
Belgrade, October 15-16, 2015
The proposed methodology remains applicable to
adjust center weights ๐ฅ1 , ๐ฅ2 , and threshold ๐
according to different noise ratio ๐. In addition, the
proposed filter present a quite stable performance
over a wide variety of image.
[2]
[3]
6. References
[1]
4
C. Gurwitz, “Weighted median algorithms for
๐ฟ1
approximation”,
BIT
Numerical
Mathematics 12(2002), 524-560.
[4]
V. Novoselac, S. Rimac-Drlje, “Svojstva I
primjena
aritmetiฤke
sredine”,
Osjeฤki
matematiฤki list, 14(2014), 1;51-67.
V. Novoselac, B. Zovko-Cihlar, “Image Noise
Removal
by
Vector
Median
Filter”,
Proceedings ELMAR-2012, Croatian Society
Electronics in Marine-ELMAR, 2012, 57-62.
P. J. Rousseeuw, A. M. Leroy, “Robust
Regression and Outlier Detection”, Whiley,
New
York,
2003.
Adaptive Center Weighted Median Filter