histograms in matlab
play

Histograms in Matlab a = A(:); % reshapes matrix A into vector, - PDF document

9/22/2009 Histograms in Matlab a = A(:); % reshapes matrix A into vector, columns first Fitting: H = hist(A(:), 10); Voting and the Hough Transform g g % takes a histogram from the As values, into % t k hi t f th A l i t


  1. 9/22/2009 Histograms in Matlab • a = A(:); % reshapes matrix A into vector, columns first Fitting: • H = hist(A(:), 10); Voting and the Hough Transform g g % takes a histogram from the A’s values, into % t k hi t f th A’ l i t 10 uniformly sized bins Tuesday, Sept 22 • H = histc(A(:), [1:N]); Kristen Grauman % counts values within the bins having UT-Austin specified edges Review: graph-based clustering Last time: segmentation • Segmentation to find object boundaries or mid- • Assuming we use a fully connected graph, what is the level regions, tokens. time complexity of computing the affinities for a graph cuts-based segmentation? • Bottom-up segmentation via clustering – General choices -- features, affinity functions, and • Example affinity measure: clustering algorithms • Grouping also useful for quantization, can create new feature summaries – Texton histograms for texture within local region X (i) is position of node i • Example clustering methods F (i) is a feature vector for node i based on color, texture, etc. – K-means This affinity measure limits connections to spatially close pixels. – Graph cuts, normalized cuts – Tradeoffs Fitting Now: Fitting • Choose a parametric model to represent a • Want to associate a model with observed features 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: ee a quest o s • 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 [Fig from Marszalek & Schmid, 2007] and every possible combination of features For example, the model could be a line, a circle, or an arbitrary shape. Source: L. Lazebnik 1

  2. 9/22/2009 Example: Line fitting Difficulty of line fitting • Why fit lines? • Extra edge points (clutter), Many objects characterized by presence of straight lines 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 • Wait, why aren’t we done just by running edge detection? parameters? Fitting lines Fitting lines • Given points that belong to a line, what • Given points that belong to a line, what is the line? is the line? • How many lines are there? • Which points belong to which lines? Assuming all the points that belong to a line are known, can solve for line parameters that yield minimal error. Forsyth & Ponce 15.2.1 Fitting lines Voting • It’s not feasible to check all combinations of features by • Given points that belong to a line, what fitting a model to each possible subset. is the line? • How many lines are there? • Voting is a general technique where we let the features • Which points belong to which lines? vote for all models that are compatible with it. – Cycle through features cast votes for model parameters Cycle through features, cast votes for model parameters. • Hough Transform is a voting • Hough Transform is a voting technique that can be used to answer – Look for model parameters that receive a lot of votes. all of these questions. • Noise & clutter features will cast votes too, but typically Main idea: their votes should be inconsistent with the majority of “good” features. 1. Record vote for each possible line on which each edge point lies. • Ok if some features not observed, as model can span 2. Look for lines that get many votes . multiple fragments. 2

  3. 9/22/2009 Finding lines in an image: Hough space Finding lines in an image: Hough space y b y b y 0 b 0 m 0 x 0 x m x m image space Hough (parameter) space image space Hough (parameter) space Connection between image (x,y) and Hough (m,b) spaces Connection between image (x,y) and Hough (m,b) spaces • A line in the image corresponds to a point in Hough space • A line in the image corresponds to a point in Hough space • To go from image space to 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 – 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 Slide credit: Steve Seitz Slide credit: Steve Seitz Finding lines in an image: Hough space Finding lines in an image: Hough algorithm y b y b ( x 1 , y 1 ) y 0 ( x 0 , y 0 ) b = – x 1 m + y 1 x 0 x m x m image space Hough (parameter) space image space Hough (parameter) space How can we use this to find the most likely parameters What are the line parameters for the line that contains both (m,b) for the most prominent line in the image space? (x 0 , y 0 ) and (x 1 , y 1 )? • Let each edge point in image space vote for a set of • It is the intersection of the lines b = –x 0 m + y 0 and b = –x 1 m + y 1 possible parameters in Hough space • Accumulate votes in discrete set of bins; parameters with the most votes indicate line in image space. Polar representation for lines Hough transform algorithm Using the polar parameterization: Issues with usual ( m,b ) parameter space: can take on H: accumulator array (votes) θ − θ = cos sin x y d infinite values, undefined for vertical lines. d Basic Hough transform algorithm x [0,0] θ d : perpendicular distance 1. Initialize H[d, θ ]=0 from line to origin 2. for each edge point I[x,y] in the image θ for θ = 0 to 180 // some quantization d : angle the perpendicular θ y = θ − θ cos sin makes with the x-axis d x y H[d, θ ] += 1 3. Find the value(s) of (d, θ ) where H[d, θ ] is maximum θ − θ = cos sin x y d = cos θ − sin θ 4. The detected line in the image is given by d x y Hough line demo Point in image space � sinusoid segment in Hough space Time complexity (in terms of number of votes per pt)? Source: Steve Seitz 3

  4. 9/22/2009 Example: Hough transform for straight lines Example: Hough transform for straight lines Circle : Square : d y θ x Image space Votes edge coordinates Bright value = high vote count Black = no votes Example: Hough transform for straight lines Impact of noise on Hough d y x θ Image space Votes edge coordinates Showing longest segments found What difficulty does this present for an implementation? 4

  5. 9/22/2009 Extensions Impact of noise on Hough Extension 1: Use the image gradient 1. same 2. for each edge point I[x,y] in the image θ = gradient at (x,y) = θ − θ cos sin d x y H[d, θ ] += 1 3. same 4. same (Reduces degrees of freedom) Extension 2 • give more votes for stronger edges Image space Votes Extension 3 edge coordinates change the sampling of (d, θ ) to give more/less resolution • Extension 4 Here, everything appears to be “noise”, or random • The same procedure can be used with circles, squares, or any edge points, but we still see peaks in the vote space. other shape Extensions Hough transform for circles Extension 1: Use the image gradient • Circle: center (a,b) and radius r 1. same − 2 + − 2 = 2 2. for each edge point I[x,y] in the image ( ) ( ) x a y b r compute unique (d, θ ) based on image gradient at (x,y) i i H[d, θ ] += 1 • For a fixed radius r, unknown gradient direction 3. same 4. same b b (Reduces degrees of freedom) (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 a other shape… Image space Hough space Source: Steve Seitz Hough transform for circles Hough transform for circles • Circle: center (a,b) and radius r • Circle: center (a,b) and radius r − 2 + − 2 = 2 − 2 + − 2 = 2 ( ) ( ) ( ) ( ) x a y b r x a y b r i i i i • For a fixed radius r, unknown gradient direction • For an unknown radius r, unknown gradient direction r Intersection : most votes for center b occur here. a Image space Hough space Hough space Image space 5

Recommend


More recommend