EECE 5639 Computer Vision I: Filtering, Probability Review
EECE 5639 Computer Vision I: Filtering, Probability Review
Lecture
Filtering, Probability Revie
Next Clas
Noise Cleaning, Edges
1
7
Image processing:
Filtering
Digital Images
3
Digital Images
Array of numbers (pixels
Typically integers 0-255 (unsigned byte
Pixels have neighbors
4-neighbors 8-neighbors
4
)
Image Paths
A path is a sequence of pixel indices (io,jo)(i1,j1)…(in,jn) such tha
(ik,jk) is a neighbor of (ik+1,jk+1)
4-connected
path
8-connected path
Levels of Computation
Point leve
Output based only on a single poin
Ex.: thresholdin
Local leve
Output based on a neighborhoo
Ex. : smoothing and edge detectio
Global leve
Output based on the whole imag
Ex.: Fourier transform and histogra
Object leve
Output based on pixels that belong to an object
6
l
Spatial Filtering
Spatial Filtering
• Use of spatial masks (kernels, lters, templates,
windows) for image processing (spatial lters
• Linear and nonlinear lter
• Spatial Filters include
• Sharpenin
• Smoothin
• Edge detectio
• Noise remova
• etc
8
g
fi
:
fi
fi
)
Linear Filters
• General process • Example: smoothing by averagin
• Form new image whose pixels are a • form the average of pixels in a
weighted sum of original pixel values, neighborhoo
using the same set of weights at each
point • Example: smoothing with a Gaussia
• Propertie • form a weighted average of pixels in a
• Output is a linear function of the inpu neighborhoo
• Output is a shift-invariant function of • Example: nding a derivativ
the input (i.e. shift the input image two
pixels to the left, the output is shifted
• form a weighted average of pixels in a
two pixels to the left) neighborhood
9
.
fi
d
Image Filtering
Low-pass lters eliminate or attenuate high frequency
components in the frequency domain (sharp image
details), and result in image blurring
10
fi
fi
fi
.
Spatial Filtering
Operations are performed directly on the pixels in the
spatial domain
11
.
fi
Basics of Spatial Filtering
Ex of a 3x3 mask
12
Linear Spatial Filtering: CORRELATION
Linear ltering of an MxN image f(x,y) with a lter
w(s,t) of size mxn is given by:
Where zi are the values of the input image under the mask
14
Practical Issue: Border Handling
0000 …
h
f
16
Correlation Example
17
18
19
20
21
22
And so on …
Correlation vs Convolution
Correlation:
FLIP FIRST!
Convolution:
24
Correlation vs Convolution
25
Correlation and Convolution in MATLAB
Im lter(image,template{,option1,option2,…}
27
Filtering with Correlation
28
Filtering with Correlation
29
Filtering with Correlation
30
Filtering with Correlation
31
Filtering with Correlation
32
Smoothing Filters
Image Noise
Images are nois
Noise is anything in the image that we are not interested i
Examples
Fluctuations of pixel value
Numerical error
Clutter
34
:
Images as Surfaces
Surface height
proportional to
pixel grey value
(dark=low, light=high)
Bob Collins 35
Examples
37
fl
e
Modeling Noise
We are interested in RANDOM noise
Deterministic noise (ex: hardware defects) can be corrected.
38 .
We want something
more like this!
Bob Collins 39
Probability Review
Intuitive Development
Intuitively, the probability of an event a could be de ned as:
41
More Formal:
Ω is the Sample Space:
Contains all possible outcomes of an experimen
ω in Ω is a single outcom
A in Ω is a set of outcomes of interest
42
e
Independence
The probability of independent events A, B and C is given by
P(ABC) = P(A)P(B)P(C)
43
Conditional Probability
One of the most useful concepts!
Ω
A
AB
B
44
Bayes Theorem
Provides a way to convert a-priori probabilities to a-posteriori
probabilities:
45
Random Variables
A (scalar) random variable X is a function that maps the
outcome of a random event into real scalar values
Ω X(ω)
ω
46
Random Variables Distributions
Cumulative Probability Distribution (CDF):
47
Random Distributions:
From the two previous equations:
48
Statistical Characterizations
Expectation (Mean Value, First Moment):
“weighted average”
• Second Moment:
49
Statistical Characterizations
Variance of X:
“how far is x from the mean”
• Standard Deviation of X:
50
Mean Estimation from Samples
Given a set of N samples from a distribution, we can
estimate the mean of the distribution by:
51
Variance Estimation from Samples
Given a set of N samples from a distribution, we can
estimate the variance of the distribution by:
52
Uniform Distribution
A R.V. X that is uniformly distributed between x1 and x2 has
density function:
X1 X2
53
Gaussian (Normal) Distribution
A R.V. X that is normally distributed has density function:
µ
54