• No results found

The Top Ten Algorithms of the Century

N/A
N/A
Protected

Academic year: 2022

Share "The Top Ten Algorithms of the Century"

Copied!
23
0
0

Loading.... (view fulltext now)

Full text

(1)

Title Page

Contents

JJ II

J I

Page1of23

Go Back

Full Screen

Sharat Chandran

Computer Science & Engineering Department, Indian Institute of Technology,

(2)

Title Page

Contents

JJ II

J I

Page2of23

Go Back

Full Screen

Close

The Top Ten Algorithms of the Century

Metropolis Algorithm for Monte Carlo

Simplex Method for Linear Programming

Krylov Subspace Iteration Methods

The Decompositional Ap- proach to Matrix Computa- tions

QR Algorithm for Computing Eigenvalues

The Fortran Optimizing Com- piler

Quicksort Algorithm for Sort- ing

Fast Fourier Transform

Integer Relation Detection

Fast Multipole Method

(3)

Title Page

Contents

JJ II

J I

Page3of23

Go Back

Full Screen

Overview

1. Sample problems from computer vision (fade out computer vision gurus)

The problem of shape

The problem of obtaining 3D information

The problem of motion

2. The beauty of mathematics (fade out math gurus)

The method of the calculus of variations

Allied mathematical methods: Singular Value Decomposition, and the Method of Lagrange Multipliers

3. Sample solution to problems posed (or how computer scientists teach/cheat)

(4)

Title Page

Contents

JJ II

J I

Page4of23

Go Back

Full Screen

Close

Shape

When placed out of context, images can be quite involved

What you get is not what you see (WYGINWYS)

What you want to compute: A contour (useful for obtaining properties such as size)

Key mathematical concept:

parametric curve

x(s), y(s)

Idealized image

(5)

Title Page

Contents

JJ II

J I

Page5of23

Go Back

Full Screen

Motion

Optical flow is an intensity- based approximation to image motion from sequential time- ordered images

Key mathematical concept:

Two functions:

u(x, y)

and

v(x, y)

What does it look like?

How do we compute optical flow?

(6)

Title Page

Contents

JJ II

J I

Page6of23

Go Back

Full Screen

Close

Application of Optical Flow

A short video segment

Specifications tohelp.

(7)

Title Page

Contents

JJ II

J I

Page7of23

Go Back

Full Screen

Two Problems

Determine the equation of the curve joining two points

(x

1

, y

1

)

and

(x

2

, y

2

)

on the plane such that the length of the curve joining them is minimum

(x1, y1)

(x2, y2)

Goal: Prove that your answer is correct

Similar problem: Determine the equation of the support so that a ball placed at

(x

1

, y

1

)

reaches (due to gravity)

(x

2

, y

2

)

in the least possible time

(8)

Title Page

Contents

JJ II

J I

Page8of23

Go Back

Full Screen

Close

Functions and Functionals

Differential segment length is

( dx

2

+ dy

2

)

1/2 where

dx

and

dy

are infinitesimal lengths in the x and y directions along the curve.

Therefore the length of the curve joining the two end points

(x

1

, y

1

)

and

(x

2

, y

2

)

is

J =

Z

x2 x1

p (1 + y

0

) dx

=

Z

x2

x1

F (x, y, y

0

) dx

For the first problem, what should the function

y

be so that

J

is mini- mized?

Compare: Find

x

0 such that

y = f (x)

is minimum.

• J

is a functional, a quantity that depends on functions rather than depen- dent variables.

(9)

Title Page

Contents

JJ II

J I

Page9of23

Go Back

Full Screen

Solution to the Shortest Length Problem

The Euler-Lagrange equation is a necessary condition for minimising

J F

y

− d

dx F

y0

= 0

(1)

In our problem,

F = p

1 + y

0. Applying Equation 1 we get

d

dx ( y

0

√ 1 + y

0

) = 0

Solution:

y

0 is a constant.

The shortest distance curve is a straight line.

(10)

Title Page

