Fitting: Voting and the Hough Transform April 23 rd, Yong Jae Lee UC Davis

Similar documents
Finding 2D Shapes and the Hough Transform

Prof. Kristen Grauman

Lecture 8: Fitting. Tuesday, Sept 25

Lecture 9: Hough Transform and Thresholding base Segmentation

Announcements, schedule. Lecture 8: Fitting. Weighted graph representation. Outline. Segmentation by Graph Cuts. Images as graphs

Example: Line fitting. Difficulty of line fitting. Fitting lines. Fitting lines. Fitting lines. Voting 9/22/2009

Fitting: Voting and the Hough Transform

Fitting. Lecture 8. Cristian Sminchisescu. Slide credits: K. Grauman, S. Seitz, S. Lazebnik, D. Forsyth, J. Ponce

Elaborazione delle Immagini Informazione Multimediale. Raffaella Lanzarotti

Lecture 4: Finding lines: from detection to model fitting

Fitting: The Hough transform

Fitting: The Hough transform

Fitting: The Hough transform

Segmentation and Grouping April 19 th, 2018

Model Fitting: The Hough transform II

Segmentation and Grouping April 21 st, 2015

Part-based and local feature models for generic object recognition

Segmentation. Bottom Up Segmentation

Model Fitting: The Hough transform I

Outline. Segmentation & Grouping. Examples of grouping in vision. Grouping in vision. Grouping in vision 2/9/2011. CS 376 Lecture 7 Segmentation 1

Grouping and Segmentation

HOUGH TRANSFORM CS 6350 C V

Segmentation and Grouping

Previously. Part-based and local feature models for generic object recognition. Bag-of-words model 4/20/2011

Computer Vision Lecture 6

Announcements. Edges. Last Lecture. Gradients: Numerical Derivatives f(x) Edge Detection, Lines. Intro Computer Vision. CSE 152 Lecture 10

Segmentation (continued)

EECS 442 Computer vision. Fitting methods

Computer Vision Lecture 6

Straight Lines and Hough

Lecture 8 Fitting and Matching

CS 4495 Computer Vision. Segmentation. Aaron Bobick (slides by Tucker Hermans) School of Interactive Computing. Segmentation

Image Segmentation continued Graph Based Methods. Some slides: courtesy of O. Capms, Penn State, J.Ponce and D. Fortsyth, Computer Vision Book

Edge detection. Convert a 2D image into a set of curves. Extracts salient features of the scene More compact than pixels

Multimedia Computing: Algorithms, Systems, and Applications: Edge Detection

Lecture 9 Fitting and Matching

CS 2770: Computer Vision. Edges and Segments. Prof. Adriana Kovashka University of Pittsburgh February 21, 2017

Feature Matching + Indexing and Retrieval

Object Detection. Sanja Fidler CSC420: Intro to Image Understanding 1/ 1

Fitting. Instructor: Jason Corso (jjcorso)! web.eecs.umich.edu/~jjcorso/t/598f14!! EECS Fall 2014! Foundations of Computer Vision!

Edge Detection. Announcements. Edge detection. Origin of Edges. Mailing list: you should have received messages

CS 2750: Machine Learning. Clustering. Prof. Adriana Kovashka University of Pittsburgh January 17, 2017

Edge Detection. CSE 576 Ali Farhadi. Many slides from Steve Seitz and Larry Zitnick

Hough Transform and RANSAC

The goals of segmentation

Image gradients and edges April 11 th, 2017

Other Linear Filters CS 211A

Image gradients and edges April 10 th, 2018

10/03/11. Model Fitting. Computer Vision CS 143, Brown. James Hays. Slides from Silvio Savarese, Svetlana Lazebnik, and Derek Hoiem

Segmentation & Grouping Kristen Grauman UT Austin. Announcements

Fitting a transformation: Feature-based alignment April 30 th, Yong Jae Lee UC Davis

Applications. Foreground / background segmentation Finding skin-colored regions. Finding the moving objects. Intelligent scissors

Edge Detection. EE/CSE 576 Linda Shapiro

Part based models for recognition. Kristen Grauman

Image Segmentation continued Graph Based Methods

Image gradients and edges

Image warping and stitching

Targil 12 : Image Segmentation. Image segmentation. Why do we need it? Image segmentation

CS 558: Computer Vision 4 th Set of Notes

