Computer Vision ch4
Computer Vision ch4
Source: D. Lowe
Origin of Edges
surface normal discontinuity
depth discontinuity
illumination discontinuity
Source: D. Hoiem
Closeup of edges
Source: D. Hoiem
Closeup of edges
Source: D. Hoiem
Closeup of edges
Source: D. Hoiem
Characterizing edges
• An edge is a place of rapid change in the image
intensity function
intensity function
image (along horizontal scanline) first derivative
edges correspond to
Source: L. Lazebnik extrema of derivative
Intensity profile
Source: D. Hoiem
Image derivatives
• How can we differentiate a digital image F[x,y]?
– Option 1: reconstruct a continuous image, f, then
compute the derivative
– Option 2: take discrete derivative (finite difference)
: 1 -1 : -1
1
Source: S. Seitz
Image gradient
• The gradient of an image:
The gradient points in the direction of most rapid increase in intensity
Source: L. Lazebnik
Effects of noise
f*h
Source: S. Seitz
The 1D Gaussian and its
derivatives
2D edge detection filters
x-direction y-direction
The Sobel operator
• Common approximation of derivative of Gaussian
-1 0 1 1 2 1
-2 0 2 0 0 0
-1 0 1 -1 -2 -1
• The standard defn. of the Sobel operator omits the 1/8 term
– doesn’t make a difference for edge detection
– the 1/8 term is needed to get the right gradient magnitude
Sobel operator: example
Source: Wikipedia
Sobel operator
Laplacian of Gaussian
operator
Laplacian of Gaussian
26
LoG Operator
Using the LoG Function
• The LoG function will be
• Zero far away from the edge
• Positive on one side
• Negative on the other side
• Zero just at the edge
• It has simple digital mask implementation(s)
• So it can be used as an edge operator
• BUT, is this good enough?
Designing an edge detector
• Criteria for a good edge detector:
– Good detection: the optimal detector should find all real
edges, ignoring noise or other artifacts
– Good localization
• the edges detected must be as close as possible
to the true edges
• the detector must return one point only for each
true edge point
• Cues of edge detection
– Differences in color, intensity, or texture across the boundary
– Continuity and closure
– High-level knowledge
Source: L. Fei-Fei
Canny edge detector
• This is probably the most widely used edge
detector in computer vision
Source: L. Fei-Fei
Example
gradient magnitude
Finding edges
thresholding
Get Orientation at Each Pixel
• Threshold at minimum level
• Get orientation
theta = atan2(gy, gx)
Non-maximum suppression
35
Picture from Prem K Kalra
Before Non-max Suppression
After Non-max Suppression
Finding edges
thresholding
Threshold the gradient magnitude image such that strong edges are
kept and noise is suppressed
Finding edges
thinning
(non-maximum suppression)
Canny edge detector
MATLAB: edge(image,‘canny’)
3. Non-maximum suppression
Source: S. Seitz
Final Canny Edges
𝜎 = 2, 𝑡𝑙𝑜𝑤 = 0.05, 𝑡ℎ𝑖𝑔ℎ = 0.1
Effect of (Gaussian kernel spread/size)
Original 𝜎= 2 𝜎=4 2
Source: S. Seitz
Scale space (Witkin 83)
first derivative peaks
larger
by Diva Sian
by swashford
Harder case
Feature Descriptors
Advantages of local features
Locality
• features are local, so robust to occlusion and clutter
Quantity
• hundreds or thousands in a single image
Distinctiveness:
• can differentiate a large database of objects
Efficiency
• real-time performance achievable
More motivation…
Feature points are used for:
• Image alignment (e.g., mosaics)
• 3D reconstruction
• Motion tracking
• Object recognition
• Indexing and database retrieval
• Robot navigation
• … other
Approach
Feature detection: find it
Feature descriptor: represent it
Feature matching: match it
3) Matching: Determine
correspondence between
descriptors in two views x 2 = [ x1( 2) ,, xd( 2) ]
Kristen Grauman
What makes a good feature?
Snoop demo
Want uniqueness
Look for image regions that are unusual
• Lead to unambiguous matches in other images
Horizontal edge:
v
u
E(u,v)
Vertical edge:
v
u
General case
We can visualize H as an ellipse with axis lengths
determined by the eigenvalues of H and orientation
determined by the eigenvectors of H
Image patch
X derivative
Y derivative
Intuitive way of understanding Harris detector
Intuitive way of understanding Harris detector
Quick eigenvalue/eigenvector review
The eigenvectors of a matrix A are the vectors x that satisfy:
• The solution:
xmin
xmax
2 “Edge”
2 >> 1 “Corner”
1 and 2 are large,
1 ~ 2 ;
E increases in all
directions
1
Corner detection summary
Here’s what you do
• Compute the gradient at each point in the image
• Create the H matrix from the entries in the gradient
• Compute the eigenvalues.
• Find points with large response (min > threshold)
• Choose those points where min is a local maximum as features
Corner detection summary
Here’s what you do
• Compute the gradient at each point in the image
• Create the H matrix from the entries in the gradient
• Compute the eigenvalues.
• Find points with large response (min > threshold)
• Choose those points where min is a local maximum as features
The Harris operator
min is a variant of the “Harris operator” for feature detection
• The trace is the sum of the diagonals, i.e., trace(H) = h11 + h22
• Very similar to min but less expensive (no square root)
• Called the “Harris Corner Detector” or “Harris Operator”
• Lots of other detectors, this is one of the most popular
The Harris operator
Harris
operator
Harris detector example
f value (red high, blue low)
Threshold (f > value)
Find local maxima of f
Harris features (in red)
Weighting the derivatives
• In practice, using a simple window W doesn’t work
too well
5. Non-maxima suppression 96
har
Exercise
• Suppose that an image 𝑓(𝑥, 𝑦) is convolved with a mask of size n*n
ҧ 𝑦).
(with coefficients 1/𝑛2 ) to produce a smoothed image 𝑓(𝑥,
(a) Derive an expression of edge strength (edge magnitude) of the
smoothed image as a function of mask size. Assume for simplicity that n is
odd and that edges are obtained using the partial derivatives.
(b) Show that the ratio of the maximum edge strength of the smoothed
image to the maximum edge strength of the original image is 1/n.
Solution
Roberts
operator
Laplacian
operator
• OpenCV
• cv.Canny( image, threshold1, threshold2)