Smoothing Techniques in Image Processing
Smoothing Techniques in Image Processing
Processing
Introduction
Briefreview of linear operators
Linear image smoothing techniques
Nonlinear image smoothing techniques
Introduction
Frequency spectrum
Statistical properties
Brief Review of Linear Operators
[Pratt 1991]
Convolution sum
Brief Review of Linear Operators
h22 h21 h20
L-1
h12 h11 h10 2
H h02 h01 h0
L-1
2 h22 h21 h20 Geometrical
0
h12 h11 h10
G
L-1
2
L-1 h22 h21 h20
h02 h01 h0
0
interpretation
h12 h11 h10
2
h02 h01 h0 of 2D
F
0
N-
L+1
convolution
N
N+L-1
Matrix formulation
t Af
Unitary transform
1
A A *T
Separable transform
T A C FA T
R
Transform is invertible
f A *T t A *T Af If
Brief Review of Linear Operators
0, k l
Inner product and energy are conserved
|| t || 2 t *T t (Af)*T (Af)
f *T A *T Af f *T If f *T f || f || 2
Unitary transform: a rotation in N-dimensional vector
space
Brief Review of Linear Operators
x2
2 1
x1
i 2 2 2
W N exp{ } cos( ) i sin( )
N N N
Brief Review of Linear Operators
1D DFT
1 N 1
i 2
t (u )
N
n 0
f (n) exp{
N
un}, u 0,1,..., N 1
2D DFT M 1 N 1
1 u v
t (u , v)
MN m 0 n 0
f (m, n) exp{i 2( m n)}
M N
u 0,1,..., M 1, v 0,1,..., N 1
Brief Review of Linear Operators
1 1 1 1
1 1 1 1
1 1 1
h 2 1 1 1 *
L 1 L L
1 1 1 1
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
Separable
Can be computed recursively, resulting in
roughly 4 operations per pixel
m,n
m,n+1
L pixels
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
Optimality properties
Signal and additive white noise
N N N
1 1 1
g
N
k 1
( f k nk )
N
k 1
fk
N
n .
k 1
k
N
1
z
N
n .
k 1
k
1 N N 1 2
2
(l , k ) 2
=
N k 1 l 1 N
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
k 1
2 ( g )
0
g
N
1
g
N
f
k 1
k
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
Frequency response:
Non-monotonically decreasing with frequency
1 1 1 1
1 1 1
1 1 1 [111] 1 hx hy
9 3 3
1 1 1 1
( N 1)/ 2
i 2
t (u) hx (0)
n ( N 1)/ 2
hx (n) exp{
N
un}
1 2 2
t (u ) cos( u )
3 3 N
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
An example
8 5 8 8 5 8 1 1 1 7 7 7 7 7 7
1
8 5 8 8 5 8 1 1 1 7 7 7 7 7 7
9
8 5 8 8 5 8 1 1 1 7 7 7 7 7 7
8 5 8 5 8 5 1 1 1 6 7 6 7 6 7
1
8 5 8 5 8 5 1 1 1 6 7 6 7 6 7
9
8 5 8 5 8 5 1 1 1 6 7 6 7 6 7
Linear Image smoothing techniques
Box filters. Arithmetic mean LL operator
1
b1 1 1
2
1
b 1 2 1 b 1 * b 1
2
4
1
b 1 4 6 4 1 b 1 * b 1 * b 1 * b 1
4
16
1
b 1 6 15 20 15 6 1 b 1 * b 1 * b 1 * b 1 * b 1 * b 1
6
64
As size increases, the shape of the filter is closer to a Gaussian one
Linear Image smoothing techniques
Binomial filters. 2D versions
1 1 2 1
1 1 1
b 2 1 2 1 * 2 2 4 2
4 4 16
1 1 2 1
1 1 4 6 4 1
4 4 16 24 16 4
1 1 1
b 1 4 6 4 1 * 6
4
6 24 36 24 6
16 16 256
4 4 16 24 16 4
1 1 4 6 4 1
Linear Image smoothing techniques
Binomial filters. Frequency response
1
b 1 2 1
2
4
t (u )
1 1 2
cos( u )
2 2 N
b4
1
16
1 4 6 4 1
1 1
2 2
2
t (u ) [ cos( u )]2
N
Monotonically decreasing
with frequency
Linear Image smoothing techniques
Binomial filters. Example
Result of size L
box filter
Size L binomial
L
Nonlinear image smoothing
The median filter [Pratt 1991]
Block diagram
f(1)
f1
f(2)
f2
. . f(m)
. Order . select
.
. samples
f(N) median
fN
f (1) f ( 2) f ( 3) f ( N )
N 1
m N is odd
2
Nonlinear image smoothing
The median filter
Numerical example
3 7 8
2 3 7 6
4 6 7
2, 3, 3, 4, 6, 7, 7, 7, 8
Nonlinear image smoothing
The median filter
Nonlinearity
Optimality
Grey level plateau plus noise. Minimize sum of
absolute differences:
N
( g ) | f k g |
k 1
Result:
g median{ f 1 , f 2 , f 3 , , f N } f ( m )
If 51% of samples are correct and 49% outliers,
the median still finds the right level!
Nonlinear image smoothing
The median filter
Caution: points, thin lines and corners are erased by the median filter
Test images
x2 x(2)
x3 x(3)
a Min(a,b)
x4 x(4)
b Max(a,b)
x5 x(5)
x6 x(6)
x7 x(7)
Nonlinear image smoothing
The median filter
Example of color
median filtering
5x5 pixels window
Up: original image
Down: filtered image
Nonlinear image smoothing
The weighted median filter
2 3 2
1 2 1
3 7 8
2 3 7 6
4 6 7
2, 2, 3, 3, 3, 3, 4, 6, 6, 7, 7, 7, 7, 7, 8
Nonlinear image smoothing
The multi-stage median filter
R2 R4
m5
R1
mi = median( Ri ), i =1,2,3,4.
Block diagram
weights
f(1)
f1 a1
f(2)
f2
a2
y
. .
.
ordering . sum
. .
f(N)
fN
aN
a
k 1
k 1 y = a1f(1) + a2 f(2)+...+ aN f(N)
Nonlinear image smoothing
Rank-order filters (L filters)
Some examples
a1=1
Percentile . . .
Min
Particular cases
filters (rank of grey level
selection): aN=1 morphological
filters
. . . Max
0%,
50% am=1
. . . . . .
100% Median
a1=.5 aN=.5
. . .
Mid range
Nonlinear image smoothing
Rank-order filters (L filters)
Optimality
N
( f ) | f ( k ) f |r Minkovski distance
k 1
M 1 median{ f1 , f 2 , f 3 , , f N }
M 2 median{| f i M 1 |}, i 1,2,..., N
output average{ f i : | f i M 1 | M 2 }
reg 8 reg 7
Nonlinear image smoothing
Conditional mean
1, if | f (m k , n l ) f (m, n) | th
h( k , l )
0, otherwise
K h( k , l )
k l
s() and r() are space and range similarity functions (Gaussian
functions of the Euclidian distance between their arguments).
Nonlinear image smoothing
Bilateral filter
|| x c x || 2
h(x) exp{ }
s
h(x) K(d(x c x); s )
Nonlinear image smoothing
Bilateral filter
Mean shift filtering replaces each pixels value with the most probable local value, found
by a nonparametric probability density estimation method.
{x i }i 1...n xi R d
The multivariate kernel density estimate obtained in the point x with the kernel K(x) and
window radius r is:
1 n
x xi
f (x) d
nr
K
i 1 r
For the Epanechnikov kernel, the estimated normalized density gradient is proportional
to the mean shift:
r2 f ( x) 1
d 2 f (x)
M r ( x)
nx
x
x i S r ( x )
i x
S is a sphere of radius r, centered on x and nx is the number of samples inside the sphere
Nonlinear image smoothing
Mean shift filtering
Example1.
Nonlinear image smoothing
Mean shift filtering
Detail of a 24x40
window from the
cameraman
image
a) Original data
b) Mean shift paths for
some points
c) Filtered data
d) Segmented data
Nonlinear image smoothing
Mean shift filtering
Example 2
Nonlinear image smoothing
Mean shift filtering