Announcements. Segmentation (Part 2) Image Segmentation. From images to objects. Image histograms. What do histograms look like?

6.801/866. Segmentation and Line Fitting. T. Darrell

Segmentation (Part 2)

Image warping and stitching

Lecture 15: Segmentation (Edge Based, Hough Transform)

Computer Vision 6 Segmentation by Fitting

Feature Matching and Robust Fitting

Bias-Variance Trade-off (cont d) + Image Representations

HOUGH TRANSFORM. Plan for today. Introduction to HT. An image with linear structures. INF 4300 Digital Image Analysis

Lecture: RANSAC and feature detectors

Segmentation Computer Vision Spring 2018, Lecture 27

Edge linking. Two types of approaches. This process needs to be able to bridge gaps in detected edges due to the reason mentioned above

E0005E - Industrial Image Analysis

CS 534: Computer Vision Segmentation and Perceptual Grouping

Lecture 7: Segmentation. Thursday, Sept 20

Local features: detection and description May 12 th, 2015

Beyond Bags of features Spatial information & Shape models

Anno accademico 2006/2007. Davide Migliore

Generalized Hough Transform, line fitting

Image Segmentation. Selim Aksoy. Bilkent University

Image Segmentation. Selim Aksoy. Bilkent University

Discriminative classifiers for image recognition

Deformable Part Models

Feature Tracking and Optical Flow

Model Fitting. Introduction to Computer Vision CSE 152 Lecture 11

Normalized cuts and image segmentation

Edge and Texture. CS 554 Computer Vision Pinar Duygulu Bilkent University

Segmentation & Clustering

Feature Tracking and Optical Flow

GENERALIZING THE HOUGH TRANSFORM TO DETECT ARBITRARY SHAPES. D. H. Ballard Pattern Recognition Vol. 13 No

Instance-level recognition part 2

Edges and Binary Image Analysis April 12 th, 2018

Lecture: k-means & mean-shift clustering

Lecture: k-means & mean-shift clustering

Edge detection. Gradient-based edge operators

CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu. Lectures 21 & 22 Segmentation and clustering

Issues with Curve Detection Grouping (e.g., the Canny hysteresis thresholding procedure) Model tting They can be performed sequentially or simultaneou

Segmentation I: Edges and Lines

Edge and corner detection

human vision: grouping k-means clustering graph-theoretic clustering Hough transform line fitting RANSAC

Patch Descriptors. CSE 455 Linda Shapiro

Transcription:

Fitting: Voting and the Hough Transform April 23 rd, 2015 Yong Jae Lee UC Davis

Last time: Grouping Bottom-up segmentation via clustering To find mid-level regions, tokens General choices -- features, affinity functions, and clustering algorithms Example clustering algorithms Mean shift and mode finding: K-means, Mean shift Graph theoretic: Graph cut, normalized cuts Grouping also useful for quantization Texton histograms for texture within local region 2 Slide credit: Kristen Grauman

Recall: Images as graphs q p w pq w Fully-connected graph node for every pixel link between every pair of pixels, p,q similarity w pq for each link» similarity is inversely proportional to difference in color and position Slide by Steve Seitz 3

Points x 1 x 10 Last time: Measuring affinity 40 data points 40 x 40 affinity matrix A x 1. Points x 31 x 40.. x 40 x 1... x 40 1. What do the blocks signify? AA ii, jj = exp{ 1 2σσ 2 xx ii xx 2 jj } 2. What does the symmetry of the matrix signify? 3. How would the matrix change with larger value of σ? Slide credit: Kristen Grauman 4

Example: weighted graphs Feature dimension 2 Suppose we have a 4-pixel image (i.e., a 2 x 2 matrix) Each pixel described by 2 features Feature dimension 1 Dimension of data points : d = 2 Number of data points : N = 4 5 Kristen Grauman

Example: weighted graphs Computing the distance matrix: 0.01 D(1,:)= (0) 0.24 0.01 0.47 0.47 0.24 for i=1:n for j=1:n D(i,j) = x i - x j 2 end end 6 Kristen Grauman

Example: weighted graphs Computing the distance matrix: D(1,:)= (0) 0.24 0.01 0.47 0.24 0.29 0.24 (0) 0.29 0.15 0.15 for i=1:n for j=1:n D(i,j) = x i - x j 2 end end 7 Kristen Grauman

