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]
Generalized 2D linear operator
M −1 N −1
g (m, n) = ∑∑ O ( j , k ; m, n) f ( j , k )
j =0 k =0
Separable linear operator:
O( j , k ; m, n) = OR ( j; m)OC (k ; n)
M −1 N −1
g ( m, n) = ∑O R ( j ; m) ∑OC ( k ; n) f ( j , k )
j =0 k =0
Space invariant operator:
O( j , k ; m, n) = O(m − j , n − k ) = H (m − j , n − k )
M −1 N −1
g ( m, n) = ∑∑h( m − j , n − k ) f ( j , k )
j =0 k =0
Convolution sum
Brief Review of Linear Operators
h22 h21 h20
L-1
h12 h11 h10
Geometrical
2 L-1
H h02 h01 h0 2 h22 h21 h20
0
h12 h11 h10
G
L-1
2
L-1 h22 h21 h20
h02 h01 h0
0
interpretation
of 2D
2 h12 h11 h10
h02 h01 h0
F
0
N-
L+1
convolution
N
N+L-1
Matrix formulation
t = Af
Unitary transform
−1
A =A *T
Separable transform
T = A FAC is
Transform
T
R
invertible
f = A *Tt = A *T Af = If
Brief Review of Linear Operators
|| t || 2 = t *T t = (Af)*T (Af) =
Unitary *T
Af = f *aTrotation
f *T Atransform: If = f *Tinf N-dimensional
=|| f || 2 vector space
Brief Review of Linear Operators
x2
ξ 2 ξ 1
x1
W 0 W 0 W0 ⋅ ⋅ ⋅ W0
0
W W 1
W 2
⋅ ⋅ ⋅ W N −1
W 0 W 2 W4 ⋅ ⋅ ⋅ W 2 ( N −1)
1
A= ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
N
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
W 0 W N W 2 ( N −1) ⋅ ⋅ ⋅ W ( N −1)
2
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 L× L operator
Separable
Canbe computed recursively, resulting in roughly 4
operations per pixel
m,n
m,n+1
− +
L pixels
Linear Image smoothing techniques
Box filters. Arithmetic mean L× L 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 L× L operator
k =1
∂ε 2 ( g )
=0
∂g
N
1
gˆ =
N
∑f
k =1
k
Linear Image smoothing techniques
Box filters. Arithmetic mean L× L 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 L× L 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 L× L operator
1
b1 = [1 1]
2
1
b2 = [1 2 1] = b 1 * b 1
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
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 pixel’s 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
∑
i =1
K
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