Lecture 2 PDF
Lecture 2 PDF
ideal (sinc)
uniform (box)
triangle
(=box⊗box)
Gaussian
(note: book pg. 139, eq. 5.47 needs normalization: 1/2πσ2 in 2D)
Phase Reversal of Uniform Filter
uniform Gaussian
reversed!
Other Linear Low-Pass Filters
● Square neighbourhood, significance of centre pixel
increased:
[ ] [ ]
1 1 1 1 2 1
1 1
1 2 1 2 4 2
10 16
1 1 1 1 2 1
– Book says: “it better approximates the properties of noise
with a Gaussian probability distribution.” (pg. 125) Wrong!
– You now now why these filters are used!
● The Butterworth Filter
– Compare: Chebyshev, Elliptic, etc.
– Designed for electric circuitry
– But: electric circuitry has different constraints!
– Has no purpose in digital signal/image processing
Linear Smoothing in n-D
● Separable filters vs. non-separable h=h x ⊗h y
Gaussian
(separable)
Impulse
response
in Fourier
domain
Linear Smoothing in n-D
square uniform
(separable) circular uniform
(not separable)
Gaussian
(separable)
Impulse
response
in Fourier
domain
Median Filter
● Takes the median of the values in some neighbourhood
● Not separable
● Median is an estimator for the mean
– Better than mean (linear filters) for some noise models
– Conserves edges slightly better than linear filters
● Generalizes to percentile filter
– Median is 50%
– 0% is min filter ( = erosion, Robin's lecture on
mathematical morphology )
– 100% is max filter ( = dilation, Robin's lecture )
– Other useful filters: 5%, 95% (like min and max, but less
sensitive to noise)
Median Statistics
one input image mean of 5 images median of 5 images
Normally
distributed
noise
Salt &
pepper
noise
Median Statistics
input image 3x3 uniform filter 3x3 median filter
Normally
distributed
noise
Salt &
pepper
noise
Max-Min and Min-Max Filter
max-min min-max
(=closing) (=opening)
Sequence of Max and Min Filters
● max min min max f ≈ min max max min f
● Removes local maxima and minima
● Apply first with very small neighbourhood
● Apply repeatedly with increasing size
Application: Unsharp Masking
● Subtract smoothed image from original image
● Darkroom technique: implemented by projecting out-of-
focus image onto a negative, then using the two
negatives together
spatial domain frequency domain
Identity (δ)
Unsharp (G)
2δ–G
Unsharp Masking Example
Application: Shading Correction
background estimated
with Gaussian filter
background estimated
with max-min filter
Normalised Convolution
{ f x m x }⊗h x
m x ⊗h x
{f x m x }⊗h x m x ⊗h x
[ ] []
1 0 −1 1
1 0 −1 /6 = [ 1 0 −1 ] /2 ⊗ 1 /3
1 0 −1 1
– Sobel
[ ] []
1 0 −1 1
2 0 −2 /8 = [ 1 0 −1 ] /2 ⊗ 2 / 4
1 0 −1 1
– Etc.
● You should understand now why Gaussian is better!
Uses of The Gradient
● The gradient is a vector perpendicular to the edge
● Gradient magnitude is a measure for edge strength
∣∇ f ∣ =
∂ f 2 ∂ f 2...
∂x
∂y
● Gradient direction is a measure for local orientation
∢ ∇ f = atan2 ∂ f , ∂ f
∂y ∂x
● Of course, you need a rotation invariant filter to
accurately measure orientation. The Gaussian gradient
operator is rotation invariant
Gradient Direction
Difference between
computed and true
gradient direction,
for various gradient
filters.
Input Gauss
radian
5 10-5
-5 10-5
Prewitt Sobel
Gradient Direction
Isotropy of Gradient Magnitude
impulse response
(in Fourier Domain)
using Gaussian gradients
impulse response
(in Fourier Domain)
using Sobel derivatives
Second Order Derivatives
∂2 f x =lim f x −2 f x f x −
∂ x2 0 2
{ }
2
ℱ ∂ f x =− 2
ℱ {f x }
2
∂x
2 2
2
∇ f =∇⋅∇ f = ∂ ∂
2 ... f
2
∂x ∂y
● The Laplace operator is:
– isotropic
– generalized 2nd derivative
● It detects lines, and responds strongly to edges
● It does not measure edge magnitude, as reported in
book (pg. 133)
Laplace Operator
2 2
2
∇ f =∇⋅∇ f = ∂ ∂
2 ... f
2
∂x ∂y
[ ]
1 1 1
● Finite difference approximation: 1 −8 1
1 1 1
● Gaussian approximation:
– Less sensitive to noise, more isotropic
– But: not separable!
● Another approximation: difference of Gaussians (DoG)
– Advantage: separable
Laplace Operator
H(0) = 0
Laplace of
Gaussian
difference of
Gaussians
Unsharp Masking Revisited
2 −G =1 + =
−∇ 2 G =1 + =
−∇ 2 + =
Kuwahara / Nagao Filter
● Mean in neighbourhood
● The neighbourhood shifts for each pixel
– Neighbourhood with minimum variance chosen
● Does not average across edges
7-pixel circular
uniform filter
Generalizing the Sigma Filter
position position
intensity
intensity
Bilateral Filter
● Kernel is Gaussian in distance, like linear Gaussian
● Kernel is also Gaussian in intensity difference
– Edges attenuate kernel significantly
hx x = G x − x 0 G f x −f x 0
0 x f
Anisotropic Diffusion
∂f
= ∇⋅ D f , x ∇ f , f x , t
∂t
● Linear diffusion = heat equation = Gaussian filter
∂f 2
=D ∇ f
∂t
● Choose diffusion coefficient
to be low at edges:
Df , x =g ∣∇ f∣
2
− u/ K
g u=e
1
g u= 2
1 u / K
Summary of Today’s Lecture
● Gaussian filters for:
– Smoothing
– Derivatives
– Laplace operator
● Non-linear filters for edge-preserving smoothing
● Smoothing filters for:
– Noise reduction
– Image simplification
– Shading correction
– Edge sharpening
● First order derivatives used for edge detection