Example: weighted graphs Computing the distance matrix: for i=1:n for j=1:n D(i,j) = x i - x j 2 end end N x N matrix 8 Kristen Grauman

Example: weighted graphs D Distances affinities A for i=1:n for j=1:n D(i,j) = x i - x j 2 end end for i=1:n for j=i+1:n A(i,j) = exp(-1/(2*σ^2)* x i - x j 2 ); A(j,i) = A(i,j); end 9 end Kristen Grauman

Scale parameter σ affects affinity Distance matrix D= Affinity matrix with increasing σ: 10 Kristen Grauman

Visualizing a shuffled affinity matrix If we permute the order of the vertices as they are referred to in the affinity matrix, we see different patterns: 11 Kristen Grauman

Putting these two aspects together Points x 1 x 10 Data points σ=.1 σ=.2 σ=1 Points x 31 x 40 Affinity matrices AA ii, jj = exp{ 1 2σσ 2 xx ii xx 2 12 jj } Kristen Grauman

Goal: Segmentation by Graph Cuts w A B C Break graph into segments Delete links that cross between segments Easiest to break links that have low similarity similar pixels should be in the same segments dissimilar pixels should be in different segments 13 Slide credit: Kristen Grauman

Cuts in a graph: Min cut A B Link Cut set of links whose removal makes a graph disconnected cost of a cut: cut( A, B) = Weakness of Min cut w p, q p A, q B Find minimum cut gives you a segmentation fast algorithms exist 14 Source: Steve Seitz

Cuts in a graph: Normalized cut A B Fix bias of Min Cut by normalizing for size of segments: cut( A, B) assoc( A, V ) + cut( A, B) assoc( B, V ) assoc(a,v) = sum of weights of all edges that touch A Ncut value is small when we get two clusters with many edges with high weights, and few edges of low weight between them. Approximate solution: generalized eigenvalue problem. J. Shi and J. Malik, Normalized Cuts and Image Segmentation, CVPR, 1997 15 Steve Seitz

Example results: segments from Ncuts Slide credit: Kristen Grauman 16

Normalized cuts: pros and cons Pros: Generic framework, flexible to choice of function that computes weights ( affinities ) between nodes Does not require model of the data distribution Cons: Time complexity can be high Dense, highly connected graphs many affinity computations Solving eigenvalue problem Preference for balanced partitions 17 Kristen Grauman

Now: Fitting Want to associate a model with multiple observed features [Fig from Marszalek & Schmid, 2007] For example, the model could be a line, a circle, or an arbitrary shape. 18 Adapted from Kristen Grauman

Fitting: Main idea Choose a parametric model that best represent a set of features Membership criterion is not local Can t tell whether a point belongs to a given model just by looking at that point Three main questions: What model represents this set of features best? Which of several model instances gets which feature? How many model instances are there? Computational complexity is important It is infeasible to examine every possible set of parameters and every possible combination of features 19 Slide credit: L. Lazebnik

Example: Line fitting Why fit lines? Many objects characterized by presence of straight lines Wait, why aren t we done just by running edge detection? 20 Kristen Grauman

Difficulty of line fitting Extra edge points (clutter), multiple models: which points go with which line, if any? Only some parts of each line detected, and some parts are missing: how to find a line that bridges missing evidence? Noise in measured edge points, orientations: how to detect true underlying parameters? 21 Kristen Grauman

Voting It s not feasible to check all combinations of features by fitting a model to each possible subset. Voting is a general technique where we let each feature vote for all models that are compatible with it. Cycle through features, cast votes for model parameters. Look for model parameters that receive a lot of votes. Noise & clutter features will cast votes too, but typically their votes should be inconsistent with the majority of good features. 22 Kristen Grauman

Fitting lines: Hough transform Given points that belong to a line, what is the line? How many lines are there? Which points belong to which lines? Hough Transform is a voting technique that can be used to answer all of these questions. Main idea: 1. Record vote for each possible line on which each edge point lies. 2. Look for lines that get many votes. 23 Kristen Grauman

Finding lines in an image: Hough space y b Equation of a line? y = mx + b b 0 image space x m 0 m Hough (parameter) space Connection between image (x,y) and Hough (m,b) spaces A line in the image corresponds to a point in Hough space To go from image space to Hough space: given a set of points (x,y), find all (m,b) such that y = mx + b 24 Slide credit: Steve Seitz

