Computational Vision / Ioannis Stamos  Edge Detection  Canny Detector  Line Detection  Hough Transform  Trucco: Chapter 4, pp. 76 – 80 Chapter 5,

Download Computational Vision / Ioannis Stamos  Edge Detection  Canny Detector  Line Detection  Hough Transform  Trucco: Chapter 4, pp. 76 – 80 Chapter 5,

Post on 13-Dec-2015

212 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

<ul><li>Slide 1</li></ul> <p>Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 80 Chapter 5, pp. 95 - 100 Chapter 5, pp. 95 - 100 Computational Vision Slide 2 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Corners Slide 3 CSc 83020 3-D Computer Vision Ioannis Stamos What Is a Corner? Large gradients in more than one direction. Slide 4 Edges vs. Corners Edges = maxima in intensity gradient Slide 5 Edges vs. Corners Corners = lots of variation in direction of gradient in a small neighborhood Slide 6 Detecting Corners How to detect this variation? Slide 7 Detecting Corners How to detect this variation? Not enough to check average and Slide 8 Detecting Corners Claim: the following covariance matrix summarizes the statistics of the gradient Summations over local neighborhoods Slide 9 Detecting Corners Examine behavior of C by testing its effect in simple cases Case #1: Single edge in local neighborhood Slide 10 Case#1: Single Edge Let (a,b) be gradient along edge Compute C (a,b): Slide 11 Case #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) Slide 12 Case #2: Corner Assume there is a corner, with perpendicular gradients (a,b) and (c,d) Slide 13 Case #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) Slide 14 Corner 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 Slide 15 Corner Detection Implementation 1. Compute image gradient 2. For each m m neighborhood, compute matrix C 3. If smaller eigenvalue 2 is larger than threshold , record a corner 4. Nonmaximum suppression: only keep strongest corner in each m m window Slide 16 Corner Detection Results Checkerboard with noise Trucco &amp; Verri Slide 17 Corner Detection Results Slide 18 Histogram of 2 (smaller eigenvalue ) Slide 19 CSc 83020 3-D Computer Vision Ioannis Stamos A Simple Corner Detector Find eigenvalues of C If the smaller eigenvalue is above a threshold then we have a corner. Slide 20 CSc 83020 3-D Computer Vision Ioannis Stamos A Simple Corner Detector Find eigenvalues of C If the smaller eigenvalue is above a threshold then we have a corner. Slide 21 CSc 83020 3-D Computer Vision Ioannis Stamos A Simple Corner Detector Slide 22 Canny 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 Slide 23 CSc 83020 3-D Computer Vision Ioannis Stamos Comparison CannySobel Slide 24 Canny Edge Detection 3 STEPS: CANNY_ENHANCER NONMAX_SUPPRESION HYSTERESIS_THRESH Slide 25 Localization-Detection Tradeoff Filters spatial scale Location &amp; Detection criteria. Good tradeoff 1-D step edge detector: (optimal) (optimal) Approximated by the 1 st derivative of the Gaussian. Slide 26 Optimal 1-D step edge detectors Pixel (i,j) Keep the one that gives you maximum response. Expensive. Slide 27 Solution Pixel (i,j) Compute derivatives with respect to x &amp; y directions. Compute edge normal. x y Slide 28 CANNY_ENHANCER Compute I x and I y 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(I y / I x ): Eo [Canny 86] n Slide 29 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 ? gradient magnitude (Es) original image Problem with detector Slide 30 NONMAX_SUPPRESSION 0 45 90 135 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). Slide 31 CSc 83020 3-D Computer Vision Ioannis Stamos Non-Maximum Supression Non-maximum suppression: Select the single maximum point across the width of an edge. Slide 32 CSc 83020 3-D Computer Vision Ioannis Stamos Linking 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). Slide 33 Thresholding 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 Slide 34 Edge Detection With Hysteresis Low thresholdHigh threshold Hysteresis (high and low threshold) Slide 35 CSc 83020 3-D Computer Vision Ioannis Stamos Edge Hysteresis Hysteresis: A lag or momentum factor Hysteresis: A lag or momentum factor Idea: Maintain two thresholds k high and k low Idea: Maintain two thresholds k high and k low Use k high to find strong edges to start edge chain Use k high to find strong edges to start edge chain Use k low to find weak edges which continue edge chain Use k low to find weak edges which continue edge chain Typical ratio of thresholds is roughly Typical ratio of thresholds is roughly k high / k low = 2 k high / k low = 2 Slide 36 Edge Tracking Hysteresis thresholding [Canny 86] Strong edge Weak edges Strong edges reinforce weak edges. 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 Weak edge removed edges Slide 37 CSc 83020 3-D Computer Vision Ioannis Stamos Canny Edge Detection (Example) courtesy of G. Loy gap is gone Original image Strong edges only Strong + connected weak edges Weak edges Slide 38 HYSTERESIS_THRESH Input: In, Eo, high threshold, low threshold. Output: Lists of connected edges (contours). Slide 39 Edge Relaxation Parallel iterative method to adjust edge values on the basis of neighboring edges Crack edges: Slide 40 Edge Relaxation Parallel iterative method to adjust edge values on the basis of neighboring edges Vertex types: Notation: Edge to be updated Edge No edge Crack edges: (0) (1) (2) (3) Slide 41 Edge Relaxation Parallel iterative method to adjust edge values on the basis of neighboring edges Vertex types: Notation: Edge to be updated Edge No edge Crack edges: (0) (1) (2) (3) Action table for edge type: Decrease Increase Unchanged 0-01-10-1 0-21-22-2 0-31-32-3 3-3 Slide 42 Edge Relaxation Parallel iterative method to adjust edge values on the basis of neighboring edges Vertex types: Notation: Edge to be updated Edge No edge Crack edges: (0) (1) (2) (3) Action table for edge type: Decrease Increase Unchanged 0-01-10-1 0-21-22-2 0-31-32-3 3-3 Algorithm: 0. Compute initial confidence C 0 (e) of each edge e C 0 (e) = 1.k = 1 2.Compute edge type for all e 3.Modify C k (e) based on C k-1 (e) and edge type. 4.If all C k (e) have converged to 1 or 0 else go to step 1 Slide 43 Computational Vision / Ioannis Stamos Canny Edge Detector Original: Lena Edges Slide 44 CSc 83020 3-D Computer Vision Ioannis Stamos Towards Global Features Local versus global Slide 45 CSc 83020 3-D Computer Vision Ioannis Stamos From Edges to Lines Slide 46 Detecting 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 Slide 47 Detecting Lines Possible approaches ? From Szymon Rusinkiewicz, Princeton Slide 48 Detecting 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 Slide 49 Hough 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 spac e From Szymon Rusinkiewicz, Princeton Slide 50 Hough Transform for Lines Generic line: y = ax+b Parameters: a and b From Szymon Rusinkiewicz, Princeton Slide 51 Hough Transform for Lines 1. Initialize table of buckets, indexed by a and b, to zero 2. For each detected edge pixel (x,y): a.Determine all (a,b) such that y = ax+b b.Increment bucket (a,b) 3. Buckets with many votes indicate probable lines From Szymon Rusinkiewicz, Princeton Slide 52 Hough Transform for Lines b a From Szymon Rusinkiewicz, Princeton Slide 53 Hough Transform for Lines b a From Szymon Rusinkiewicz, Princeton Slide 54 Difficulties with Hough Transform for Lines Slope / intercept parameterization not ideal Non-uniform sampling of directions Cant represent vertical lines Angle / distance parameterization Line represented as (r, ) where x cos + y sin = r r From Szymon Rusinkiewicz, Princeton Slide 55 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Lines Using the Hough Transform Slide 56 CSc 83020 3-D Computer Vision Ioannis StamosAlgorithm 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 h=1T =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 (k p, h p ) such that A (k p, h p )&gt; Slide 57 Hough Transform Results Forsyth &amp; Ponce Slide 58 Hough Transform Results Forsyth &amp; Ponce Slide 59 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Lines Using the Hough Transform Strong local peaks correspond to lines. Slide 60 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Lines Using the Hough Transform Resolution Issues Slide 61 Bucket Selection How to select bucket size? From Szymon Rusinkiewicz, Princeton Slide 62 Bucket 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 Slide 63 CSc 83020 3-D Computer Vision Ioannis Stamos Hough Transform: Results Hough TransformImageEdge detection Slide 64 CSc 83020 3-D Computer Vision Ioannis Stamos Summary 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 Slide 65 Hough Transform What else can be detected using Hough transform? Slide 66 Hough Transform What else can be detected using Hough transform? Anything, but dimensionality is key Slide 67 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Circles by Hough Transform a0a0 b0b0 r (x i,y i ) Equation of Circle: x y Slide 68 Finding Circles by Hough Transform a0a0 b0b0 r (x i,y i ) Equation of Circle: If radius r is known: x y x y a b (x i,y i ) Circles! Accumulator array A(a,b) Slide 69 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Circles by Hough Transform a0a0 b0b0 r (x i,y i ) x y If r is not known Use accumulator array A(a,b,r) For each (x i,y i ) increment A(a,b,r) such that Slide 70 CSc 83020 3-D Computer Vision Ioannis Stamos Using Gradient Information Can save lot of computations! Given: location (x i,y i ) Edge direction i x y Slide 71 Using Gradient Information Can save lot of computations! Given: location (x i,y i ) Edge direction i x y Assume r is known: x y ii (x i,y i ) a=x-rcos b=y-rsin Need to increment only one point in Accumulator Array. (a,b) Slide 72 CSc 83020 3-D Computer Vision Ioannis Stamos Hough Transform for Curves Curve y=f(x,a) a=[a 1, , a p ] the parameters of the curve. Limitation: size of parameter space wrt # of parameters. Solution: variable-resolution parameter space. Slide 73 Hough Transform Pattern Matching. More efficient than template matching. Handles occlusion. Finds all instances of pattern. Handling inaccurate edge locations? Drawbacks? Slide 74 Fitting Output of Hough transform often not accurate enough Use as initial guess for fitting Slide 75 Fitting Lines Initial guess Slide 76 Fitting Lines Least-squaresminimization Slide 77 Slide 78 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Lines Assume edge detection Each pixel is either edge or not How do we find the line? Slide 79 CSc 83020 3-D Computer Vision Ioannis Stamos Finding Lines Assume edge detection Each pixel is either edge or not How do we find the line? Slide 80 CSc 83020 3-D Computer Vision Ioannis Stamos Least Squares Fitting of Lines Minimize E Slide 81 Least Squares Fitting of Lines Minimize E Problem: E must be formulated carefully! Slide 82 Least Squares Fitting of Lines Minimize E </p>