Professional Documents
Culture Documents
Lecture 15
Lecture 15
Recap
Non-Linear Filters
Median Filters
Morphological Filters
Bilateral Filters
Gaussian Compositions
Unsharp Masking
Difference of Gaussians
Summary
Recap
I we also write
Nxy = p0 , p1 , . . . , pq−1
where q = mn
Recap
note:
the Gaussian filter is a specific weighted mean filter
Recap
then
h m ni h m n i
c[x, y, m, n] = C x + , y + − C x + ,y − − 1
h 2m 2
ni h2 m
2
n i
− C x − − 1, y + + C x − − 1, y − − 1
2 2 2 2
C β C C α C
c c c c
y y y y
δ γ
x x x x
Recap
integral images
I dynamic programming allows for efficient computation of
integral images, simply consider that
C[x, y] = c[x, y] + C[x, y − 1] + C[x − 1, y] − C[x − 1, y − 1]
x
Recap
integral images
I dynamic programming allows for efficient computation of
integral images, simply consider that
C[x, y] = c[x, y] + C[x, y − 1] + C[x − 1, y] − C[x − 1, y − 1]
y y y y
x x x x
Non-Linear Filters
median filter
given f and Nxy , consider ordered set Rxy = ri ∈ Nxy ri 6 ri+1
I
example
image f 3 × 3 median g
Non-Linear Filters
observation
x
P (x)
1
2
med{p(x)} x
Non-Linear Filters
histograms
I histograms H(i) count things
Pi
H(i) C(i) = k=0 H(k)
Non-Linear Filters
for all y = 0 . . . M − 1
for all x = 0 . . . N − 1
I sketch
sanity check for x and y
if (x, y) is UL corner
initialize histogram H
else
for all k = − n2 . . . n2 y − +
sub f [y + k, x − 2n − 1] from H
add f [y + k, x + 2n ] to H
P
q = i Hi
s=0
for all i = 0 . . . #colors x
s = s + Hi
if s > q/2
I effort per pixel
median = i
O(n) + 256 ops max
= O(n) + O(1)
= O(n)
Non-Linear Filters
observation
I for disjoint sets A and B, we have
for all y = 0 . . . M − 1
for all x = 0 . . . N − 1
I sketch
sanity check for x and y
if y is uppermost row −
initialize hx
if (x, y) is UL corner y
initialize H
+
else
sub f [y − m2 − 1, x + n2 ] from hx+ n
2
add f [y + m2 , x + n2 ] to hx+ n
2 x
H = H − hx− n −1 + hx+ n
2 2
s=0
...
y − +
x
Non-Linear Filters
morphology (I)
given f [i, j] and ordered set Rxy = ri ∈ Nxy ri 6 ri+1
I
Non-Linear Filters
morphology (I)
given f [i, j] and ordered set Rxy = ri ∈ Nxy ri 6 ri+1
I
I the operation
g[x, y] ← r0
is called erosion
Non-Linear Filters
morphology (I)
given f [i, j] and ordered set Rxy = ri ∈ Nxy ri 6 ri+1
I
I the operation
g[x, y] ← r0
is called erosion
I the operation
g[x, y] ← rq−1
is called dilation
Non-Linear Filters
morphology (II)
I erosion and dilation are useful in binary image processing
morphology (III)
I shape boundary extraction
morphology (IV)
I the operation
d◦e
is called opening
Non-Linear Filters
morphology (IV)
I the operation
d◦e
is called opening
I the operation
e◦d
is called closing
Non-Linear Filters
morphology (V)
I they remove isolated pixels or close holes, for example
image f opening d e(f ) closing e d(f )
Non-Linear Filters
morphology (VI)
I morphological operations are of importance in industrial
computer vision (machine vision) and in medical image
processing
Non-Linear Filters
morphology (VI)
I morphological operations are of importance in industrial
computer vision (machine vision) and in medical image
processing
16
Gaussian Compositions
I terminology:
α = 1 ⇔ unsharp masking
α > 1 ⇔ highboost filtering
Gaussian Compositions
0.08
0.06
0.04
0.02
-0.02
-0.04
-20 -10 0 10 20
Gaussian Compositions
original
σ1 = 4.5, σ2 = 9 σ1 = 9, σ2 = 18 σ1 = 18, σ2 = 36
Gaussian Compositions
Laplacians (I)
I for the discrete convolution (not correlation!!!)
of the signal · · · 0-110 · · · with the kernel [-11],
we have
Laplacians (I)
I for the discrete convolution (not correlation!!!)
of the signal · · · 0-110 · · · with the kernel [-11],
we have
I therefore, if we define
d !
f [x] = [-11] ∗ f [x]
dx
then
d2
f [x] = [-11] ∗ [-11] ∗ f [x] = [1-21] ∗ f [x]
dx2
Gaussian Compositions
Laplacians (II)
I given a continuous 2D function f (x, y), the function
∂2 ∂2
∆ f (x, y) = ∇2 f (x, y) = f (x, y) + f (x, y)
∂x2 ∂y2
Laplacians (III)
I for discrete 2D function f [x, y] with
∂2 f
= f [x − 1, y] − 2f [x, y] + f [x + 1, y]
∂x2
∂2 f
= f [x, y − 1] − 2f [x, y] + f [x, y + 1]
∂y2
we find
∇2 f [x, y] =f [x − 1, y] + f [x + 1, y]+
f [x, y − 1] + f [x, y + 1] − 4 f [x, y]
Gaussian Compositions
Laplacians (IV)
I written as a discrete 2D filter kernel, the Laplacian
amounts to
0 1 0
L[x, y] = 1 -4 1
0 1 0
and we have
∇2 f [x, y] = (L ∗ f )[x, y]
Gaussian Compositions
note:
Laplacians (V)
I the Laplacian of an image reveals regions of rapidly
changing intensities and is therefore often used in
edge detection
Gaussian Compositions
Laplacians (V)
I the Laplacian of an image reveals regions of rapidly
changing intensities and is therefore often used in
edge detection
Laplacians (V)
I the Laplacian of an image reveals regions of rapidly
changing intensities and is therefore often used in
edge detection
f̃ (x, y) = L ∗ G ∗ f (x, y)
Gaussian Compositions
Laplacians (VI)
I when computing L ∗ G ∗ f , it is beneficial to compute the
Laplacian of Gaussian
LoG(x, y) = L ∗ G (x, y)
x2 + y2 − x2 +y22
1
=− 4 1− e 2σ
πσ 2σ2
Laplacians (VII)
I finally, to further simplify computation, the Laplacian of
Gaussian LoG is commonly approximated by means
of a suitably chosen Difference of Gaussians DoG
Summary
I unsharp masking