4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

62
4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238

Transcript of 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Page 1: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

4.1 Feature: Point and Patches

Xuejin ChenReading: Szeliski Chap. 4 222~238

Page 2: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

4.1.2 Feature Descriptor

Page 3: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature DescriptorsWe know how to detect good pointsNext question: How to match them?

?

Page 4: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature Descriptors

Lots of possibilities (this is a popular research area)– Simple option: match square windows around the

point – State of the art approach: SIFT

• David Lowe, UBC http://www.cs.ubc.ca/~lowe/keypoints/

?

Page 5: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature Descriptors

• Sum of Squared Difference (SSD)

• Normalized Cross-Correlation (NCC)

• For small motion: video stereo, tracking…• Time consuming and sensitive to noise, transforms..

21 0( ( ) ( ))i i

i

I I x x

( ( ) )( ( ) )1

1i i

i f g

f x f g x g

n

Page 6: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

InvarianceSuppose we are comparing two images I1 and I2

– I2 may be a transformed version of I1

– What kinds of transformations are we likely to encounter in practice?

We’d like to find the same features regardless of the transformation

– This is called transformational invariance– Most feature methods are designed to be invariant to

• Translation, 2D rotation, scale– They can usually also handle

• Limited 3D rotations (SIFT works up to about 60 degrees)• Limited affine transformations (some are fully affine invariant)• Limited illumination/contrast changes

Page 7: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

How to Achieve InvarianceNeed both of the following:1. Make sure your detector is invariant

– Harris is invariant to translation and rotation– Scale is trickier

• common approach is to detect features at many scales using a Gaussian pyramid (e.g., MOPS)

• More sophisticated methods find “the best scale” to represent each feature (e.g., SIFT)

2. Design an invariant feature descriptor– A descriptor captures the information in a region around

the detected feature point– The simplest descriptor: a square window of pixels

• What’s this invariant to?

– Let’s look at some better approaches…

Page 8: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Find dominant orientation of the image patch– This is given by x+, the eigenvector of H corresponding to +

• + is the larger eigenvalue

– Rotate the patch according to this angle

Rotation Invariance for Feature Descriptors

Figure by Matthew Brown

Page 9: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Take 40x40 square window around detected feature– Scale to 1/5 size (using prefiltering) – Rotate to horizontal– Sample 8x8 square window centered at feature– Intensity normalize the window by subtracting the mean, dividing by the

standard deviation in the window

Multiscale Oriented PatcheS descriptor

8 pixels40 pixels

Adapted from slide by Matthew Brown

