1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

35
1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Page 1: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

1

Model Fitting

Hao Jiang

Computer Science Department

Oct 6, 2009

Page 2: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Model Fitting

An object model constrains the kind of object we wish to find in images.

2

window

Front wheel

Back wheel

Page 3: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Type of 2D Models

Rigid models

Deformable models

Articulated models

3

Page 4: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Template Matching

4

Template

Target image

Page 5: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Template Matching

5

Template

Target image

Page 6: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Template Matching

6

Template

Target image

Page 7: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Template Matching

7

Template

Target image

Page 8: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Template Matching

8

Template

Target image

Page 9: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Matching Criteria

9

At each location (x,y) the matching cost is:

Page 10: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Dealing with Rotations

10

Template

Target image

Page 11: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Dealing with Scale Changes

11

Template

Target image in multiple scales

Sweep windowand find the best match

Page 12: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Multi-scale Refinement

12

Template

Target image in multiple scales

Start from here

Complexity reduced from O(n^2 k^2) to O(log(n/m) + m^2 j^2)

size n

size m

size k

size j

Page 13: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Multi-scale Refinement

13

1. Generate the image pyramids

2. Exhaustive search the smallest image and get location (x,y)

3. Go to the next level of the pyramid and check the locations (2x, 2y), (2x+1,2y), (2x,2y+1), (2x+1,2y+1), pick up the best and update the estimate.

4. If at the bottom of the pyramid, stop; otherwise go to 3.

5. Output the estimate (x,y)

Page 14: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Binary Template Matching

14G.M. Gavrila, “Pedestrian detection from a moving vechicle”, ECCV 2000

Page 15: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Matching Binary Template

15

Template

Binary target image

Targetobject

Clutter

Page 16: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Distance of Curves

16

d_red(p)

d_green(q)

For each point p on the red curve,find the closed point q on the green curve.Denote

The distance from red curve to the greencurve =

Similarly, the distance from the green curve to the red curve is

q

p

Page 17: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Distance Transform Transform binary image into an image whose pixel values equal

the closest distance to the binary foreground.

17

Page 18: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Chamfer Matching

18

d_red(p) = distI(p)p

Page 19: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Chamfer Matching in Matlab

19

% distance transform and matchingdist = bwdist(imTarget, ‘euclidean’);map = imfilter(dist, imTemplate, ‘corr’, ‘same’);

%look for the local minima in map to locate objectssmap = ordfilt2(map, 25, true(5));[r, c] = find((map == smap) & (map < threshold));

Page 20: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Hough Transform

Template matching may become very complex if transformations such as rotation and scale is allowed.

A voting based method, Hough Transform, can be used to solve the problem.

Instead of trying to match the target at each location, we collect votes in a parameter space using features in the original image.

20

Page 21: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

21

Page 22: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

22

Page 23: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

23

x

y

(1) Where is the line?(2) How many lines?(3) Which point belongs to which line?

Page 24: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

24

x

y

y = ax + b

For each point, there are many lines that pass it.

(x1,y1)

Page 25: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

25

a

b

b = -x1a + y1

All the lines passing (x1,y1) can be represented as another linein the parameter space.

y1

y1/x1

Page 26: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

26

a

b

b = -x1a + y1

The co-linear points vote for the same point in the a-b space.

y

y/x

b = -x2a + y2

Page 27: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Detection

27

a

b

b = -x1a + y1 y

y/x

b = -x2a + y2

b = -x(n)a + y(n)

The co-linear points vote for the same point in the a-b space. Thepoint that receives the most votes corresponds to the line.

Page 28: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Line Parameterization

28

x

y

theta

d

x cos(theta) + y sin(theta) = d

Page 29: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Parameter Space

29

theta

r

x cos(theta) + y sin(theta) = r

Page 30: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Hough Transform AlgorithmUsing the polar parameterization:

Basic Hough transform algorithm1. Initialize H[d, ]=0

2. for each edge point I[x,y] in the image

for = 0 to 180 // some quantization

H[d, ] += 1§ Find the value(s) of (d, ) where H[d, ] is maximum§ The detected line in the image is given by

Hough line demo

H: accumulator array (votes)

d

Time complexity (in terms of number of votes)?

dyx sincos

Source: Steve Seitz

sincos yxd

sincos yxd

Page 31: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Image spaceedge coordinates

Votes

d

x

y

Example: Hough transform for straight lines

Bright value = high vote countBlack = no votes

Source: K. Grauman

Page 32: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Impact of noise on Hough

Image spaceedge coordinates

Votes

x

y d

What difficulty does this present for an implementation?Source: K. Grauman

Page 33: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

Image spaceedge coordinates

Votes

Impact of noise on Hough

Here, everything appears to be “noise”, or random edge points, but we still see peaks in the vote space.

Source: K. Grauman

Page 34: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

ExtensionsExtension 1: Use the image gradient

1. same

2. for each edge point I[x,y] in the image

= gradient at (x,y)

H[d, ] += 1

3. same

4. same

(Reduces degrees of freedom)

ExThe same procedure can be used with circles, squares, or any other shape

sincos yxd

Source: K. Grauman

Page 35: 1 Model Fitting Hao Jiang Computer Science Department Oct 6, 2009.

ExtensionsExtension 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…

Source: K. Grauman