Contents

JJ II

J I

Page10of23

Go Back

Full Screen

Close

Detour: Why the Euler equation

• J = R

x2

x1

F (x, f, f

0

) dx

with boundary conditions

f (x

1

) = f

1 and

f (x

2

) = f

2.

Let

η(x)

be a test function. Deform

f

by

η(x)

. Then,

dJ/ d = 0

at the “right” place.

This is true for all test functions

η(x)

. The boundary conditions assert

η(x

1

) = η(x

2

) = 0

If

f (x)

is replaced by

f (x) + η(x)

then

f

0

(x)

will be replaced by

f

0

(x) + η

0

(x)

.

The integral then becomes

J =

Z

x2 x1

F (x, f + η, f

0

+ η

0

) dx

(11)

Title Page

Contents

JJ II

J I

Page11of23

Go Back

Full Screen

Detour: Why the Euler equation

If

F

is differentiable, expand the integrand in a Taylor series

Differentiate with respect to

and set to zero

Apply integration by parts to get

Z

x2

x1

η

0

(x)F

f0

dx = [η(x)F

f0

]

xx21

− Z

x2

x1

η (x) d(F

f

) dx dx,

The first term is zero due to the boundary conditions

Hence

Z

x2

x1

η(x)(F

f

− dF

f0

dx )dx = 0

(12)

Title Page

Contents

JJ II

J I

Page12of23

Go Back

Full Screen

Close

Bottom Line Euler Equations

Various generalizations are possible – Higher order derivatives:

J = R

x2

x1

F (x, f, f

0

, f

00

, ...)dx

– Integrand may depend on several functions instead of only one – Finding functions that have two independent variables

J = Z Z

F (x, y, f, f

x

, f

y

)dxdy

The bottom line

Function to optimize The Euler-Lagrange equations

R F (x, u

x

)dx F

u

dxd

F

ux = 0

R F (x, u

x

, u

xx

)dx F

u

dxd

F

ux

dxd22

F

uxx = 0

R F (x, u

x

, v

x

)dx F

u

dxd

F

ux = 0

F

v

dxd

F

vx = 0

R R F (x, y, u

x

, u

y

)dxdy F

u

dxd

F

ux

dyd

F

uy = 0

(13)

Title Page

Contents

JJ II

J I

Page13of23

Go Back

Full Screen

The Snake Formulation

Start with any old curve (a “snake”).

Mathematically deform it to be the de- sired shape (based on image data).

Curve is

v(s) = (x(s), y(s))

. Define en- ergy of the curve to be

E(v(s)) = Z

1

0

E

snake

(v(s)) ds

(2) where

E

snake

= E

int

+ E

ext

Find the curve that minimizes Equation 2

Remember, actual im- age is not so clean!

(14)

Title Page

Contents

JJ II

J I

Page14of23

Go Back

Full Screen

Close

More on Formulation

The energy functional is given by

E = R

1

0

(E

int

(v(s)) + E

img

(v(s)) + E

con

(v(s))) ds

• E

int

= (α(s) | v

s

(s) |

2

+ β(s) | v

ss

(s) |

2

)/2

• E

con

= − k(v(s) − x) ¯

2

• E

img

= w

line

E

line

(v(s)) + w

edge

E

edge

(v(s)) + w

term

E

term

(v(s))

– Line energy is

E

line

(v(s)) = I (x, y)

– Edge energy is

E

edge

(v(s)) = − |∇I (x, y) |

2

(15)

Title Page

Contents

JJ II

J I

Page15of23

Go Back

Full Screen

Applying Euler-Lagrange to Snakes

We minimize

J

1

= Z

(α(s)x

2s

+ β (s)x

2ss

)/2 + E

x

(s)ds = Z

X (s, x, x

0

, x

00

)ds

and

J

2

= Z

(α(s)y

s2

+ β (s)y

2ss

)/2 + E

y

(s)ds = Z

Y (s, y, y

0

, y

00

)ds

For

