3-D Computer Vision CSc Feature Detection and Grouping
CSc D Computer Vision – Ioannis Stamos Finding Corners
CSc D Computer Vision – Ioannis Stamos What Is a Corner? Large gradients in more than one direction.
CSc 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.
CSc 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.
CSc D Computer Vision – Ioannis Stamos A Simple Corner Detector
CSc D Computer Vision – Ioannis Stamos Sobel Operator S1=S1=S 2 = Edge Magnitude = Edge Direction = S 1 + S tan -1 S1S1 S2S2
CSc D Computer Vision – Ioannis Stamos Sobel in Matlab
CSc D Computer Vision – Ioannis Stamos Canny Edge Detector
CSc D Computer Vision – Ioannis Stamos Comparison CannySobel
CSc D Computer Vision – Ioannis Stamos Canny Edge Detection Steps: Steps: 1. Apply derivative of Gaussian 2. Non-maximum suppression Thin multi-pixel wide “ridges” down to single pixel width Thin multi-pixel wide “ridges” down to single pixel width 3. Linking and thresholding Low, high edge-strength thresholds Low, high edge-strength thresholds Accept all edges over low threshold that are connected to edge over high threshold Accept all edges over low threshold that are connected to edge over high threshold
CSc D Computer Vision – Ioannis Stamos Non-Maximum Supression Non-maximum suppression: Select the single maximum point across the width of an edge.
CSc 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).
CSc 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
CSc 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
CSc D Computer Vision – Ioannis Stamos Canny Edge Detection (Example) Using Matlab with default thresholds
CSc D Computer Vision – Ioannis Stamos Bridge Example Again edge(im,’canny’)
CSc D Computer Vision – Ioannis Stamos Summary: Canny Edge Detection Most commonly used method Most commonly used method Traces edges, accommodates variations in contrast Traces edges, accommodates variations in contrast Not a linear filter! Not a linear filter! Problems with corners Problems with corners
CSc D Computer Vision – Ioannis Stamos Towards Global Features Local versus global
CSc D Computer Vision – Ioannis Stamos From Edges to Lines
CSc D Computer Vision – Ioannis Stamos Finding Lines Assume edge detection Assume edge detection Each pixel is either edge or not Each pixel is either edge or not How do we find the line? How do we find the line?
CSc D Computer Vision – Ioannis Stamos Finding Lines Assume edge detection Assume edge detection Each pixel is either edge or not Each pixel is either edge or not How do we find the line? How do we find the line?
CSc D Computer Vision – Ioannis Stamos Least Squares Fitting of Lines Minimize E
CSc D Computer Vision – Ioannis Stamos Least Squares Fitting of Lines Minimize E Problem: E must be formulated carefully!
CSc D Computer Vision – Ioannis Stamos Least Squares Fitting of Lines Minimize E
CSc D Computer Vision – Ioannis Stamos Hough Transform y x
CSc D Computer Vision – Ioannis Stamos m Hough Transform: Quantization Detecting Lines by finding maxima / clustering in parameter space x y
CSc D Computer Vision – Ioannis Stamos Hough Transform: Algorithm For each image point, determine For each image point, determine most likely line parameters b,m (direction of gradient) most likely line parameters b,m (direction of gradient) strength (magnitude of gradient) strength (magnitude of gradient) Increment parameter counter by strength value Increment parameter counter by strength value Cluster in parameter space, pick local maxima Cluster in parameter space, pick local maxima
CSc D Computer Vision – Ioannis Stamos Hough Transform: Results Hough TransformImageEdge detection
CSc D Computer Vision – Ioannis Stamos Finding Lines Using the Hough Transform
CSc D Computer Vision – Ioannis StamosAlgorithm Discretize the parameter spaces ρ and θ. Discretize the parameter spaces ρ and θ. Create Accumulator array A(1..R,1..T). Create Accumulator array A(1..R,1..T). Set A(k,h)=0 for all k and h. Set A(k,h)=0 for all k and h. For each image edge E(i,j)=1 For each image edge E(i,j)=1 For h=1…T For h=1…T ρ =i cosθ d (h)+j sinθ d (h) ρ =i cosθ d (h)+j sinθ d (h) Find index k: ρ d is closest to ρ Find index k: ρ d is closest to ρ Increment A(h,k) by one. Increment A(h,k) by one. Find all local maxima (k p, h p ) such that A (k p, h p )>τ Find all local maxima (k p, h p ) such that A (k p, h p )>τ
CSc D Computer Vision – Ioannis Stamos Finding Lines Using the Hough Transform Strong local peaks correspond to lines.
CSc D Computer Vision – Ioannis Stamos Finding Lines Using the Hough Transform Resolution Issues …
CSc D Computer Vision – Ioannis Stamos From Forsyth and Ponce
CSc D Computer Vision – Ioannis Stamos Summary Hough Transform Smart counting Smart counting Local evidence for global features Local evidence for global features Organized in a table Organized in a table Careful with parameterization! Careful with parameterization! Problem: Curse of dimensionality Problem: Curse of dimensionality Works great for simple features with 3 unknowns Works great for simple features with 3 unknowns Will fail for complex objects Will fail for complex objects Problem: Not a local algorithm Problem: Not a local algorithm
CSc D Computer Vision – Ioannis Stamos Finding Circles by Hough Transform a0a0 b0b0 r (x i,y i ) Equation of Circle: x y
CSc D Computer Vision – Ioannis Stamos 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)
CSc 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
CSc D Computer Vision – Ioannis Stamos Using Gradient Information Can save lot of computations! Given: location (x i,y i ) Edge direction φ i x y
CSc D Computer Vision – Ioannis Stamos 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 φiφi (x i,y i ) a=x-rcosφ b=y-rsinφ Need to increment only one point in Accumulator Array. (a,b)
CSc D Computer Vision – Ioannis Stamos Hough Transform for Curves Curve y=f(x,a) Curve y=f(x,a) a=[a 1, …, a p ] the parameters of the curve. a=[a 1, …, a p ] the parameters of the curve. Limitation: size of parameter space wrt # of parameters. Limitation: size of parameter space wrt # of parameters. Solution: variable-resolution parameter space. Solution: variable-resolution parameter space.
CSc D Computer Vision – Ioannis Stamos Hough Transform Pattern Matching. Pattern Matching. More efficient than template matching. More efficient than template matching. Handles occlusion. Handles occlusion. Finds all instances of pattern. Finds all instances of pattern. Handling inaccurate edge locations? Handling inaccurate edge locations? Drawbacks? Drawbacks?