0% found this document useful (0 votes)
85 views38 pages

Lecture 2 PDF

The lecture covered linear and non-linear filtering techniques. Linear filters like Gaussian and median filters were discussed for applications like smoothing, edge detection, and derivative estimation. Properties of linear time-invariant systems like convolution and the Fourier domain were also reviewed. Key concepts included separable filters, normalized convolution, and using derivatives of Gaussians for rotation-invariant edge detection and estimation of gradient vectors.

Uploaded by

Ali Kassab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views38 pages

Lecture 2 PDF

The lecture covered linear and non-linear filtering techniques. Linear filters like Gaussian and median filters were discussed for applications like smoothing, edge detection, and derivative estimation. Properties of linear time-invariant systems like convolution and the Fourier domain were also reviewed. Key concepts included separable filters, normalized convolution, and using derivatives of Gaussians for rotation-invariant edge detection and estimation of gradient vectors.

Uploaded by

Ali Kassab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Summary of Lecture #1

● Convolution describes Linear Time Invariant systems


● Sampling and reconstruction are LTI systems
● Imaging devices often are LTI systems
● Fourier Domain useful for analysing LTI systems
● Convolution in Spatial Domain is multiplication in
Fourier Domain

f  x ⊗h x  ℱ F H 


We will built on this for today's lecture


Filtering
● Smoothing:
– Linear (low-pass filtering) & non-linear
– Reduce noise
– Down-sample (zoom out)
– Sharpen
– Abstract (simplify)

1st & 2nd order derivatives:
– Linear (non-linear exist but we do not discuss)
– Detect edges
– Detect lines
● Normalised convolution
● Next lecture: detection & analysis
Filtering Properties
● Shift invariant:
– The result of the filter is independent of location within the
image
● Rotation invariant:
– The result of the filter should be independent of the
orientation of the image w.r.t. the axes
● These two rules make the result dependent only on the
object being imaged, not on the exact positioning of the
imaging system
Linear Smoothing in 1-D
● Low-pass filtering: removing high-frequency
components
smoothing kernel frequency response

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

● Convolution is associative f ⊗ { h x ⊗h y }= { f ⊗h x }⊗h y

● Separable filters are faster & easier to implement

the square uniform kernel is separable

G x ⊗G  y =G  x , y  the circular uniform kernel


the Gaussian kernel is separable is not separable
Linear Smoothing in n-D
square uniform
(separable) circular uniform
(not separable)

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

Subtract the background


or divide by the
background, depending
on the imaging model.

background estimated
with max-min filter
Normalised Convolution

Input data, with We also know which


missing samples samples are missing

Simply filtering the input image with the


missing samples produces a bad output
Normalised Convolution

{ f  x m x  }⊗h x 
m x ⊗h  x 

{f  x  m x  }⊗h x  m x ⊗h  x 

By normalising with the mask, the filter


“skips” missing input samples
First Order Derivatives
∂ f  x =lim f  x −f  x 
∂x 0 
ℱ { ∂ f  x  =i  ℱ { f  x  }
∂x }
● In a discrete grid, the smallest δ is 1
● Convolve with [ 1 -1 ] filter
– Asymmetric
● Convolve with [ 1 0 -1 ] / 2 filter
– Larger δ = worse approximation to derivative
Gaussian Derivatives
● Both filters have problems:
– High response to noise
– Poor approximation of gradient vector in n-D images
● Solution: use Gaussian derivatives
∂ { f  x ⊗G x  }=f  x ⊗ ∂ G x 
∂x ∂x
– Reduced response to noise
– Computes exact derivative of smoothed function
(meaning gradient vector has correct direction)
– “Band-limited”, so discretisable
– Separable
Other Derivatives
● In the first course you learned about some other
derivative operators:
– Prewitt

[ ] []
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

● Finite difference approximation


– Convolve with [ 1 -2 1 ]
– Note that [ 1 -2 1 ] = [ 1 -1 ] ⊗ [ 1 -1 ]
● Gaussian approximation
– Convolve with second derivative of Gaussian
Laplace Operator
● The Laplace operator is everywhere in physics
e.g. remember heat equation:
∂f 2
– =D ∇ f
∂t

 
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

finite difference Laplace

difference of
Gaussians
Unsharp Masking Revisited

spatial domain frequency domain

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

In book: “averaging using rotating mask”


Adaptive Filters
● Generalization of Kuwahara / Nagao
● We can turn or grow and shrink our neighbourhood
● Many, many ways of directing the filter
Gaussian (3x0.8) rotated to
align to local contours
Sigma Filter
● Computes mean in neighbourhood, like uniform filter
● But: excludes pixels that differ more than s from the
central value
7-pixel circular uniform
sigma filter, with s=20

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
hx  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:
Df , 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

You might also like