X (s, x, x

0

, x

00

)

the Euler equation is

X

x

− d

ds X

x0

+ d

2

ds

2

X

x00

= 0

(16)

Title Page

Contents

JJ II

J I

Page16of23

Go Back

Full Screen

Close

More on Application

• X

x

=

∂E∂s,

X

x0

= α(s)x

0

(s)

, and

X

x00

= β (s)x

00

(s)

dsd

X

x0

= α

0

x

0

+ αx

00 and

dsd

(X

00

(s)) = β

0

x

00

+ βx

000 and

dsd22

(X

00

(s)) = β

00

x

00

+ 2β

0

x

000

+ βx

0000

For purpose of illustration use only two terms: ∂E∂s

− α

0

x

0

− αx

00

= 0

Numerically approximating we have ∂E∂x

' E

i+1

− E

i at location i

α

0

(s) ' α

i+1

− α

i

x

0

(s) ' x

i+1

− x

i

α

0

x

0

= (α

i+1

− α

i

)(x

i+1

− x

i

) = (α

i+1

− α

i

)x

i+1

− (α

i+1

− α

i

)x

i

x

00

(s) ' x

i+1

− 2x

i

+ x

i1

(17)

Title Page

Contents

JJ II

J I

Page17of23

Go Back

Full Screen

Reducing Snakes To A Matrix Equation

− 1 1 . . . 0 0 − 1 . . . 0

... ... . . . ...

0 0 . . . − 1

 E

1

E

2 ...

E

n

 −

− (α

2

− α

1

) (α

2

− α

1

) 0 . . . 0 0 − (α

3

− α

2

) (α

3

− α

2

) . . . 0

... ... ... . . . ...

0 0 0 . . . − (α

n+1

− α

n

)

 x

1

x

2 ...

x

n

 α

1

α

2 ...

α

n

T

− 2 1 0 . . . 0 0 1 − 2 1 . . . 0 0

... ... ... ... ... ...

0 0 0 . . . − 2 1

 x

1

x

2 ...

x

n

 = 0

This can be written as

Ax = B

, and solved using SVD.

(18)

Title Page

Contents

JJ II

J I

Page18of23

Go Back

Full Screen

Close

The Method of Lagrange Multipliers

Minimize a function

f (x, y)

subject to

g(x, y) = 0

.

For example, find a point on the line

x sin θ − y cos θ + p = 0

closest to origin

That is, minimize

x

2 +

y

2 subject to the given constraint.

In MOLM, we generate a new function

E = f + λg

and set the partial derivatives with respect to

x

,

y

and

λ

to zero.

In the example

• 2x + λ sin θ = 0

• 2y + λ cos θ = 0

• x sin θ − y cos θ + p = 0

The solution is the obvious one

• x = − p sin θ

• y = +p cos θ

The method can be generalized to larger number of constraints.

(19)

Title Page

Contents

JJ II

J I

Page19of23

Go Back

Full Screen

Formulation for Motion

Let

E(x, y, t)

be the intensity value at point

(x, y)

in the image

Due to motion, let this point correspond to a point

(x + δx, y + δy )

at time instance

t + δt

Key assumption:

E(x, y, t) = E(x + δx, y + δy, t + δt)

Two parts to determine

u(x, y)

and

v (x, y)

– Use Taylor’s theorem to get

E

x

u + E

y

v + E

t

= 0

– Introduce a smoothness constraint:

f (u, v, u

x

, v

x

, u

y

, v

y

) = u

x2

+ u

y2

+ v

x2

+ v

y2

Using MOLM we have a functional that needs to be minimized

Z Z

f (u, v, u

x

, v

x

, u

y

, v

y

) + λg(u, v, t)

2

dxdy

(20)

Title Page

Contents

JJ II

J I

Page20of23

Go Back

Full Screen

Close

Applying Euler-Lagrange for Optical Flow

We have

F

u

∂x

F

ux

∂y

F

uy

= 0 F

v

∂x

F

vx

∂y

F

vy

