EECE 5639 Computer Vision I: Filtering, Noise Cleaning, Separable Filters
EECE 5639 Computer Vision I: Filtering, Noise Cleaning, Separable Filters
Lecture
Filtering, Noise Cleaning, Separable Filter
Next Clas
Edges, Corners, Model Fitting
1
8
Probability
Independent events A, B and C P(ABC) = P(A)P(B)P(C)
Std. Dev:
2
:
3
Variance Estimation from Samples
Given a set of N samples from a distribution, we can
estimate the variance of the distribution by:
4
… back to images
Dealing with Noise
Image patch Noisy surface
We want something
more like this!
Bob Collins 6
How can we reduce noise?
Image acquisition noise due to light uctuations and sensor
noise can be reduced by acquiring a sequence of images
and averaging them
WHY?
7
.
fl
Measuring Noise
Noise Amount: SNR = σs/ σn
Noise Estimation:
Given a sequence of images I0,I1, … IN-1
Smoothing Filters
Linear Spatial Filtering: CORRELATION
Alternative notation:
Where zi are the values of the input image under the mask
10
Correlation Example
11
Smoothing Spatial Filters
They are used for blurring and noise reduction
12
fi
s
13
fi
fi
fi
.
Average Filter
Mask with positive entries, that sum 1
Replaces each pixel with an average of its neighborhood
If all weights are equal, it is called a BOX lter.
1 1 1
1 1 1
1/9
1 1 1
14
.
fi
Example:
X X X X X X
10 11 10 0 0 1
9 10 11 1 0 1 X 10 X
O X X
I 10 9 10 0 2 1
X X
11 10 9 10 9 11
F X X
9 10 11 9 99 11
X X X X X X
10 9 9 11 10 10 1 1 1
1 1
1/9 1
1 1 1
X X X X X X
10 11 10 0 0 1
9 10 11 1 0 1 X 10 7 4 1 X
O X X
I 10 9 10 0 2 1
X X
11 10 9 10 9 11
F X X
9 10 11 9 99 11
X X X X X X
10 9 9 11 10 10 1 1 1
1 1
1/9 1
1 1 1
X X X X X X
10 11 10 0 0 1
9 10 11 1 0 1 X 10 7 4 1 X
O X X
I 10 9 10 0 2 1
X X
11 10 9 10 9 11
F X 20 X
9 10 11 9 99 11
X X X X X X
10 9 9 11 10 10 1 1 1
1 1
1/9 1
1 1 1
X X X X X X
10 11 10 0 0 1
9 10 11 1 0 1 X 10 7 4 1 X
O X X
I 10 9 10 0 2 1
X 18 X
11 10 9 10 9 11
F X 20 X
9 10 11 9 99 11
X X X X X X
10 9 9 11 10 10 1 1 1
1 1
1/9 1
1 1 1
19
.
20
.
fi
Does it reduce noise?
Assume that the noise in the image is uncorrelated, zero
mean, with stdev sigma
The expected value of a pixel after ltering is:
21
.
fi
Does it reduce noise?
Assume that the noise in the image is uncorrelated, zero
mean, with stdev sigma
The variance of a pixel before ltering is:
22
.
fi
Does it reduce noise?
Assume that the noise in the image is uncorrelated, zero
mean, with stdev sigma
The variance of the pixel after ltering is:
23
.
fi
How big should the mask be?
The bigger the mask
more neighbors contribute
smaller noise variance of the output
bigger noise spread
more blurring
more expensive to compute.
24
.
25
.
Gaussian Filter
A particular case of weighted averaging
The coef cients are a 2D Gaussian.
26
fi
fi
:
F
S
Gaussian lter is the only one that has the same shape
in the space and frequency domains.
27
fi
How big should the mask be?
The std. dev of the Gaussian σ determines the amount
of smoothing
The samples should adequately represent a Gaussian
For a 98.76% of the area, we nee
m = 5σ (space domain)
5.(1/σ) ≤ 2π (frequency domain) ⇒ σ ≥ 0.796, m ≥5
28
.
29
Effects of increasing mask size
30
Ef cient Implementation
Both, the BOX lter and the Gaussian lter are
separable
First convolve each row with a 1D lte
Then convolve each column with a 1D lter.
31
fi
:
fi
fi
r
fi
fi
Separable Filters
32
fi
Separable Filters
∑∑ ∑∑ ∑ ∑
w(x, y)p(x, y) = w(x)w(y)p(x, y) = w(x) w(y)p(x, y)
x y x y x y
33
Separable Filters
34
fi
Separable Filters
36
Separable Filters
37
Separable Filters
How do we know a lter is separable
By inspectio
Looking at the analytic form of i
Looking at its Singular Value Decomposition (SVD)
38
n
fi
t
Cascading
Convolving twice with a Gaussian Kernel (σ), is the same as convolving once
with a Gaussian Kernel (√2σ)
39
Ef cient Implementation: Integral Image
If an image is going to be repeatedly convolved with
different box lters a pre-computed summed area table
can save computations for future use.
40
fi
fi
Ef cient Implementation: Integral Image
If an image is going to be repeatedly convolved with
different box lters a pre-computed summed area table
can save computations for future use.
28 = 19 +17 - 11 + 3
41
fi
fi
Ef cient Implementation: Integral Image
If an image is going to be repeatedly convolved with
different box lters a pre-computed summed area table
can save computations for future use.
42
fi
fi
Limitations of averaging
Signal frequencies shared with noise are lost, resulting in
blurring
Impulsive noise is diffused but not removed
It spreads pixel values, resulting in blurring.
43
.
Non-linear Filtering
Replace each pixel with the MEDIAN value of all the pixels in
the neighborhood.
44
Example:
10 11 10 0 0 1 X X X X X X
9 10 11 1 0 1 X 10 X
I 10 9 10 0 2 1 O X X
11 10 9 10 9 11 X X
9 10 11 9 99 11 X X
10 9 9 11 10 10 X X X X X X
median
10,11,10,9,10,11,10,9, sort
10 9,9,10,10,10,10,10,11,11
45
Example:
10 11 10 0 0 1 X X X X X X
9 10 11 1 0 1 X 10 10 1 1 X
I 10 9 10 0 2 1 O X X
11 10 9 10 9 11 X X
9 10 11 9 99 11 X X
10 9 9 11 10 10 X X X X X X
median
11,10,0,10,11,1,9,10 sort
,0 0,0,1,9,10,10,10,11,11
46
Example:
X X X X X X
10 11 10 0 0 1
9 10 11 1 0 1 X 10 X
O X X
I 10 9 10 0 2 1
X 9 X
11 10 9 10 9 11
9 10 11 9 99 11 X 10 X
10 9 9 11 10 10 X X X X X X
median
10,9,11,9,99,11,11,10, sort
10 9,9,10,10,10,11,11,11,99
47
Median Filter Properties
Non-linea
Does not spread the nois
Can remove spike nois
Expensive to run
48
r
Median Filter
49