lecture 08 - finding edges and straight lines - vision_spring2011
DESCRIPTION
lecture edge findingTRANSCRIPT
![Page 1: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/1.jpg)
Finding Edges and Straight Lines
Computer VisionCS 543 / ECE 549
University of Illinois
Derek Hoiem
02/10/11
Many slides from Lana Lazebnik, Steve Seitz, David Forsyth, David Lowe, Fei-Fei Li
![Page 2: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/2.jpg)
Last class
• How to use filters for– Matching– Denoising– Compression
• Image representation with pyramids
• Texture and filter banks
![Page 3: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/3.jpg)
A couple remaining questions from earlier
• Does the curvature of the earth change the horizon location?
Illustrations from Amin Sadeghi
![Page 4: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/4.jpg)
A couple remaining questions from earlier
• Computational complexity of coarse-to-fine search?
Image 1 Pyramid
Size NSize M
Low Resolution Search O(N/M)
Repeated Local Neighborhood Search O(M)
Downsampling: O(N+M)
Image 2 Pyramid
Overall complexity: O(N+M)Original high-resolution full search: O(NM) or O(N logN)
![Page 5: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/5.jpg)
A couple remaining questions from earlier
• Why not use an ideal filter?
Attempt to apply ideal filter in frequency domain
Answer: has infinite spatial extent, clipping results in ringing
![Page 6: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/6.jpg)
Today’s class
• Detecting edges
• Finding straight lines
![Page 7: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/7.jpg)
Why do we care about edges?
• Extract information, recognize objects
• Recover geometry and viewpoint
Vanishingpoint
Vanishingline
Vanishingpoint
Vertical vanishingpoint
(at infinity)
![Page 8: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/8.jpg)
Origin of Edges
• Edges are caused by a variety of factors
depth discontinuity
surface color discontinuity
illumination discontinuity
surface normal discontinuity
Source: Steve Seitz
![Page 9: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/9.jpg)
Closeup of edges
![Page 10: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/10.jpg)
Closeup of edges
![Page 11: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/11.jpg)
Closeup of edges
![Page 12: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/12.jpg)
Closeup of edges
![Page 13: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/13.jpg)
Characterizing edges• An edge is a place of rapid change in the
image intensity function
imageintensity function
(along horizontal scanline) first derivative
edges correspond toextrema of derivative
![Page 14: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/14.jpg)
Intensity profile
![Page 15: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/15.jpg)
With a little Gaussian noise
Gradient
![Page 16: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/16.jpg)
Effects of noise• Consider a single row or column of the image
– Plotting intensity as a function of position gives a signal
Where is the edge?Source: S. Seitz
![Page 17: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/17.jpg)
Effects of noise• Difference filters respond strongly to noise
– Image noise results in pixels that look very different from their neighbors
– Generally, the larger the noise the stronger the response
• What can we do about it?
Source: D. Forsyth
![Page 18: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/18.jpg)
Solution: smooth first
• To find edges, look for peaks in )( gfdxd
∗
f
g
f * g
)( gfdxd
∗
Source: S. Seitz
![Page 19: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/19.jpg)
• Differentiation is convolution, and convolution is associative:
• This saves us one operation:
gdxdfgf
dxd
∗=∗ )(
Derivative theorem of convolution
gdxdf ∗
f
gdxd
Source: S. Seitz
![Page 20: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/20.jpg)
Derivative of Gaussian filter
• Is this filter separable?
* [1 -1] =
![Page 21: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/21.jpg)
• Smoothed derivative removes noise, but blurs edge. Also finds edges at different “scales”.
1 pixel 3 pixels 7 pixels
Tradeoff between smoothing and localization
Source: D. Forsyth
![Page 22: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/22.jpg)
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
![Page 23: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/23.jpg)
Canny edge detector
• This is probably the most widely used edge detector in computer vision
• Theoretical model: step-edges corrupted by additive Gaussian noise
• 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
J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.
Source: L. Fei-Fei
![Page 24: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/24.jpg)
Example
original image (Lena)
![Page 25: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/25.jpg)
Derivative of Gaussian filter
x-direction y-direction
![Page 26: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/26.jpg)
Compute Gradients (DoG)
X-Derivative of Gaussian Y-Derivative of Gaussian Gradient Magnitude
![Page 27: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/27.jpg)
Get Orientation at Each Pixel• Threshold at minimum level• Get orientation
theta = atan2(gy, gx)
![Page 28: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/28.jpg)
Non-maximum suppression for each orientation
At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values.
Source: D. Forsyth
![Page 29: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/29.jpg)
Before Non-max Suppression
![Page 30: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/30.jpg)
After non-max suppression
![Page 31: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/31.jpg)
Hysteresis thresholding
• Threshold at low/high levels to get weak/strong edge pixels• Do connected components, starting from strong edge pixels
![Page 32: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/32.jpg)
Hysteresis thresholding
• Check that maximum value of gradient value is sufficiently large– drop-outs? use hysteresis
• use a high threshold to start edge curves and a low threshold to continue them.
Source: S. Seitz
![Page 33: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/33.jpg)
Final Canny Edges
![Page 34: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/34.jpg)
Canny edge detector1. Filter image with x, y derivatives of Gaussian 2. Find magnitude and orientation of gradient3. Non-maximum suppression:
– Thin multi-pixel wide “ridges” down to single pixel width
4. Thresholding and linking (hysteresis):– Define two thresholds: low and high– Use the high threshold to start edge curves and the low
threshold to continue them
• MATLAB: edge(image, ‘canny’)
Source: D. Lowe, L. Fei-Fei
![Page 35: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/35.jpg)
Effect of σ (Gaussian kernel spread/size)
Canny with Canny with original
The choice of σ depends on desired behavior• large σ detects large scale edges• small σ detects fine features
Source: S. Seitz
![Page 36: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/36.jpg)
Learning to detect boundaries
• Berkeley segmentation database:http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
image human segmentation gradient magnitude
![Page 37: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/37.jpg)
pB boundary detector
Figure from Fowlkes
Martin, Fowlkes, Malik 2004: Learning to Detection Natural Boundaries…http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/papers/mfm-pami-boundary.pdf
![Page 38: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/38.jpg)
pB Boundary Detector
Figure from Fowlkes
![Page 39: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/39.jpg)
Brightness
Color
Texture
Combined
Human
![Page 40: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/40.jpg)
Finding straight lines
• One solution: try many possible lines and see how many points each line passes through
• Hough transform provides a fast way to do this
![Page 41: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/41.jpg)
Outline of Hough Transform
1. Create a grid of parameter values
2. Each point votes for a set of parameters, incrementing those values in grid
3. Find maximum or local maxima in grid
![Page 42: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/42.jpg)
Finding lines using Hough transform• Using m,b parameterization• Using r, theta parameterization
– Using oriented gradients
• Practical considerations– Bin size– Smoothing– Finding multiple lines– Finding line segments
![Page 43: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/43.jpg)
1. Image Canny
![Page 44: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/44.jpg)
2. Canny Hough votes
![Page 45: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/45.jpg)
3. Hough votes Edges
Find peaks and post-process
![Page 46: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/46.jpg)
Hough transform example
http://ostatic.com/files/images/ss_hough.jpg
![Page 47: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/47.jpg)
Finding circles using Hough transform• Fixed r• Variable r
![Page 48: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/48.jpg)
Finding straight lines
• Another solution: get connected components of pixels and check for straightness
![Page 49: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/49.jpg)
Finding line segments using connected components
1. Compute canny edges– Compute: gx, gy (DoG in x,y directions)– Compute: theta = atan(gy / gx)
2. Assign each edge to one of 8 directions3. For each direction d, get edgelets:
– find connected components for edge pixels with directions in {d-1, d, d+1}
4. Compute straightness and theta of edgelets using eig of x,y2nd moment matrix of their points
5. Threshold on straightness, store segment
( ) ( )( )( )( ) ( )
−−−−−−
=∑∑
∑∑2
2
yyx
yxx
yyxyxxµµµ
µµµM )eig(],[ Μ=λv
))2,1(),2,2(2(atan vv=θ
12 /λλ=conf
Larger eigenvector
![Page 50: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/50.jpg)
1. Image Canny
![Page 51: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/51.jpg)
2. Canny lines … straight edges
![Page 52: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/52.jpg)
Hough Transform Method
Comparison
Connected Components Method
![Page 53: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/53.jpg)
Things to remember• Canny edge detector =
smooth derivative thin threshold link
• Generalized Hough transform = points vote for shape parameters
• Straight line detector = canny + gradient orientations orientation binning linking check for straightness
![Page 54: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/54.jpg)
Next classes
• Fitting and Registration
• Clustering
• EM (mixture models)
![Page 55: Lecture 08 - Finding Edges and Straight Lines - Vision_Spring2011](https://reader034.vdocument.in/reader034/viewer/2022051623/55cf881755034664618d413e/html5/thumbnails/55.jpg)
Questions