Lecture: RANSAC and feature detectors 08-Oct-2019 Juan Carlos - - PowerPoint PPT Presentation

lecture ransac and feature detectors
SMART_READER_LITE
LIVE PREVIEW

Lecture: RANSAC and feature detectors 08-Oct-2019 Juan Carlos - - PowerPoint PPT Presentation

Features and Fitting Lecture: RANSAC and feature detectors 08-Oct-2019 Juan Carlos Niebles and Ranjay Krishna Stanford Vision and Learning Lab 1 St Stanfor ord University CS 131 Roadmap Features and Fitting Pixels Segments Images


slide-1
SLIDE 1

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 1

Lecture: RANSAC and feature detectors

Juan Carlos Niebles and Ranjay Krishna Stanford Vision and Learning Lab

slide-2
SLIDE 2

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 2

CS 131 Roadmap

Pixels Images

Convolutions Edges Features

Segments

Resizing Segmentation Clustering Recognition Detection Machine learning

Videos

Motion Tracking

Web

Neural networks Convolutional neural networks

slide-3
SLIDE 3

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 3

What we will learn today?

  • A model fitting method for line detection

– RANSAC

  • Local invariant features

– Motivation – Requirements, invariances

  • Keypoint localization

– Harris corner detector

slide-4
SLIDE 4

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 4

What we will learn today

  • A model fitting method for line detection

– RANSAC

  • Local invariant features

– Motivation – Requirements, invariances

  • Keypoint localization

– Harris corner detector

slide-5
SLIDE 5

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 5

Fitting as Search in Parametric Space

  • Choose a parametric model to 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

  • f features

Source: L. Lazebnik

slide-6
SLIDE 6

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 6

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?

Slide credit: Kristen Grauman

slide-7
SLIDE 7

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 7

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,
  • rientations:

– How to detect true underlying parameters?

Slide credit: Kristen Grauman

slide-8
SLIDE 8

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 8

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 the features 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.

  • Ok if some features not observed, as model can span multiple fragments.

Slide credit: Kristen Grauman

slide-9
SLIDE 9

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 9

RANSAC [Fischler & Bolles 1981]

  • RANdom SAmple Consensus
  • Approach: we want to avoid the impact of outliers, so let’s look for “inliers”, and

use only those.

  • Intuition: if an outlier is chosen to compute the current fit, then the resulting line

won’t have much support from rest of the points.

Slide credit: Kristen Grauman

slide-10
SLIDE 10

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 10

RANSAC [Fischler & Bolles 1981]

RANSAC loop: 1. Randomly select a seed group of points on which to base transformation estimate (e.g., a group of matches) 2. Compute transformation from seed group 3. Find inliers to this transformation 4. If the number of inliers is sufficiently large, re-compute least-squares estimate

  • f transformation on all of the inliers
  • Keep the transformation with the largest number of inliers

Slide credit: Kristen Grauman

slide-11
SLIDE 11

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 11

RANSAC Line Fitting Example

  • Task: Estimate the best line

– How many points do we need to estimate the line?

Slide credit: Kristen Grauman

slide-12
SLIDE 12

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 12

RANSAC Line Fitting Example

  • Task: Estimate the best line

Sample two points

Slide credit: Kristen Grauman

slide-13
SLIDE 13

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 13

RANSAC Line Fitting Example

  • Task: Estimate the best line

Fit a line to them

Slide credit: Kristen Grauman

slide-14
SLIDE 14

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 14

RANSAC Line Fitting Example

  • Task: Estimate the best line

Total number of points within a threshold of line.

Slide credit: Kristen Grauman

slide-15
SLIDE 15

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 15

RANSAC Line Fitting Example

  • Task: Estimate the best line

Total number of points within a threshold of line.

“7 inlier points”

Slide credit: Kristen Grauman

slide-16
SLIDE 16

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 16

RANSAC Line Fitting Example

  • Task: Estimate the best line

Repeat, until we get a good result.

Slide credit: Kristen Grauman

slide-17
SLIDE 17

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 17

RANSAC Line Fitting Example

  • Task: Estimate the best line

Repeat, until we get a good result.

“11 inlier points”

Slide credit: Kristen Grauman

slide-18
SLIDE 18

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 18

slide-19
SLIDE 19

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 19

RANSAC: How many samples?

  • How many samples are needed?

–Suppose w is fraction of inliers (points from line).

– n points needed to define hypothesis (2 for lines) – k samples chosen.

  • Prob. that a single sample of n points is correct:
  • Prob. that all k samples fail is:

Þ Choose k high enough to keep this below desired failure rate.

n

w

k n