Finding lines in an image: Hough space y b y 0 x 0 image space x m Hough (parameter) space Connection between image (x,y) and Hough (m,b) spaces A line in the image corresponds to a point in Hough space To go from image space to Hough space: given a set of points (x,y), find all (m,b) such that y = mx + b What does a point (x 0, y 0 ) in the image space map to? Answer: the solutions of b = -x 0 m + y 0 this is a line in Hough space 25 Slide credit: Steve Seitz

Finding lines in an image: Hough space y y 0 (x 0, y 0 ) (x 1, y 1 ) b b = x 1 m + y 1 x 0 image space x m Hough (parameter) space What are the line parameters for the line that contains both (x 0, y 0 ) and (x 1, y 1 )? It is the intersection of the lines b = x 0 m + y 0 and b = x 1 m + y 1 Slide credit: Kristen Grauman 26

Finding lines in an image: Hough algorithm y b image space x m Hough (parameter) space How can we use this to find the most likely parameters (m,b) for the most prominent line in the image space? Let each edge point in image space vote for a set of possible parameters in Hough space Accumulate votes in discrete set of bins; parameters with the most votes indicate line in image space. Slide credit: Kristen Grauman 27

Polar representation for lines Issues with usual (m,b) parameter space: can take on infinite values, undefined for vertical lines. d d : perpendicular distance from line to origin θ : angle the perpendicular makes with the x-axis x cosθ + y sinθ = d Point in image space sinusoid segment in Hough space 28 Adapted from Kristen Grauman

Hough line demo http://www.dis.uniroma1.it/~iocchi/slides/icra2001/jav a/hough.html Slide credit: Kristen Grauman 29

Hough transform algorithm Using the polar parameterization: x cosθ + y sinθ = d H: accumulator array (votes) Basic Hough transform algorithm 1. Initialize H[d, θ]=0 2. for each edge point I[x,y] in the image for θ = [θ min H[d, θ] += 1 to θ max ] // some quantization d = x cosθ + y sinθ 3. Find the value(s) of (d, θ) where H[d, θ] is maximum 4. The detected line in the image is given by d = x cosθ + y sinθ d θ Time complexity (in terms of number of votes per pt)? 30 Source: Steve Seitz

Derek Hoiem 1. Image Canny

Derek Hoiem 2. Canny Hough votes

3. Hough votes Edges Find peaks Derek Hoiem

Hough transform example Derek Hoiem http://ostatic.com/files/images/ss_hough.jpg

Original image Canny edges Vote space and top peaks Showing longest segments found 35 Kristen Grauman

Impact of noise on Hough y d x Image space edge coordinates θ Votes What difficulty does this present for an implementation?

Impact of noise on Hough Image space edge coordinates Votes Here, everything appears to be noise, or random edge points, but we still see peaks in the vote space. 37 Slide credit: Kristen Grauman

Extensions Recall: when we detect an edge point, we also know its gradient direction Extension 1: Use the image gradient 1. same 2. for each edge point I[x,y] in the image θ = gradient at (x,y) 3. same 4. same d = x cosθ + y sinθ H[d, θ] += 1 (Reduces degrees of freedom) Extension 2 give more votes for stronger edges Extension 3 Slide credit: Kristen Grauman change the sampling of (d, θ) to give more/less resolution 38

Extensions Extension 1: Use the image gradient 1. same 2. for each edge point I[x,y] in the image compute unique (d, θ) based on image gradient at (x,y) H[d, θ] += 1 3. same 4. same (Reduces degrees of freedom) Extension 2 give more votes for stronger edges (use magnitude of gradient) Extension 3 change the sampling of (d, θ) to give more/less resolution Extension 4 The same procedure can be used with circles, squares, or any other shape 39 Source: Steve Seitz