IxI i )(

Page 10: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Detections at Multiple Scales

Page 11: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Basic idea:• Take 16x16 square window around detected feature

• Compute edge orientation (angle of the gradient - 90) for each pixel

• Throw out weak edges (threshold gradient magnitude)

• Create histogram of surviving edge orientations

Scale Invariant Feature Transform

Adapted from slide by David Lowe

0 2

angle histogram

Page 12: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

SIFT DescriptorFull version

• Divide the 16x16 window into a 4x4 grid of cells (2x2 case shown below)

• Compute an orientation histogram for each cell

• 16 cells * 8 orientations = 128 dimensional descriptor

Adapted from slide by David Lowe

Page 13: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Properties of SIFTExtraordinarily robust matching technique

– Can handle changes in viewpoint• Up to about 60 degree out of plane rotation

– Can handle significant changes in illumination• Sometimes even day vs. night (below)

– Fast and efficient—can run in real time– Lots of code available

• http://people.csail.mit.edu/albert/ladypack/wiki/index.php/Known_implementations_of_SIFT

Page 14: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

PCA-SIFT

• 39x39 patches• Ix, Iy• 39x39x2=3021 D vector 36 D using

Principle Component Analysis

Ke and Sukthankar 2004

Page 15: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Gradient Location-Orientation Histogram (GLOH)

• Log-polar binning structure instead of four quadrants

• 17 spatial bins * 16 orientation bins = 272 D• PCA -> 128 D

Mikolajczyk and Schmid 2005

Best performance overall

Page 16: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Maximally Stable Extremal Regions

• Maximally Stable Extremal Regions– Threshold image intensities: I > thresh

for several increasing values of thresh– Extract connected components

(“Extremal Regions”)– Find a threshold when region is “Maximally

Stable”, i.e. local minimum of the relative growth

– Approximate each region with an ellipse

J.Matas et.al. “Distinguished Regions for Wide-baseline Stereo”. BMVC 2002.

Page 17: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance of Local Descriptor

• Comparison in• GLOH > SIFT > others

Mikolajczyk and Schmid 2005

Page 18: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Many New Descriptors

• Many newer techniques: tuning parameters..

• Trained from large database• Class- or instance- specific features…

Page 19: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

4.1.3 Feature Matching

Given a feature in I1, how to find the best match in I2?1. Define distance function that compares two

descriptors2. Test all the features in I2, find the one with min

distance3. Efficient data structures and algorithms

Page 20: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature DistanceHow to define the difference between features f1, f2?

– Simple approach is SSD(f1, f2) • Sum of square differences between entries of the two

descriptors• Can give good scores to very ambiguous (bad) matches

I1 I2

f1 f2

Page 21: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature DistanceHow to define the difference between features f1, f2?

– Better approach: ratio distance = SSD(f1, f2) / SSD(f1, f2’)• f2 is best SSD match to f1 in I2

• f2’ is 2nd best SSD match to f1 in I2

• gives small values for ambiguous matches

I1 I2

f1 f2f2'

Page 22: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Evaluating the Results

How can we measure the performance of a feature matcher?

5075

200

feature distance

Page 23: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

True/False Positives

The distance threshold affects performance– True positives = # of detected matches that are correct

• Suppose we want to maximize these—how to choose threshold?

– False positives = # of detected matches that are incorrect• Suppose we want to minimize these—how to choose threshold?

5075

200

feature distance

false match

true match

Threshold

Page 24: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation

• TP: true positives, i.e., number of correct matches;• FN: false negatives, matches that were not correctly

detected;• FP: false positives, proposed matches that are

incorrect;• TN: true negatives, non-matches that were correctly

rejected.

Page 25: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

True/False Positive/Negative

• Black 1, 2: features

• Threshold solid circle– Green 1: true positive– Blue 1: false negative – 3: false positive – 4: true negative

• Threshold dashed circle– Green 1: true positive– Blue 1: true positive– 3: false positive – 4: false positive

Page 26: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation

• Unit rates:– True positive rate (TPR)

– False positive rate (FPR)

– Positive predictive value (PPV)

– Accuracy (ACC)

TP TPTPR

TP FN P

TP TNACC

P N

'

TP TPPPV

TP FP P

FP FPFPR

FP TN N

Page 27: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Confusion Matrix

TP=18 FP=4 P’=22

FN=2 TN=76 N’=78

P=20 N=80 Total =100

TPR=0.90 FPR=0.05

PPV=0.82

ACC=0.94

True matches True non-matches

Predicted matches

Predicted non-matches

Ideally, TPR = 1, FPR =0

Page 28: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

0.7

Evaluating the ResultsHow can we measure the performance of a feature matcher?

0 1

1

false positive rate

truepositive

rate

# true positives# matching features (positives)

0.1

# false positives# unmatched features (negatives)

For a specific threshold

Page 29: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

0.7

Evaluating the ResultsHow can we measure the performance of a feature matcher?

0 1

1

false positive rate

truepositive

rate

# true positives# matching features (positives)

0.1# false positives

# unmatched features (negatives)

ROC curve (“Receiver Operator Characteristic”)

ROC Curves• Generated by counting # current/incorrect matches, for different thresholds• Want to maximize area under the curve (AUC)• Useful for comparing different feature matching methods• For more info: http://en.wikipedia.org/wiki/Receiver_operating_characteristic

Close to upper left corner

Page 30: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation

• Give the distribution, look for the best threshold• However, hard to have a clear distribution function• Hard to set a best threshold

Inter-space distance

Distribution of positives and negatives

Page 31: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

• Fixed threshold – Db: FN; Dc, De: FP

• Nearest Neighbor– Db: TP; Dc: FP

Trained from large database to get appropriate threshold

• Nearest neighbor distance ratio (NNDR)– Small d1/d2– Db: TP; Dc, De: TN

Threshold will adapt to different regions of the feature space

(Mikolajczyk and Schmid 2005)

Page 32: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation(Mikolajczyk and Schmid 2005)

Fixed threshold

Page 33: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation(Mikolajczyk and Schmid 2005)

Nearest neighbor

Page 34: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance Evaluation(Mikolajczyk and Schmid 2005)

NNDR

Page 35: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature Space

• Nearest Neighbor Distance Ratio • Adaptive threshold based on different regions

in feature space• Trained from database• ..

Page 36: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Efficient Matching

• Compare all features against all others– Quadratic, impractical for most applications

• Indexing structure – For individual image, or globally for all images – Multi-dimensional search tree– Hash table – Vocabulary tree– …

Page 37: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Efficient Matching

• Multi-dimensional hashing– Map descriptor into fixed size buckets – When matching, new feature is hashed into a

bucket– Search for nearby buckets to return potential

candidates

1 2 3 N……

Page 38: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Haar Wavelets

• 3D index by performing sum over the quadrants

• Normalize the 3 values by their expected standard deviations

• V_n two nearest bins (of 10) index 2^3 = 8 bins• Query: primary 3D bin, k nearest neighbors for

further process

MOPS, Brown, Szeliski, andWinder (2005)

Page 39: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Haar Wavelets

• V_n two nearest bins (of 10) index 2^3 = 8 bins

MOPS, Brown, Szeliski, andWinder (2005)

Page 40: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Haar Wavelets

• Query

• primary 3D bin, • k nearest neighbors for further process

MOPS, Brown, Szeliski, andWinder (2005)

[v1 v2 v3]

Page 41: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

More Structures

• Locality Sensitive Hashing– Use unions of independently computed hashing functions

to index the features

• Parameter-Sensitive Hashing– More sensitive to the distribution of points in parameter

space

• High-D vectors to binary codes– Compared using Hamming distance– Accommodate arbitrary kernel functions

Page 232, 233

[Gionis, Indyk, and Motwani 1999]

[Shakhnarovich, et al,2003]

Torralba, Weiss, and Fergus 2008;Weiss, Torralba, and Fergus 2008;

Kulis and Grauman 2009;Raginsky and Lazebnik 2009

Page 42: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

KD Tree

• Multi-dimensional search tree• Recursively divide multi-D feature space along

alternating axis-aligned hyperplanes • Choose the threshold along each axis so as to

maximize some criterion (tree balance, maximum depth as small as possible…)

• Query: nearby bins

Page 43: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

KD Tree(.22, .56)

More complicated case

Page 44: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Additional Data Structure• Slicing

– use a series of 1D binary searches on point list sorted along different dimensions to efficiently cull down a list of candidate points that lie within a hypercube of the query point

• Reweight the matches at different levels of the indexing tree– Less sensitive to discretization errors in tree construction

• Metric tree – A small number of prototypes at each level in a hierarchy– Visual words classical information retrieval, fast

Page 234

Page 45: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Indexing Structure

• Survey and comparison on indexing structures

• Kd tree works best

• Rapid computation of image feature correspondences remains a challenging open research problem

Muja and Lowe (2009)

Page 46: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Verification and Densification

• Geometry alignment to verify • Inliers and outliers • RANSAC, Random sampling• Will be discussed further in next sections

Page 47: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

4.1.4 Feature Tracking• Find features in all candidate images

– Detect in one then search in others – Detect and track: for video tracking applications, where the

expected amount of motion and appearance deformation between adjacent frames in expected to be small

• Subsequent frames– SSD works well– NCC is better if there is brightness change– Hierarchical search strategy when search range is large:

matches in lower resolution images to provide better initial guesses and speed up the search

Page 48: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

4.1.4 Feature Tracking

• Long image sequence: large appearance change– Whether to continue matching against the originally

detected patch or– Re-sample each subsequent frame at the matching

location

Fail when original patch apperance changes such as foreshotening

Risk: features drift from its original location

Page 49: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Feature Tracking• Affine motion model

– Compare patches in neighboring frames using a translational model– Use the location to initialize an affine registration between the patch in

the current frame and the base frame

– The area around the predicted feature location is searched with an incremental registration algorithm

(Shi and Tomasi 1994)

Detect new features in regions where the tracking has fail

Kanade–Lucas–Tomasi (KLT) tracker.

Page 50: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

A lot of Expansions

• Tracking combined with structure from motion• Tie together the corners • Tracking in video with large number of moving

objects or points • Special purpose recognizer: Learning algorithms

– Train classifiers on sample patches and their affine deformation, fast and reliable, fast motion is supported

• Survey … (Yilmaz, Javed, and Shah 2006)

Page 236

Page 51: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Real-time head tracking using the fast trained classifiers of Lepetit, Pilet, and Fua (2004) 2004 IEEE.

Page 52: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Application: Performance-driven animation

• Expression and head tracking • Morph among a series of hand-drawn sketches

Buck, Finkelstein, Jacobs et al. (2000)

Page 53: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance-Driven Animation

• An animator first extracts the eye and mouth regions of each sketch and draws control lines over each image

Page 54: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance-Driven Animation

• An animator first extracts the eye and mouth regions of each sketch and draws control lines over each image

• At run time, a face-tracking system (Toyama 1998) determines the current location of these features.

Page 55: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance-Driven Animation

• An animator first extracts the eye and mouth regions of each sketch and draws control lines over each image

• At run time, a face-tracking system (Toyama 1998) determines the current location of these features.

• The animation system decides which input images to morph based on nearest neighbor feature appearance matching and triangular barycentric interpolation.

• It also computes the global location and orientation of the head from the tracked features.

Page 56: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

correspondence

Morph based on nearest neighbor feature appearance matching

triangular barycentric interpolation

Page 57: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Performance-Driven Animation

• An animator first extracts the eye and mouth regions of each sketch and draws control lines over each image

• At run time, a face-tracking system (Toyama 1998) determines the current location of these features.

• The animation system decides which input images to morph based on nearest neighbor feature appearance matching and triangular barycentric interpolation.

• It also computes the global location and orientation of the head from the tracked features.

• The resulting morphed eye and mouth regions are then composited back into the overall head model to yield a frame of hand-drawn animation

Page 58: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.
Page 59: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

More on feature detection/description

Page 60: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Lots of Applications

Features are used for:– Image alignment (e.g., mosaics)– 3D reconstruction– Motion tracking– Object recognition– Indexing and database retrieval– Robot navigation– … other

Page 61: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Object Recognition (David Lowe)

Page 62: 4.1 Feature: Point and Patches Xuejin Chen Reading: Szeliski Chap. 4 222~238.

Sony Aibo

SIFT usage:

Recognize charging station

Communicate with visual cards

Teach object recognition