S thi ith G i Smoothing with a Gaussian• Smoothing with a box actually doesn’t compare at all well with a defocussed lens • Most obvious difference is that a single point of light vie
Trang 4From the 3D to 2D
P = [x,y,z]
3D world
p = [x,y]
•Let’s now focus on 2D
Trang 5Extract useful building blocks
Trang 6The big picture…
Feature
Feature Detection e.g DoG
Feature e g SIFT
Feature Description
e.g SIFT
Matching / Indexing /
database of local Indexing /
Detection
descriptors
Trang 8Images as functions
y f(x,y)
x
Source: S Seitz
Trang 9Images as functions
• Images are usually digital (discrete):
– Sample the 2D space on a regular grid
• The image can now be represented as a matrix
• The image can now be represented as a matrix
of integer values
i lpixel
Source: S Seitz
Trang 10• Linear filtering:
– Form a new image whose pixels are a weighted sum of original pixel values – use the same set of weights at each point
Goals:
Extract useful information from the images g
•Features (edges, corners, blobs…)
Modify or enhance image properties
- super-resolution, in-painting, de-noising
Trang 121 1 1
Convolution
1 1 1
1 1 1
• Represent the linear
image H, where u,v range
over kernel pixels:
convolution
– Center origin of the kernel
F at each pixel location
Trang 13Slide credits for these examples: Bill Freeman, David Jacobs
Trang 28X 1010
XO
Trang 29Average filter (box filter)
Mask ith positi e
• Mask with positive
entries, that sum to 1.
• Replaces each pixel
with an average of its
neighborhood.
1 1
1
neighborhood.
• If all weights are equal,
it is called a box filter.
1 1
1
Slide credit: David Lowe (UBC)
Trang 30Example: Smoothing with a box filter
Trang 31S thi ith G i Smoothing with a Gaussian
• Smoothing with a box actually
doesn’t compare at all well with
a defocussed lens
• Most obvious difference is that
a single point of light viewed in
a defocussed lens looks like a
fuzzy blob; but the averaging
process would give a little
Slide credit: David Lowe (UBC)
Trang 32Gaussian Kernel
• Idea: Weight contributions of neighboring pixels by nearness
0.003 0.013 0.022 0.013 0.003 0.013 0.059 0.097 0.059 0.013
0 022 0 097 0 159 0 097 0 022 0.013 0.059 0.097 0.059 0.013 0.003 0.013 0.022 0.013 0.003
5 x 5, = 1
• Constant factor at front makes volume sum to 1 (can be ignored, as we should
normalize weights to sum to 1 in any case).
Slide credit: Christopher Rasmussen
Trang 33Smoothing with a Gaussian
Trang 34Smoothing reduces pixel noise:
Each row shows smoothing with Gaussians of different width; each column shows different amounts of
Gaussian noise.
Trang 35Efficient Implementation
• Both the BOX filter and the Gaussian filter are separable
into two 1D convolutions:
– First convolve each row with a 1D filter
– Then convolve each column with a 1D filter
Trang 36Differentiation and convolution
• Recall, for 2D function,
• This is linear and shift
invariant, so must be the
(which is obviously a convolution)
result of a convolution
Trang 37Vertical gradients from finite differences
Trang 38Shift invariant linear systems
Trang 40Spatial frequency and Fourier Transform
Trang 43Sampling and aliasing
Constructing a pyramid by
taking every second pixel
leads to layers that badly
misrepresent the top layer
Trang 44Sampling in 1D p g
Trang 45Sampling in 2D
Trang 47Aliasing in graphics g g p
Source: A Efros
Trang 49Aliasing!
Trang 50Smoothing and resampling
• Nyquist’s theorem
Trang 52Algorithm
Trang 53Filters are templates p
• Applying a filter at some point
• Insight can be seen as taking a dot-
product between the image and
some vector
– filters look like the effects they are intended to find – filters find effects they look
• Filtering the image is a set of
dot products
like
Slide credit: David Lowe (UBC)
Trang 54Normalized correlation
• Think of filters as a dot product of the filter vector with
the image region
Now measure the angle between the vectors
– Now measure the angle between the vectors
Angle (similarit ) bet een ectors can be meas red b normali ing
a
– Angle (similarity) between vectors can be measured by normalizing
length of each vector to 1.
– Normalized correlation: divide each correlation by square root of sum
of squared values (length)
Slide credit: David Lowe (UBC)
Trang 55Application: Vision system for TV remote control
- uses template matching
Figure from “Computer Vision for Interactive Computer Graphics,” W.Freeman et al, IEEE Computer Graphics and Applications,
1998 copyright 1998, IEEE
Trang 56We need scaled representations
• Find template matches at all scales
– e.g., when finding hands or faces, we don’t know what
size they will be in a particular image
– Template size is constant, but image size changes
• Efficient search for correspondence
– look at coarse scales, then refine with finer scales
– much less cost, but may miss best match
• Examining all levels of detail
– Find edges with different amounts of blur
– Find textures with different spatial frequencies (levels p q (
of detail)
Slide credit: David Lowe (UBC)
Trang 57The Gaussian pyramid
• Create each level from previous one:
– smooth and sample
• Smooth with Gaussians, in part because
– a Gaussian*Gaussian = another Gaussian
G( ) * G( ) G( t( 2 + 2))
– G(x) * G(y) = G(sqrt(x2 + y2))
Slide credit: David Lowe (UBC)
Trang 58All the extra
All the extra levels add very little overhead for memory orfor memory or computation!
Trang 59Edge and Corner Detection
• Goal: Identify sudden
• Example: artist’s line
drawing (but artist is also
using object-level knowledge)
Slide credit: David Lowe (UBC)
Trang 60What causes an edge?
• Depth discontinuity
• Surface orientation
discontinuity
• Reflectance discontinuity (i.e.,
change in surface material
Trang 61Smoothing and Differentiation g
• Edge: a location with high gradient (derivative)
• Need smoothing to reduce noise prior to taking derivative
• Need two derivatives, in x and y direction
• We can use derivative of Gaussian filters
• because differentiation is convolution, and convolution is associative:
D * (G * I) = (D * G) * I
Trang 62Derivative of Gaussian
Slide credit: Christopher Rasmussen
Trang 63Increased smoothing:
• Eliminates noise edges
• Makes edges smoother and thicker
• Removes fine detail
• Removes fine detail
Trang 64Edge Detection
• Criteria for optimal edge detection:
− Good detection: the optimal detector must minimize the probability
of false positives (detecting spurious edges caused by noise), as well as that of false negatives (missing real edges)
− Good localization: the edges detected must be as close as possible
to the true edges.
− Single response constraint: the detector must return one point only for each true edge point; that is, minimize the number of local g p ; ,
maxima around the true edge
Trang 66Canny Edge Detection
− This is probably the most widely used edge detector in computer vision
vision.
− Canny has shown that the first derivative of the Gaussian closely
approximates the operator that optimizes the product of
signal-to-noise ratio and localization
noise ratio and localization.
− His analysis is based on "step-edges" corrupted by "additive
Gaussian noise".
Trang 67C Ed D t ti Canny Edge Detection
Steps:
1 Smooth image w/ Gaussian filter
2 Apply derivative of Gaussianpp y
3 Find magnitude and orientation of gradient
4 ‘Non-maximum suppression’
• Thin multi-pixel wide “ridges” down to single pixel width
5 ‘Hysteresis’: Linking and thresholding
• Low, high edge-strength thresholds
• Accept all edges over low threshold that are connected to edge over high threshold
Trang 68Canny Edge Detector
First Two Steps
• Smoothing
I y
x g y
x g I
S ( , ) ( , )
2
2 2
2
2
1 )
e y
x g
y g
x g
I g
Trang 69Canny Edge Detector Derivative of Gaussian
),(x y
g x
),(x y
Trang 70Canny Edge Detector
First Two Steps
x
S I
y
S
Trang 71Canny Edge Detector
S S
S S
1
2 2
tan
) (
Trang 72Canny Edge Detector
Fourth Step
• Non maximum suppression
We wish to mark points along the curve where the magnitude is biggest We can
do this by looking for a maximum along a slice normal to the curve (non-maximum suppression) These points should form a curve There are then two algorithmic suppression) These points should form a curve There are then two algorithmic issues: at which point is the maximum, and where is the next one?
Trang 73Non-maximum suppression
Trang 74Examples:
Non-Maximum Suppression
courtesy of G Loy
Slide credit: Christopher Rasmussen
Trang 76fine scalehigh
threshold
Trang 77coarse scale,
high
threshold
Trang 78low
threshold
Trang 79Linking to the next edge point
points (either r or s)
Trang 80Canny Edge Detector Step 5: Hysteresis Thresholding
• Hysteresis: A lag or momentum factor
• Idea: Maintain two thresholds khighhigh and klowlow
– Use khigh to find strong edges to start edge chain
– Use klow to find weak edges which continue edge chain
• Typical ratio of thresholds is roughly
khigh / klow = 2
Trang 81Example: Canny Edge Detection p y g
courtesy of G Loy
Trang 82Example:
Canny Edge Detection
Using Matlab with default thresholdsg
Slide credit: Christopher Rasmussen
Trang 83http://www.cs.washington.edu/research/imagedatabase/demo/edge/