Title: Edge Detection
1Computational Vision
- Edge Detection
- Canny Detector
- Line Detection
- Hough Transform
- Trucco Chapter 4, pp. 76 80
- Chapter 5, pp. 95 - 100
2Finding Corners
3What Is a Corner?
Large gradients in more than one direction.
4Edges vs. Corners
- Edges maxima in intensity gradient
5Edges vs. Corners
- Corners lots of variation in direction of
gradient in a small neighborhood
6Detecting Corners
- How to detect this variation?
7Detecting Corners
- How to detect this variation?
- Not enough to check average and
8Detecting Corners
- Claim the following covariance matrix summarizes
the statistics of the gradientSummations
over local neighborhoods
9Detecting Corners
- Examine behavior of C by testing its effect in
simple cases - Case 1 Single edge in local neighborhood
10Case1 Single Edge
- Let (a,b) be gradient along edge
- Compute C? (a,b)
11Case 1 Single Edge
- However, in this simple case, the only nonzero
terms are those where ?f (a,b) - So, C? (a,b) is just some multiple of (a,b)
12Case 2 Corner
- Assume there is a corner, with perpendicular
gradients (a,b) and (c,d)
13Case 2 Corner
- What is C? (a,b)?
- Since (a,b) ? (c,d) 0, the only nonzero terms
are those where ?f (a,b) - So, C? (a,b) is again just a multiple of (a,b)
- What is C? (c,d)?
- Since (a,b) ? (c,d) 0, the only nonzero terms
are those where ?f (c,d) - So, C? (c,d) is a multiple of (c,d)
14Corner Detection
- Matrix times vector multiple of vector
- Eigenvectors and eigenvalues!
- In particular, if C has one large eigenvalue,
theres an edge - If C has two large eigenvalues, have corner
- Tomasi-Kanade corner detector
15Corner Detection Implementation
- Compute image gradient
- For each m?m neighborhood,compute matrix C
- If smaller eigenvalue ?2 is larger thanthreshold
?, record a corner - Nonmaximum suppression only keep strongest
corner in each m?m window
16Corner Detection Results
Trucco Verri
17Corner Detection Results
18Corner Detection Results
Histogram of l2 (smaller eigenvalue)
19A Simple Corner Detector
Find eigenvalues of C
If the smaller eigenvalue is above a threshold
then we have a corner.
20A Simple Corner Detector
Find eigenvalues of C
If the smaller eigenvalue is above a threshold
then we have a corner.
21A Simple Corner Detector
22Canny Edge Detection
- Can we derive an optimal detector?
- Good Detection minimize false positives and
false negatives. - Good Localization close as possible to the true
edges. - Single Response Constraint one edge should be
detected for each true edge
23Comparison
Canny
Sobel
24Canny Edge Detection
- 3 STEPS
- CANNY_ENHANCER
- NONMAX_SUPPRESION
- HYSTERESIS_THRESH
25Localization-Detection Tradeoff
- Filters spatial scale
- Location
- Detection criteria.
- Good tradeoff 1-D step edge detector
- (optimal)
- Approximated by the 1st derivative of the
Gaussian.
26Optimal 1-D step edge detectors
Pixel (i,j)
Keep the one that gives you maximum
response. Expensive.
27Solution
y
x
Pixel (i,j)
Compute derivatives with respect to x y
directions. Compute edge normal.
28CANNY_ENHANCER
- Compute Ix and Iy the gradient of the image using
a derivative of Gaussian filter. - Compute the edge strength from the magnitude of
the gradient Es - Compute the orientation of the edge from
arctan(Iy / Ix ) Eo
Canny 86
n
29Problem with detector
gradient magnitude (Es)
original image
- Compute image derivatives
- if gradient magnitude gt ? and the value is a
local max. along gradient - direction pixel is an edge candidate
- how to detect one pixel thin edges ?
30NONMAX_SUPPRESSION
- Locate local maxima from Es.
- Find direction d that best approximates Eo(i,j)
- If Es(i,j) is smaller than at least one neighbor
along d In(i,j)0 else In(i,j)Es(i,j).
90
135
45
0
31Non-Maximum Supression
Non-maximum suppression Select the single
maximum point across the width of an edge.
32Linking to the Next Edge Point
Assume the marked point q is an edge point.
Take the normal to the gradient at that point
and use this to predict continuation points
(either r or p).
33Thresholding
- Edges are found by thresholding the output of
NONMAX_SUPRESSION - If the threshold is too high
- Very few (none) edges
- High MISDETECTIONS, many gaps
- If the threshold is too low
- Too many (all pixels) edges
- High FALSE POSITIVES, many extra edges
34Edge Detection With Hysteresis
Low threshold
High threshold
Hysteresis (high and low threshold)
35Edge Hysteresis
- Hysteresis A lag or momentum factor
- Idea Maintain two thresholds khigh and klow
- 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
36Edge Tracking
Hysteresis thresholding Canny 86
edges
Strong edges reinforce weak edges.
Weak edge removed
We call a pixel an edge if it is strong. We also
call a pixel an edge if it is weak but is
connected to an edge. A pixel is connected to an
edge if it is in a direction perpendicular to the
edge normal
37Canny Edge Detection (Example)
Strong connected weak edges
Original image
Strong edges only
Weak edges
courtesy of G. Loy
38HYSTERESIS_THRESH
- Input In, Eo, high threshold, low threshold.
- Output Lists of connected edges (contours).
39Edge Relaxation
Parallel iterative method to adjust edge values
on the basis of neighboring edges
Crack edges
40Edge Relaxation
Parallel iterative method to adjust edge values
on the basis of neighboring edges
Notation
Crack edges
Edge to be updated
Edge
No edge
Vertex types
(0)
(1)
(2)
(3)
41Edge Relaxation
Parallel iterative method to adjust edge values
on the basis of neighboring edges
Notation
Crack edges
Edge to be updated
Edge
No edge
Vertex types
(0)
(1)
(2)
(3)
42Edge Relaxation
Parallel iterative method to adjust edge values
on the basis of neighboring edges
Notation
Crack edges
Algorithm
Edge to be updated
Edge
- 0. Compute initial confidence C0(e) of
- each edge e
-
- C0(e)
- k 1
- Compute edge type for all e
- Modify Ck(e) based on Ck-1(e) and
- edge type.
- If all Ck(e) have converged to 1 or 0
- else go to step 1
No edge
Vertex types
(0)
(1)
(2)
(3)
43Canny Edge Detector
Original Lena
Edges
44Towards Global Features
Local versus global
45From Edges to Lines
46Detecting Lines
- What is the difference between line detection and
edge detection? - Edges local
- Lines nonlocal
- Line detection usually performed on the output of
an edge detector
From Szymon Rusinkiewicz, Princeton
47Detecting Lines
From Szymon Rusinkiewicz, Princeton
48Detecting Lines
- Possible approaches
- Brute force enumerate all lines, check if
present - Hough transform vote for lines to which detected
edges might belong - Fitting given guess for approximate location,
refine it - Second method efficient for finding unknown
lines, but not always accurate
From Szymon Rusinkiewicz, Princeton
49Hough Transform
- General idea transform from image coordinates to
parameter space of feature - Need parameterized model of features
- For each pixel, determine all parameter values
that might have given rise to that pixel vote - At end, look for peaks in parameter space
From Szymon Rusinkiewicz, Princeton
50Hough Transform for Lines
- Generic line y axb
- Parameters a and b
From Szymon Rusinkiewicz, Princeton
51Hough Transform for Lines
- Initialize table of buckets, indexed bya and b,
to zero - For each detected edge pixel (x,y)
- Determine all (a,b) such that y axb
- Increment bucket (a,b)
- Buckets with many votes indicate probable lines
From Szymon Rusinkiewicz, Princeton
52Hough Transform for Lines
a
b
From Szymon Rusinkiewicz, Princeton
53Hough Transform for Lines
a
b
From Szymon Rusinkiewicz, Princeton
54Difficulties withHough Transform for Lines
- Slope / intercept parameterization not ideal
- Non-uniform sampling of directions
- Cant represent vertical lines
- Angle / distance parameterization
- Line represented as (r,q) wherex cos q y sin q
r
r
q
From Szymon Rusinkiewicz, Princeton
55Finding Lines Using the Hough Transform
56Algorithm
- Discretize the parameter spaces ? and ?.
- Create Accumulator array A(1..R,1..T).
- Set A(k,h)0 for all k and h.
- For each image edge E(i,j)1
- For h1T
- ? i cos?d(h)j sin?d (h)
- Find index k ?d is closest to ?
- Increment A(h,k) by one.
- Find all local maxima (kp, hp) such that A (kp,
hp)gtt
57Hough Transform Results
Forsyth Ponce
58Hough Transform Results
Forsyth Ponce
59Finding Lines Using the Hough Transform
Strong local peaks correspond to lines.
60Finding Lines Using the Hough Transform
Resolution Issues
61Bucket Selection
- How to select bucket size?
From Szymon Rusinkiewicz, Princeton
62Bucket Selection
- How to select bucket size?
- Too small poor performance on noisy data, long
running times - Too large poor accuracy, possibility of false
positives - Large buckets verification and refinement
- Problems distinguishing nearby lines
- Be smarter at selecting buckets
- Use gradient information to select subset of
buckets - More sensitive to noise
From Szymon Rusinkiewicz, Princeton
63Hough Transform Results
Hough Transform
Image
Edge detection
64Summary Hough Transform
- Smart counting
- Local evidence for global features
- Organized in a table
- Careful with parameterization!
- Problem Curse of dimensionality
- Works great for simple features with 3 unknowns
- Will fail for complex objects
- Problem Not a local algorithm
65Hough Transform
- What else can be detected usingHough transform?
66Hough Transform
- What else can be detected usingHough transform?
- Anything, but dimensionality is key
67Finding Circles by Hough Transform
y
r
b0
(xi,yi)
x
a0
Equation of Circle
68Finding Circles by Hough Transform
y
r
b0
(xi,yi)
x
a0
Equation of Circle
Circles!
If radius r is known
b
y
(xi,yi)
x
a
Accumulator array A(a,b)
69Finding Circles by Hough Transform
y
r
b0
(xi,yi)
x
a0
If r is not known Use accumulator array
A(a,b,r) For each (xi,yi) increment A(a,b,r)
such that
70Using Gradient Information
Can save lot of computations!
Given location (xi,yi) Edge direction fi
y
x
71Using Gradient Information
Can save lot of computations!
Given location (xi,yi) Edge direction fi
y
x
Assume r is known
ax-rcosf by-rsinf Need to increment only one
point in Accumulator Array.
(xi,yi)
y
fi
(a,b)
x
72Hough Transform for Curves
- Curve yf(x,a)
- aa1, , ap the parameters of the curve.
- Limitation size of parameter space wrt of
parameters. - Solution variable-resolution parameter space.
73Hough Transform
- Pattern Matching.
- More efficient than template matching.
- Handles occlusion.
- Finds all instances of pattern.
- Handling inaccurate edge locations?
- Drawbacks?
74Fitting
- Output of Hough transform often not accurate
enough - Use as initial guess for fitting
75Fitting Lines
76Fitting Lines
Least-squares minimization
77Fitting Lines
78Finding Lines
- Assume edge detection
- Each pixel is either edge or not
- How do we find the line?
79Finding Lines
- Assume edge detection
- Each pixel is either edge or not
- How do we find the line?
80Least Squares Fitting of Lines
Minimize E
81Least Squares Fitting of Lines
Minimize E
Problem E must be formulated carefully!
82Least Squares Fitting of Lines
Minimize E