Hough transform for circles Circle: center (a,b) and radius r ) ( 2 2 2 ( xi a + yi b = r ) Equation of circle? For a fixed radius r b Equation of set of circles that all pass through a point? Image space Hough space a Adapted by Devi Parikh from: Kristen Grauman 40

Hough transform for circles Circle: center (a,b) and radius r For a fixed radius r ) ( 2 2 2 ( xi a + yi b = r ) Intersection: most votes for center occur here. Image space Hough space 41 Kristen Grauman

Hough transform for circles Circle: center (a,b) and radius r For an unknown radius r ) ( 2 2 2 ( xi a + yi b = r ) r? Image space a Hough space b 42 Kristen Grauman

Hough transform for circles Circle: center (a,b) and radius r For an unknown radius r ) ( 2 2 2 ( xi a + yi b = r ) r b Image space a Hough space 43 Kristen Grauman

Hough transform for circles Circle: center (a,b) and radius r ) ( 2 2 2 ( xi a + yi b = r For an unknown radius r, known gradient direction ) x θ Image space Hough space 44 Kristen Grauman

Hough transform for circles For every edge pixel (x,y) : For each possible radius value r: For each possible gradient direction θ: // or use estimated gradient at (x,y) a = x r cos(θ) // column b = y + r sin(θ) // row H[a,b,r] += 1 end end Time complexity per edgel? Check out online demo : http://www.markschulze.net/java/hough/ 45 Kristen Grauman

Example: detecting circles with Hough Original Edges Votes: Penny Note: a different Hough transform (with separate accumulators) was used for each circle radius (quarters vs. penny). Slide credit: Kristen Grauman 46

Example: detecting circles with Hough Combined Original detections Edges Votes: Quarter Slide credit: Kristen Grauman 47 Coin finding sample images from: Vivek Kwatra

Example: iris detection Gradient+threshold Hough space (fixed radius) Max detections Hemerson Pistori and Eduardo Rocha Costa http://rsbweb.nih.gov/ij/plugins/hough-circles.html 48 Kristen Grauman

Example: iris detection An Iris Detection Method Using the Hough Transform and Its Evaluation for Facial and Eye Movement, by Hideki Kashima, Hitoshi Hongo, Kunihito 49 Kato, Kazuhiko Yamamoto, ACCV 2002. Kristen Grauman

Voting: practical tips Minimize irrelevant tokens first Choose a good grid / discretization Too fine? Too coarse Vote for neighbors, also (smoothing in accumulator array) Use direction of edge to reduce parameters by 1 50 Kristen Grauman

Pros Hough transform: pros and cons All points are processed independently, so can cope with occlusion, gaps Some robustness to noise: noise points unlikely to contribute consistently to any single bin Can detect multiple instances of a model in a single pass Cons Complexity of search time increases exponentially with the number of model parameters Non-target shapes can produce spurious peaks in parameter space Quantization: can be tricky to pick a good grid size 51 Kristen Grauman

Generalized Hough Transform What if we want to detect arbitrary shapes? Intuition: Displacement vectors x x x Ref. point Model image Novel image x Vote space x Now suppose those colors encode gradient directions 52 Kristen Grauman

Generalized Hough Transform Define a model shape by its boundary points and a reference point. Offline procedure: p 1 θ x a θ p 2 At each boundary point, compute displacement vector: r = a p i. Model shape θ θ Store these vectors in a table indexed by gradient orientation θ. [Dana H. Ballard, Generalizing the Hough Transform to Detect Arbitrary Shapes, 1980] 53 Kristen Grauman

Generalized Hough Transform Detection procedure: For each edge point: Use its gradient orientation θ to index into stored table Use retrieved r vectors to vote for reference point θ θ xx x xx p 1 θ θ Novel image θ θ θ 54 Assuming translation is the only transformation here, i.e., orientation and scale are fixed. Kristen Grauman

Generalized Hough for object detection Instead of indexing displacements by gradient orientation, index by matched local patterns. training image visual codeword with displacement vectors B. Leibe, A. Leonardis, and B. Schiele, Combined Object Categorization and Segmentation with an Implicit Shape Model, ECCV Workshop on Statistical Learning in Computer Vision 2004 55 Source: L. Lazebnik

Generalized Hough for object detection Instead of indexing displacements by gradient orientation, index by visual codeword test image B. Leibe, A. Leonardis, and B. Schiele, Combined Object Categorization and Segmentation with an Implicit Shape Model, ECCV Workshop on Statistical Learning in Computer Vision 2004 56 Source: L. Lazebnik

Summary Grouping/segmentation useful to make a compact representation and merge similar features associate features based on defined similarity measure and clustering objective Fitting problems require finding any supporting evidence for a model, even within clutter and missing features. associate features with an explicit model Voting approaches, such as the Hough transform, make it possible to find likely model parameters without searching all combinations of features. Hough transform approach for lines, circles,, arbitrary shapes defined by a set of boundary points, recognition from patches. 57 Kristen Grauman

Questions? See you Tuesday! 58