= 0

Applying these we get

F

u

= 2λE

x

(E

x

u + E

y

v + E

t

)

F

ux

= 2u

x, ∂x

F

ux

= 2u

xx

F

uy

= 2u

y, ∂y

F

uy

= 2u

yy

And

F

v

= 2λE

x

(E

x

v + E

y

v + E

t

)

F

vx

= 2v

x, ∂x

F

vx

= 2v

xx

F

vy

= 2v

y, ∂y

F

vy

= 2v

yy

This implies a coupled system of equations

2

u = λ(E

x

u + E

y

v + E

t

)E

x

2

v = λ(E

x

u + E

y

v + E

t

)E

y

(21)

Title Page

Contents

JJ II

J I

Page21of23

Go Back

Full Screen

Solution using Euler Lagrange

Discretizing we have

• u

k,l,

u

k+1,l

u

k,l+1

u

k1,l

u

k,l1:

u

component of the velocity at points

(k, l)

,

(k + 1, l)

,

(k, l + 1)

,

(k − 1, l)

and

(k, l − 1)

respectively.

• v

k,l,

v

k+1,l

v

k,l+1

v

k1,l

v

k,l1:

v

component of the velocity at points

(k, l)

,

(k + 1, l)

,

(k, l + 1)

,

(k − 1, l)

and

(k, l − 1)

respectively.

u

k,l

= u

k,l

− λE

x

E

t

1 + ˜ λE

x2

− v

k,l

E

x

E

t

1 + ˜ λE

x2

v

k,l

= v

k,l

− λE

x

E

t

1 + ˜ λE

x2

− u

k,l

E

x

E

t

1 + ˜ λE

x2

(22)

Title Page

Contents

JJ II

J I

Page22of23

Go Back

Full Screen

Close

Uses of Euler Lagrange

P roblem Regularization principle

Contours R

Esnake(v(s))ds Area based Optical f low R

[(ux2

+uy2

+vx2

+vy2

) +λ(Exu+Eyv+it)2)]dxdy

Edge detection R

[(Sfi)2+λ(fxx)2]dx Contour based Optical f low R

[(V ·NVN)2+λ(δVδx)2] Surf ace reconstruction R

[(S·fd2+λ(fxx+ 2fxy2

+fyy2

)]dxdy Spatiotemporal approximation R

[(S·fi)2+λ(f·V +f t)2]dxdydt Colour kIyAxk2+λkP zk2

Shape f rom shading R

[(ER(f, g))2+λ(fx2

+fy2

+gx2

+gy2

)]dxdy

Stereo R

{[2G(L(x, y)R(x+d(x, y), y))]2+λ(d)2}dxdy

(23)

Title Page

Contents

JJ II

J I

Page23of23

Go Back

Full Screen

Concluding Remarks

Two interesting problems have been described

Defined and derived the Euler Lagrange equations

Used mathematics to solve the computer vision problem

References

Related documents

We can use Taylor series to quantify the local truncation error in Euler’s method. In real problems, the derivatives used in the Taylor series are not easy

With respect to other government schemes, only 3.7 per cent of waste workers said that they were enrolled in ICDS, out of which 50 per cent could access it after lockdown, 11 per

This paper discusses an approach for river mapping and flood evaluation based on multi-temporal time-series analysis of satellite images utilizing pixel spectral information for

Since planar graphs have 3 dimensional box represen- tations computable in polynomial time [20], using our algorithm of Theorem 1, we get an FPT algorithm for boxicity, giving a 2

The scan line algorithm which is based on the platform of calculating the coordinate of the line in the image and then finding the non background pixels in those lines and

[8] have proposed an approach of motion segmented method, the optical flow is calculated based on motion history templates and sectioned into four directions: up, down, left, and

With the image Acquisition tool, we can extract images from the video, visualize the data and change our mechanism to trigger the warning signal, develop processing

Normalized mutual information based rigid image registration has done by using genetic algorithm, particle swarm optimization methods, GA is completely random