w ) 1 ( -

Slide credit: David Lowe

slide-20
SLIDE 20

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 20

RANSAC: Computed k (p=0.99)

Sample size

n Proportion of outliers 5% 10% 20% 25% 30% 40% 50%

2 2 3 5 6 7 11 17 3 3 4 7 9 11 19 35 4 3 5 9 13 17 34 72 5 4 6 12 17 26 57 146 6 4 7 16 24 37 97 293 7 4 8 20 33 54 163 588 8 5 9 26 44 78 272 1177

Slide credit: David Lowe

slide-21
SLIDE 21

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 21

After RANSAC

  • RANSAC divides data into inliers and outliers and

yields estimate computed from minimal set of inliers.

  • Improve this initial estimate with estimation over all

inliers (e.g. with standard least-squares minimization).

  • But this may change inliers, so alternate fitting with

re-classification as inlier/outlier.

Slide credit: David Lowe

slide-22
SLIDE 22

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 22

RANSAC: Pros and Cons

  • Pros:

– General method suited for a wide range of model fitting problems – Easy to implement and easy to calculate its failure rate

  • Cons:

– Only handles a moderate percentage of outliers without cost blowing up – Many real problems have high rate of outliers (but sometimes selective choice of random subsets can help)

  • A voting strategy, The Hough transform, can handle high

percentage of outliers

slide-23
SLIDE 23

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 23

What we will learn today?

  • A model fitting method for edge detection

– RANSAC

  • Local invariant features

– Motivation – Requirements, invariances

  • Keypoint localization

– Harris corner detector

Some background reading: Rick Szeliski, Chapter 4.1.1; David Lowe, IJCV 2004

slide-24
SLIDE 24

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 24

Image matching: a challenging problem

slide-25
SLIDE 25

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 25

by Diva Sian by swashford

Slide credit: Steve Seitz

Image matching: a challenging problem

slide-26
SLIDE 26

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 26

Harder Case

by Diva Sian by scgbt

Slide credit: Steve Seitz

slide-27
SLIDE 27

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 27

Harder Still?

NASA Mars Rover images

Slide credit: Steve Seitz

slide-28
SLIDE 28

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 28

Answer Below (Look for tiny colored squares)

NASA Mars Rover images with SIFT feature matches (Figure by Noah Snavely)

Slide credit: Steve Seitz

slide-29
SLIDE 29

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 29

Motivation for using local features

  • Global representations have major limitations
  • Instead, describe and match only local regions
  • Increased robustness to

– Occlusions – Articulation – Intra-category variations

θq

φ

dq

φ θ

d

slide-30
SLIDE 30

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 30

General Approach

N pixels N pixels

Similarity measure A

f

e.g. color

B

f

e.g. color

  • 1. Find a set of

distinctive key- points

  • 3. Extract and

normalize the region content

  • 2. Define a region

around each keypoint

  • 4. Compute a local

descriptor from the normalized region

  • 5. Match local

descriptors

Slide credit: Bastian Leibe

A1 A2 A3 B1 B2 B3

T f f d

B A

< ) , (

slide-31
SLIDE 31

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 31

Common Requirements

  • Problem 1:

–Detect the same point independently in both images

No chance to match!

We need a repeatable detector!

Slide credit: Darya Frolova, Denis Simakov

slide-32
SLIDE 32

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 32

Common Requirements

  • Problem 1:

–Detect the same point independently in both images

  • Problem 2:

–For each point correctly recognize the corresponding one We need a reliable and distinctive descriptor!

?

Slide credit: Darya Frolova, Denis Simakov

slide-33
SLIDE 33

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 33

Invariance: Geometric Transformations

Slide credit: Steve Seitz

slide-34
SLIDE 34

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 34

Levels of Geometric Invariance

Slide credit: Bastian Leibe

CS131 CS231a

slide-35
SLIDE 35

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 35

Invariance: Photometric Transformations

  • Often modeled as a linear

transformation:

– Scaling + Offset

Slide credit: Tinne Tuytelaars

slide-36
SLIDE 36

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 36

Requirements

  • Region extraction needs to be repeatable and accurate

– Invariant to translation, rotation, scale changes – Robust or covariant to out-of-plane (»affine) transformations – Robust to lighting variations, noise, blur, quantization

  • Locality: Features are local, therefore robust to occlusion and clutter.
  • Quantity: We need a sufficient number of regions to cover the
  • bject.
  • Distinctiveness: The regions should contain “interesting” structure.
  • Efficiency: Close to real-time performance.

Slide credit: Bastian Leibe

slide-37
SLIDE 37

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 37

Many Existing Detectors Available

  • Hessian & Harris

[Beaudet ‘78], [Harris ‘88]

  • Laplacian, DoG

[Lindeberg ‘98], [Lowe ‘99]

  • Harris-/Hessian-Laplace [Mikolajczyk & Schmid ‘01]
  • Harris-/Hessian-Affine

[Mikolajczyk & Schmid ‘04]

  • EBR and IBR

[Tuytelaars & Van Gool ‘04]

  • MSER

[Matas ‘02]

  • Salient Regions

[Kadir & Brady ‘01]

  • Others…
  • Those detectors have become a basic building block for many applications in

Computer Vision.

Slide credit: Bastian Leibe

slide-38
SLIDE 38

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 38

What we will learn today?

  • A model fitting method for edge detection

– RANSAC

  • Local invariant features

– Motivation – Requirements, invariances

  • Keypoint localization

– Harris corner detector

Some background reading: Rick Szeliski, Chapter 4.1.1; David Lowe, IJCV 2004

slide-39
SLIDE 39

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 39

Keypoint Localization

  • Goals:

– Repeatable detection – Precise localization – Interesting content

Þ Look for two-dimensional signal changes

Slide credit: Bastian Leibe

slide-40
SLIDE 40

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 40

Finding Corners

  • Key property:

– In the region around a corner, image gradient has two or more dominant directions

  • Corners are repeatable and distinctive

C.Harris and M.Stephens. "A Combined Corner and Edge Detector.“ Proceedings of the 4th Alvey Vision Conference, 1988.

Slide credit: Svetlana Lazebnik

slide-41
SLIDE 41

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 41

Corners as Distinctive Interest Points

  • Design criteria

–We should easily recognize the point by looking through a small window (locality) –Shifting the window in any direction should give a large change in intensity (good localization)

“edge”: no change along the edge direction “corner”: significant change in all directions “flat” region: no change in all directions

Slide credit: Alyosha Efros

slide-42
SLIDE 42

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 42

Corners versus edges

Large Large

Corner

Small Large

Edge

Small Small

Nothing

slide-43
SLIDE 43

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 43

Corners versus edges

?? ??

Corner

slide-44
SLIDE 44

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 44

Measure change in all directions [u, v]

“corner”: significant change in all directions

𝐽 𝑦, 𝑧

𝐽 𝑦 + 𝑣, 𝑧 + 𝑤

𝐽 𝑦 + 𝑣, 𝑧 + 𝑤 − 𝐽 𝑦, 𝑧

Measure change as intensity difference:

𝑣, 𝑤 That’s for a single point, but we have to accumulate over a ”small window” around that point…

slide-45
SLIDE 45

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 45

Harris Detector Formulation

  • Change of intensity for the shift [u,v]:

E(u,v) = w(x, y) I(x +u, y + v)− I(x, y) " # $ %

2 x,y

Intensity Shifted intensity Window function

  • r

Window function w(x,y) = Gaussian 1 in window, 0 outside

Slide credit: Rick Szeliski

slide-46
SLIDE 46

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 46

Harris Detector Formulation

  • This measure of change can be approximated by (Taylor expansion):

where M is a 2´2 matrix computed from image derivatives:

ú û ù ê ë é » v u M v u v u E ] [ ) , (

M

Sum over image region – the area we are checking for corner

Gradient with respect to x, times gradient with respect to y

2 2 ,

( , )

x x y x y x y y

I I I M w x y I I I é ù = ê ú ê ú ë û

å

Slide credit: Rick Szeliski

slide-47
SLIDE 47

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 47

Harris Detector Formulation

where M is a 2´2 matrix computed from image derivatives:

Ix

Image I

IxIy Iy

M

Sum over image region – the area we are checking for corner

Gradient with respect to x, times gradient with respect to y

2 2 ,

( , )

x x y x y x y y

I I I M w x y I I I é ù = ê ú ê ú ë û

å

Slide credit: Rick Szeliski

slide-48
SLIDE 48

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 48

What Does This Matrix Reveal?

  • First, let’s consider an axis-aligned corner:
  • This means:

– Dominant gradient directions align with x or y axis – If either λ is close to 0, then this is not a corner, so look for locations where both are large.

  • What if we have a corner that is not aligned with the image

axes?

ú û ù ê ë é = ú ú û ù ê ê ë é =

å å å å

2 1 2 2

l l

y y x y x x

I I I I I I M

Slide credit: David Jacobs

slide-49
SLIDE 49

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 49

What Does This Matrix Reveal?

  • First, let’s consider an axis-aligned corner:
  • This means:

– Dominant gradient directions align with x or y axis – If either λ is close to 0, then this is not a corner, so look for locations where both are large.

  • What if we have a corner that is not aligned with the image

axes?

ú û ù ê ë é = ú ú û ù ê ê ë é =

å å å å

2 1 2 2

l l

y y x y x x

I I I I I I M

Slide credit: David Jacobs

slide-50
SLIDE 50

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 50

General Case

  • Since M is symmetric, we have
  • We can think of M as an ellipse with axis lengths determined

by the eigenvalues and orientation determined by R

R R M ú û ù ê ë é =

  • 2

1 1

l l

Direction of the slowest change Direction of the fastest change

(lmax)-1/2 (lmin)-1/2

adapted from Darya Frolova, Denis Simakov

(Eigenvalue decomposition)

slide-51
SLIDE 51

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 51

Interpreting the Eigenvalues

  • Classification of image points using eigenvalues of M:

l1

“Corner” l1 and l2 are large, l1 ~ l2; E increases in all directions l1 and l2 are small; E is almost constant in all directions “Edge” l1 >> l2 “Edge” l2 >> l1 “Flat” region

Slide credit: Kristen Grauman

l2

slide-52
SLIDE 52

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 52

Corner Response Function

  • Fast approximation

– Avoid computing the eigenvalues – α: constant (0.04 to 0.06)

l2

“Corner” θ > 0 “Edge” θ < 0 “Edge” θ < 0 “Flat” region

θ = det(M)−α trace(M)2 = λ1λ2 −α(λ1 + λ2)2

l1

Slide credit: Kristen Grauman

slide-53
SLIDE 53

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 53

Window Function w(x,y)

  • Option 1: uniform window

– Sum over square window – Problem: not rotation invariant

  • Option 2: Smooth with Gaussian

– Gaussian already performs weighted sum – Result is rotation invariant 1 in window, 0 outside

2 2 ,

( , )

x x y x y x y y

I I I M w x y I I I é ù = ê ú ê ú ë û

å

Gaussian

2 2 , x x y x y x y y

I I I M I I I é ù = ê ú ê ú ë û

å

2 2

( )

x x y x y y

I I I M g I I I s é ù = *ê ú ê ú ë û

Slide credit: Bastian Leibe

slide-54
SLIDE 54

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 54

Summary: Harris Detector [Harris88]

  • Compute second moment matrix

(autocorrelation matrix)

  • 1. Image

derivatives

Ix Iy

  • 2. Square of

derivatives

Ix2 Iy2 IxIy

  • 3. Gaussian

filter g(sI)

g(Ix2) g(Iy2) g(IxIy) R

2 2

( ) ( ) ( , ) ( ) ( ) ( )

x D x y D I D I x y D y D

I I I M g I I I s s s s s s s é ù = *ê ú ê ú ë û

2 2 2 2 2 2

( ) ( ) [ ( )] [ ( ) ( )]

x y x y x y

g I g I g I I g I g I a =

  • +

θ = det[M (σ I,σ D)]−α[trace(M (σ I,σ D))]2

  • 4. Cornerness function – two strong eigenvalues
  • 5. Perform non-maximum suppression

Slide credit: Krystian Mikolajczyk

𝜏*: for Gaussian in the derivative calculation 𝜏+: for Gaussian in the windowing function

slide-55
SLIDE 55

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 55

Harris Detector: Workflow

Slide adapted from Darya Frolova, Denis Simakov

slide-56
SLIDE 56

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 56

Harris Detector: Workflow

  • computer corner responses θ

Slide adapted from Darya Frolova, Denis Simakov

slide-57
SLIDE 57

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 57

Harris Detector: Workflow

  • Take only the local maxima of θ, where θ>threshold

Slide adapted from Darya Frolova, Denis Simakov

slide-58
SLIDE 58

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 58

Harris Detector: Workflow

  • Resulting Harris points

Slide adapted from Darya Frolova, Denis Simakov

slide-59
SLIDE 59

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 59

Harris Detector – Responses [Harris88]

Effect: A very precise corner detector.

Slide credit: Krystian Mikolajczyk

slide-60
SLIDE 60

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 60

Harris Detector – Responses [Harris88]

Slide credit: Krystian Mikolajczyk

slide-61
SLIDE 61

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 61

Harris Detector – Responses [Harris88]

  • Results are well suited for finding stereo correspondences

Slide credit: Kristen Grauman

slide-62
SLIDE 62

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 62

  • Translation invariance?

Slide credit: Kristen Grauman

Harris Detector: Properties

slide-63
SLIDE 63

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 63

  • Translation invariance
  • Rotation invariance?

Ellipse rotates but its shape (i.e. eigenvalues) remains the same

Corner response θ is invariant to image rotation

Slide credit: Kristen Grauman

Harris Detector: Properties

slide-64
SLIDE 64

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 64

Harris Detector: Properties

  • Translation invariance
  • Rotation invariance
  • Scale invariance?

Not invariant to image scale!

All points will be classified as edges! Corner

Slide credit: Kristen Grauman

slide-65
SLIDE 65

Features and Fitting

St Stanfor

  • rd University

08-Oct-2019 65

What we are learned today?

  • A model fitting method for edge detection

– RANSAC

  • Local invariant features

– Motivation – Requirements, invariances

  • Keypoint localization

– Harris corner detector