SALT AND PEPPER NOISE DETECTION BASED ON
NON-LOCAL MEANS
Carlos Junez-Ferreira, Fernando Velasco-Avalos
FIE, Universidad Michoacana de San Nicolás de Hidalgo, Ciudad Universitaria, Morelia, Mexico
Nelio Pastor-Gomez
FIC, Universidad Michoacana de San Nicolás de Hidalgo, Morelia, Mexico
Keywords: Image denoising, Salt and pepper noise, Non-local means, Adaptive median filter.
Abstract: Denoising is an important task inside the image processing area. In this paper, an algorithm for detecting
and suppressing salt and pepper noise is presented. Firstly, the algorithm computes an estimation of the
denoised image by using a variant of the Non-Local Means proposal. This estimation is segmented in order
to detect corrupted pixels avoiding misclassifying pixels with extreme values that belong to objects on the
uncorrupted image. Once pixels are classified, the algorithm performs a suppression step by using an
adaptive median filter. Obtained results show that the implementation of this proposal gives good noise
detection and suppression.
1 INTRODUCTION
Frequently, digital images are corrupted by
undesirable random variations in intensity values,
called noise. The presence of noise is due to several
factors, among which are found the process of
acquisition, compression and transmission of data. A
common type of noise is impulsive noise, known as
salt and pepper. This kind of noise randomly
changes intensities of some pixels to the maximum
(
max
v ) or minimum (
min
v ) values of the intensity
range on the image (Chan et al., 2005).
The median filter has been widely used for
impulsive noise suppression due to its ability to
preserve edges in a better way than weighted
averaging methods. It must be noticed that, median
filter does not insure the edge preservation, mainly
in images with high noise density. Numerous
algorithms based on the median filter have been
presented, as the proposed by Wang & Zhang
(1999), Yuan & Tan (2006), and Chan et al. (2005).
2 IMPULSE NOISE DETECTION
Evidently, good noise detection is essential to carry
out its suppression and to get a better restoration
quality. One way to detect noise is through an
adaptive median filter, as used by Chan et al. (2005),
which is described below.
Let
y
~
the obtained image by applying an
adaptive median filter to an image with salt and
pepper noise
y . Moreover, according to the salt and
pepper noise model, noisy pixels take its values from
the set
{
}
maxmin
,vv . Then, it could be defined the set
of corrupted pixels candidates as
{}
{
}
maxmin,,,,
,,
~
: vvyyyyN
jijijiji
=
(1)
for all
(
)
Aji
, .
Another proposal has been presented by Wang &
Zhang (1999), where the following expression is
used
{
}
TyyyN
jijiji
>=
,,,
~
:
(2)
where
(
)
Aji
, and T is a predefined threshold.
Expression (2) is used iteratively in order to detect
impulse noise.
3 NON-LOCAL MEANS
Buades et al. (2005) proposed the Non-Local Means
344
Junez-Ferreira C., Velasco-Avalos F. and Pastor-Gomez N. (2010).
SALT AND PEPPER NOISE DETECTION BASED ON NON-LOCAL MEANS.
In Proceedings of the 7th International Conference on Informatics in Control, Automation and Robotics, pages 344-347
DOI: 10.5220/0002880703440347
Copyright
c
SciTePress
algorithm, based on the idea that images contain
repeated structures and that averaging these
structures, the noise of an image can be reduced.
Given a discrete image with noise
y the
restored value
nm
y
,
ˆ
, for the pixel at location
()
Anm , , is computed as the weighted average of
all pixels of the image,
=
Aji
ji
nm
jinm
ywy
),(
,
,
,,
ˆ
(3)
where the family of weights
{}
nm
ji
w
,
,
depends on the
similarity between pixels at positions
()
Anm
, and
()
Aji , , and it satisfies the conditions 10
,
,
nm
ji
w
and
=
Aji
nm
ji
w
),(
,
,
1 .
Structural similarity between
ji
y
,
and
nm
y
,
depends on similarity between vectors
)(
, ji
V Ω
and
)(
,nm
V Ω , where
lk,
Ω denotes a fixed size
neighbourhood and centered at pixel
lk
y
,
.
Similarity between above mentioned vectors is
measured by a decreasing function of Euclidean
distance,
2
,,
,
,
)()(
jinm
nm
ji
VVd ΩΩ= . Pixels with
similar neighbourhood to
)(
,nm
V Ω will have large
weights, which are defined as
2
,
,
,
,
,
1
H
d
nm
nm
ji
nm
ji
e
Z
w
=
(4)
where
nm
Z
,
is a normalization constant, and the
parameter H acts as a filtering degree, that is, it
controls the decay of weights as a function of
distances. For implementation purposes, a window
of size
1
W is used to compute the average with a
limited number of neighbours, instead of averaging
all pixels of the image. Also, a window of size
2
W is
used to define the structure of the neighbourhood
and the size of vector
)(
,lk
V Ω .
In general, the Non-Local Means algorithm gives
good results in terms of noise reduction, however,
this does not always happen, especially in images
with high salt and pepper noise level.
4 SALT AND PEPPER NOISE
DETECTION AND
SUPPRESION PROPOSAL
In this work, the Non-Local Means algorithm will be
used to provide a preliminary estimate of the
restored image, with the aim of detecting salt and
pepper noise, even with high density.
In order to consider the presence of objects whose
pixels intensity values are equal to the maximum or
minimum values on image, in other words, black or
white objects in the image without noise, we propose
a segmentation, which is performed by grouping
neighbouring pixels with similar intensity values,
based on a threshold TI.
The purpose of making this segmentation is to
find a partition
S of an image
y
ˆ
on a set of regions,
in such a way that
=
smallbig
RR
y
ˆ
(5)
where
{
}
PRhRR
ssbig
>
=
)(:
, and
(6)
and,
{
}
PRhRR
sssmall
=
)(:
,
(7)
big
R
is the set of regions considered relevant
objects, that is, regions whose number of pixels
represent a percentage of image greater than a
threshold P. Obviously,
small
R is the set of regions
that are, by their size, regarded as details or noise.
The function
)(
s
Rh computes the percentage of the
image that corresponds to a region
s
R . Thus, one
can discriminate between pixels that can be
considered corrupt and those that belong to an
object, although in both cases the pixels intensities
are extreme value.
Considering the above exposed, our proposal to
detect salt and pepper noise can be described, in
general, through the following steps:
1
y
ˆ
=Compute_Estimation( y ,TW,PAR)
2
S=Segmentation(
y
ˆ
,TI)
3
α
=Pixels_Classification( y ,S)
4
x
ˆ
=Noise_Suppression( y
ˆ
, α ,W
min
,W
max
)
where PAR
is a vector containing the parameters H,
W
1
and W
2
.
The preliminary estimate, described in Figure 1,
is performed by calculating the weights of the pixels
in the neighbourhood for a corrupt pixel candidate
according to expression (4), and its estimated value
will be the median value only of intensity values of
pixels with weights greater than a threshold TW. In
this way, only pixels whose structure is similar to
the pixel in question are involved. The median value
SALT AND PEPPER NOISE DETECTION BASED ON NON-LOCAL MEANS
345
Compute_Estimation( y ,TW,PAR
1
)
for each pixel at position (i,j)
if (y
i,j
=v
min
) or (y
i,j
=v
max
)
Compute family of weights
j,i
w
for each weight
j.i
n,m
w
if TWw
j.i
n,m
n,m
yVWVW
end
end
)VW(MEDIANy
ˆ
j,i
else
j,ij,i
yy
ˆ
end
end
return(
y
ˆ
)
Figure 1: Pseudo-code of estimation computing.
Pixels_Clasification(
y ,S)
for each pixel at position (i,j)
if (y
i,j
=v
min
) or (y
i,j
=v
max
)
if (i,j) R
small
1
j,i
α
else
if (y
i,j
j,iy
ˆ
)
1
j,i
α
else
0
j,i
α
end
end
else
0
j,i
α
end
end
return(
α
)
Figure 2: Pseudo-code of classification step.
is used instead of weighted averaging because its
better results with salt and pepper noise.
Subsequently, this estimation will be segmented,
as described above, then, a pixel is considered
corrupt if its intensity value is an extreme value and
the pixel belongs to a region considered irrelevant. If
the pixel belongs to a relevant object and its value
has changed at estimation, this pixel is also
considered corrupted. Figure 2, shows the
classification procedure, where if
0
,
=
ji
α
, the pixel at
position
),( ji is regarded as corrupt and
1
,
=
ji
α
if not.
Once pixels are classified, the algorithm
proceeds to noise reduction, by applying an adaptive
median filter. This kind of filtering considers
geometric closeness in restoration. First, a
neighbourhood for corrupt pixels is defined, then
uncorrupted pixels belonging to the neighbourhood
are stored in a vector, and the central pixel is
replaced by median value of this vector. If the
mentioned vector is empty, the window size is
increased, repeating the procedure. If the size
increases to reach a maximum size of window, the
central pixel value is replaced by the median value
of all pixels in neighbourhood. This procedure is
described in Figure 3.
It can be determined that, the proposed algorithm
is O(N
D
), where N
D
is the number of data.
Noise_Suppression( y
ˆ
, α ,W
min
,W
max
)
for each pixel at position (i,j)
if 1
j,i
α
min
WW
,
0witness
do
φ
VN
for each element in window
j,i
Ω
of size
2
W
if 0
j,i
n,m
=α
n,m
y
ˆ
VNVN
end
end
if
φ
VN
)VN(MEDIANx
ˆ
j,i
1witness
else
2WW
end
while
)0witness(&)WW(
max
=
if
)0witness(&)WW(
max
=>
)Wsizeof(MEDIANx
ˆ
2
maxj,ij,i
Ω
end
else
j,ij,i
y
ˆ
x
ˆ
end
end
return(
x
ˆ
)
Figure 3: Pseudo-code of noise suppression.
5 EXPERIMENTAL RESULTS
Experiments show that results obtained by applying
the described algorithm are very good. The
implementation of the code was made using Matlab
6.5 R13 on a PC 2.20 GHz Core Duo CPU.
The test image (Figure 4) was corrupted with salt
and pepper noise with different densities through
imnoise function of Matlab.
In order to compute the estimation, the values
W
1
=3, W
2
=3, TW=0.10 and H=10 were used. For
segmentation T=0.001 (the intensity values range of
image is [0, 1]), and the value of P depends on the
ICINCO 2010 - 7th International Conference on Informatics in Control, Automation and Robotics
346
(a)
(b)
Figure 4: Image 1, (a) Noisy image (80%), (b) Denoised
image.
maximum size of a region that can be considered
irrelevant, we use P=0.001. For noise reduction we
used W
min
=3 and W
max
=10.
In order to quantify the performance of the detector,
we used the values (Yuan & Tan, 2006)
dg
γγ
/
1
=Γ
and
ng
γ
γ
/
2
=Γ
, where
d
γ
is the number of pixels
detected with the proposed algorithm,
n
γ
is the
number of pixels that are really corrupted and
g
γ
is
the number of detected pixels that are really
corrupted. Tables 1 and 2 show the performance of
our proposal, which is identified as 1, for different
noise densities on Lena image, compared with
algorithm 2 (Chan et al., 2005) and 3 (Wang &
Zhang, 1999). Table 3 shows the performance of the
algorithm for noise reduction measured by PSNR
and UIQI (Wang & Bovik, 2002).
Table 1: Performance of different detectors for Lena
image with a noise density of 20%.
Algorithm
1
Γ
2
Γ Time (s)
1 0.9988 1 17.59
2 0.7922 1 11.66
3 0.9332 0.9529 35.35
Table 2: Performance of different detectors for Lena
image with a noise density of 80%.
Algorithm
1
Γ
2
Γ Time (s)
1 0.9998 1 39.29
2 0.9994 1 26.31
3 0.9293 0.9731 35.20
Table 3: Performance of our noise suppression proposal
for Lena image.
Noise (%) PSNR (dB) UIQI Time (s)
20 41.7821 0.9735 21.06
50 34.9502 0.9105 36.45
80 29.4583 0.7786 52.10
6 CONCLUSIONS
This paper has presented an algorithm for detection
and suppression of salt and pepper noise in digital
images. The obtained results have shown that the
proposed algorithm provides good results in
acceptable time. In future work, we can consider
adapting this algorithm for the suppression of
different types of noise and using it as part of an
image pre-processing step, in order to perform tasks
such as segmentation and object recognition in a
robust way.
REFERENCES
Buades, A., Coll, B., Morel, J. M., 2005. A non-local
algorithm for image denoising. In proc. IEEE
Computer Society Conference on Computer Vision
and Pattern Recognition. Vol. 2, 60-65.
Chan, R. H., Ho, C. W., Nikolova, M., 2005. Salt-and-
Pepper Noise Removal by Median-Type Noise
Detectors and Detail-Preserving Regularization. IEEE
Transactions on Image Processing. Vol. 14(10), 1479-
1485.
Wang, Z., Bovik, A. C., 2002. A universal image quality
index. IEEE Signal Processing Letters. Vol. 9(3), 81-
84.
Wang, Z., Zhang, D., 1999. Progressive Switching Median
Filter for the Removal of Impulse Noise from Highly
Corrupted Images. IEEE Transactions on Circuits and
Systems-II: Analog and Digital Signal Processing.
Vol. 46(1), 78-80.
Yuan, S. Q., Tan, Y. H., 2006. Difference-Type noise
detector for adaptive median filter. IEEE Electronic
Letters. Vol. 42(8).
SALT AND PEPPER NOISE DETECTION BASED ON NON-LOCAL MEANS
347