ffts in graphics and visionmisha/fall08/14.pdf · basis {v 1,…,v n} we can define an orthonormal...
TRANSCRIPT
FFTs in Graphics and Vision
Spherical Harmonics
and
Legendre Polynomials
1
Outline
Math StuffGram-Schmidt Orthogonalization
Height Functions
Completing Homogenous Polynomials
Review
Defining the Harmonics
2
Gram–Schmidt Orthogonalization
Given an inner product space V, and given a
basis {v1,…,vn} we can define an orthonormal
basis {w1,…,wn} for V:
3
ijji ww ,
Gram–Schmidt Orthogonalization
Given an inner product space V, and given a
basis {v1,…,vn} we can define an orthonormal
basis {w1,…,wn} for V:
Algorithm:
Start by making v1 a unit vector:
4
ijji ww ,
1
11
v
vw
Gram–Schmidt Orthogonalization
Given an inner product space V, and given a
basis {v1,…,vn} we can define an orthonormal
basis {w1,…,wn} for V:
Algorithm:
To get the 2nd basis element, subtract off from v2
the w1 component and then normalize:
5
ijji ww ,
1122
1122
2,
,
wwvv
wwvvw
Gram–Schmidt Orthogonalization
Given an inner product space V, and given a
basis {v1,…,vn} we can define an orthonormal
basis {w1,…,wn} for V:
Algorithm:
To get the i-th basis element, subtract off all the
earlier components from vi and then normalize:
6
ijji ww ,
1111
1111
,,
,,
wwvwwvv
wwvwwvvw
iiiii
iiiii
i
Gram–Schmidt Orthogonalization
Example:
Consider the space of polynomial functions of
degree N on the interval [-1,1], with the standard
inner-product:
We would like to obtain an orthogonal basis:
7
1
1
)()()(),( dxxgxfxgxf
)(,),(0 xpxp N
Gram–Schmidt Orthogonalization
Example:
Consider the space of polynomial functions of
degree N on the interval [-1,1], with the standard
inner-product:
We would like to obtain an orthogonal basis:
An easy basis to start with is the monomials:
8
1
1
)()()(),( dxxgxfxgxf
Nxxx ,,,,1 2
)(,),(0 xpxp N
Gram–Schmidt Orthogonalization
Example:
Starting with the constant term, we get:
9
2
1
1
1
1)(
1
1
0
dx
xp
Gram–Schmidt Orthogonalization
Example:
Starting with the constant term, we get:
10
2
1
1
1
1)(
1
1
0
dx
xp
Gram–Schmidt Orthogonalization
Example:
Starting with the constant term, we get:
11
2
1
1
1
1)(
1
1
0
dx
xp
Gram–Schmidt Orthogonalization
Example:
Moving on to the linear term, we get:
12
x
dxx
x
xpxpxx
dxxx
xpxpxx
xpxpxxxp
2
3
)()(,
2
1
2
1
)()(,
)()(,)(
1
1
2
00
1
1
00
00
1
Gram–Schmidt Orthogonalization
Example:
Moving on to the linear term, we get:
13
x
dxx
x
xpxpxx
dxxx
xpxpxx
xpxpxxxp
2
3
)()(,
2
1
2
1
)()(,
)()(,)(
1
1
2
00
1
1
00
00
1
Gram–Schmidt Orthogonalization
Example:
Moving on to the linear term, we get:
14
x
dxx
x
xpxpxx
dxxx
xpxpxx
xpxpxxxp
2
3
)()(,
2
1
2
1
)()(,
)()(,)(
1
1
2
00
1
1
00
00
1
Gram–Schmidt Orthogonalization
Example:
And the quadratic term:
15
)()(,)()(,
)()(,)()(,)(
00
2
11
22
00
2
11
22
2
xpxpxxpxpxx
xpxpxxpxpxxxp
Gram–Schmidt Orthogonalization
Example:
And the quadratic term:
16
These polynomials are called the
Legendre Polynomials.
)()(,)()(,
)()(,)()(,)(
00
2
11
22
00
2
11
22
2
xpxpxxpxpxx
xpxpxxpxpxxxp
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
...)( 2
2
k
k
k
kk xaxaxp
17
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction:
...)( 2
2
k
k
k
kk xaxaxp
18
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction (k=0):
2
1)(0 xp
...)( 2
2
k
k
k
kk xaxaxp
19
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction (assume true for k=n):
...)( 2
2
k
k
k
kk xaxaxp
)()(,)()(,
)()(,)()(,)(
00
111
00
111
1
xpxpxxpxpxx
xpxpxxpxpxxxp
n
nn
nn
n
nn
nn
n
20
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction (assume true for k=n):
Recall that:
1
1
11 )()(, dxxpxxpx m
n
m
n
)()(,)()(,
)()(,)()(,)(
00
111
00
111
1
xpxpxxpxpxx
xpxpxxpxpxxxp
n
nn
nn
n
nn
nn
n
...)( 2
2
k
k
k
kk xaxaxp
21
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction:
Since mn we can assume that the monomials
comprising pm(x) are all even if m is even and all
odd if m is odd.
1
1
11 )()(, dxxpxxpx m
n
m
n
...)( 2
2
k
k
k
kk xaxaxp
22
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction:
So if n and m are both either odd or both even,
the polynomial xn+1pm(x) is comprised of strictly
odd-powered monomials:
0)()(,
1
1
11
dxxpxxpx m
n
m
n
...)( 2
2
k
k
k
kk xaxaxp
23
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction:
)()(,)()(,
)()(,)()(,)(
00
111
00
111
1
xpxpxxpxpxx
xpxpxxpxpxxxp
n
nn
nn
n
nn
nn
n
)()(,)()(,
)()(,)()(,)(
33
1
11
11
33
1
11
11
1
xpxpxxpxpxx
xpxpxxpxpxxxp
nn
n
nn
nn
nn
n
nn
nn
n
...)( 2
2
k
k
k
kk xaxaxp
24
Legendre Polynomials
Claim:
The degrees of the monomials comprising the
Legendre polynomials have the same parity as k:
Proof by Induction:
So pn+1(x) is obtained by starting with the
monomial xn+1 and subtracting off monomials with
the same parity.
)()(,)()(,
)()(,)()(,)(
33
1
11
11
33
1
11
11
1
xpxpxxpxpxx
xpxpxxpxpxxxp
nn
n
nn
nn
nn
n
nn
nn
n
...)( 2
2
k
k
k
kk xaxaxp
25
Gram–Schmidt Orthogonalization
Example:
Consider the space of polynomials of degree N
on the interval [-1,1], with an inner-product giving
more weight to points near the origin:
26
1
1
2 )()(1)(),( dxxgxfxxgxfm
m
Gram–Schmidt Orthogonalization
Example:
Consider the space of polynomials of degree N
on the interval [-1,1], with an inner-product giving
more weight to points near the origin:
We would like to obtain an orthogonal basis:
27
1
1
2 )()(1)(),( dxxgxfxxgxfm
m
)(,),(0 xpxp m
N
m
Gram–Schmidt Orthogonalization
Example:
We proceed exactly as before but now using the
new inner-product.
28
1
1
2 )()(1)(),( dxxgxfxxgxfm
m
Gram–Schmidt Orthogonalization
Example:
We proceed exactly as before but now using the
new inner-product.
Since the weighting function is even, if f is an
even function and g is an odd function (or vice-
versa), the inner product must be zero:
29
0)(),( m
xgxf
1
1
2 )()(1)(),( dxxgxfxxgxfm
m
Gram–Schmidt Orthogonalization
Example:
We proceed exactly as before but now using the
new inner-product.
Since the weighting function is even, if f is an
even function and g is an odd function (or vice-
versa), the inner product must be zero:
Thus, as before, the degree of the monomials
comprising plm(x) must all have the same parity. 30
0)(),( m
xgxf
1
1
2 )()(1)(),( dxxgxfxxgxfm
m
Height Functions
Given a function f(x) on the interval [-1,1], we can
turn the function into a function on the sphere:
2
)(),,(
yfzyxF
31
Height Functions
Given a function f(x) on the interval [-1,1], we can
turn the function into a function on the sphere:
Given two such functions f(x) and g(y), the
mapping from 1D functions to spherical functions
preserves inner products:
2
)(),,(
yfzyxF
1
11
)()()()( dyygyfdppGpFp
32
Height Functions
To see this, we can parameterize points on the
sphere by spherical angle:
Then the integral on the left-hand side becomes:
sinsin,cos,sincos),(
0
0
2
0
0
2
01
)sin(coscos
)sin(coscos2
1
)sin(),(),()()(
dgf
ddgf
ddGFdppGpFp
33
Height Functions
To see this, we can parameterize points on the
sphere by spherical angle:
Then the integral on the left-hand side becomes:
sinsin,cos,sincos),(
0
0
2
0
0
2
01
)sin(coscos
)sin(coscos2
1
)sin(),(),()()(
dgf
ddgf
ddGFdppGpFp
34
Height Functions
To see this, we can parameterize points on the
sphere by spherical angle:
Then the integral on the left-hand side becomes:
sinsin,cos,sincos),(
0
0
2
0
0
2
01
)sin(coscos
)sin(coscos2
1
)sin(),(),()()(
dgf
ddgf
ddGFdppGpFp
35
Height Functions
On the other hand, setting y=cos, the left-hand
side can be expressed as:
0
0
01
1
)sin()(cos)(cos
)sin()(cos)(cos
)(cos)(cos)()(
dgf
dgf
dd
dygfdyygyf
36
Height Functions
On the other hand, setting y=cos, the left-hand
side can be expressed as:
0
0
01
1
)sin()(cos)(cos
)sin()(cos)(cos
)(cos)(cos)()(
dgf
dgf
dd
dygfdyygyf
37
Height Functions
On the other hand, setting y=cos, the left-hand
side can be expressed as:
0
0
01
1
)sin()(cos)(cos
)sin()(cos)(cos
)(cos)(cos)()(
dgf
dgf
dd
dygfdyygyf
38
Height Functions
On the other hand, setting y=cos, the left-hand
side can be expressed as:
dppGpF
dgf
dgf
dd
dygfdyygyf
p
)()(
)sin()(cos)(cos
)sin()(cos)(cos
)(cos)(cos)()(
1
0
0
01
1
39
Completing Homogenous Polynomials
Given a polynomial p(x,y,z) of degree d,
consisting of monomials of powers d,d-2,d,…:
2/
0 2
),,(d
k kdnml
nml
lmn zyxazyxp
40
Completing Homogenous Polynomials
Given a polynomial p(x,y,z) of degree d,
consisting of monomials of powers d,d-2,d,…:
This is not a homogenous polynomial.
2/
0 2
),,(d
k kdnml
nml
lmn zyxazyxp
41
Completing Homogenous Polynomials
Given a polynomial p(x,y,z) of degree d,
consisting of monomials of powers d,d-2,d,…:
This is not a homogenous polynomial.
However, if we restrict it to the sphere, we can
think of it as homogenous:
2/
0 2
),,(d
k kdnml
nml
lmn zyxazyxp
2/
0 2
222),,(d
k kdnml
nml
lmn
kzyxazyxzyxp
42
Completing Homogenous Polynomials
Example:
Is not a homogenous polynomial.
zyyxzyxp 2),,(
43
Completing Homogenous Polynomials
Example:
Is not a homogenous polynomial.
But on the unit-sphere, the polynomial:
has identical values and is homogenous of
degree 3.
zyyxzyxp 2),,(
2222),,( zyxzyyxzyxq
44
Outline
Math Stuff
ReviewSpherical Harmonics
Defining the Harmonics
45
Spherical Harmonics
For each non-negative integer l, there are 2l+1
spherical harmonics of degree l satisfying:
1. Each spherical harmonic of degree l can be
expressed as the restriction of a homogenous
polynomial of degree l to the unit-sphere.
2. The different spherical harmonics are
orthogonal to each other.
46
Spherical Harmonics
We had seen that by considering just the
rotations about the y-axis, we could factor the
spherical harmonics as:
where |m|l.
)(sincos
)(,
m
l
m
m
l
imm
l
Pi
PeY
47
Outline
Math Stuff
Review
Defining the Harmonics
48
Defining the Harmonics (m0)
To define the spherical harmonics, we would like
to express the function:
as the restriction of a homogenous polynomial of
degree l to the unit sphere.
49
)(sincos, m
l
mm
l PiY
Defining the Harmonics (m0)
Using the parameterization of the unit-sphere
we get:
sinsin,cos,sincos),(
m
m
lm
m
m
lm
m
l
m
m
l
y
yPizx
Pizx
Pz
ix
Y
2
1
1
)(cos
sin
)(
)(sinsin
,
50
Defining the Harmonics (m0)
Using the parameterization of the unit-sphere
we get:
sinsin,cos,sincos),(
m
m
lm
m
m
lm
m
l
m
m
l
y
yPizx
Pizx
Pz
ix
Y
2
1
1
)(cos
sin
)(
)(sinsin
,
51
Defining the Harmonics (m0)
Using the parameterization of the unit-sphere
we get:
sinsin,cos,sincos),(
m
m
lm
m
m
lm
m
l
m
m
l
y
yPizx
Pizx
Pz
ix
Y
2
1
1
)(cos
sin
)(
)(sinsin
,
52
Defining the Harmonics (m0)
This is a homogenous polynomial of degree m.
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
53
Defining the Harmonics (m0)
This is a homogenous polynomial of degree m.
So we want:
1. This to complete to a homogenous
polynomial of degree l-m.
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
54
Defining the Harmonics (m0)
This is a homogenous polynomial of degree m.
So we want:
1. This to complete to a homogenous
polynomial of degree l-m.
2. The different Ylm to be orthogonal.
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
55
Defining the Harmonics (m0)
Homogeneity:
To satisfy the homogeneity constraint, we need:
...
1
)(cos 2
22
1
ml
ml
ml
mlm
m
l yaya
y
yP
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
56
Defining the Harmonics (m0)
Homogeneity:
To satisfy the homogeneity constraint, we need:
Or equivalently:
for a polynomial:
...
1
)(cos 2
22
1
ml
ml
ml
mlm
m
l yaya
y
yP
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
mm
l
m
l yyqyP 21 1)(cos
...)( 2
2
ml
ml
ml
ml
m
l yayayq 57
Defining the Harmonics (m0)
Orthogonality:
To satisfy the orthogonality constraint, we need:
'or ' 0),(),,( '
' mmllYY m
l
m
l
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
58
Defining the Harmonics (m0)
Orthogonality (mm’):
Since we have separation of variables:
we know that:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
)(, m
l
imm
l PeY
2
0
)'(
0
'
'
0
2
0
'
'
''
'
sin)()(
sin)()(),(),,(
dedPP
ddPePeYY
mmim
l
m
l
m
l
imm
l
imm
l
m
l
59
Defining the Harmonics (m0)
Orthogonality (mm’):
Since we have separation of variables:
we know that:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
)(, m
l
imm
l PeY
2
0
)'(
0
'
'
0
2
0
'
'
''
'
sin)()(
sin)()(),(),,(
dedPP
ddPePeYY
mmim
l
m
l
m
l
imm
l
imm
l
m
l
60
Defining the Harmonics (m0)
Orthogonality (mm’):
But this is zero whenever mm’:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
2
0
)'(
0
'
'
'
' sin)()(),(),,( dedPPYY mmim
l
m
l
m
l
m
l
0)'(
12
0
)'(
2
0
)'(
mmimmi emmi
de
61
Defining the Harmonics (m0)
Orthogonality (m=m’ and ll’):
We have to choose the function:
so that:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
mm
l
m
l yyqyP 21 1)(cos
0sin)()(),(),,(0
'
'
'
2
0
'
ddPePeYY m
l
imm
l
imm
l
m
l
62
Defining the Harmonics (m0)
Orthogonality (m=m’ and ll’):
We have to choose the function:
so that:
Since m=m’, this reduces to:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
0sin)()(0
'
dPP m
l
m
l
0sin)()(),(),,(0
'
'
'
2
0
'
ddPePeYY m
l
imm
l
imm
l
m
l
mm
l
m
l yyqyP 21 1)(cos
63
Defining the Harmonics (m0)
Orthogonality (m=m’ and ll’):
We have to choose the function:
Using the change of variable formulation we get:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
1
1
2
'
1
1
1
'
1
0
'
1)()(
)(cos)(cossin)()(
dyyypyp
dyyPyPdPP
mm
l
m
l
m
l
m
l
m
l
m
l
mm
l
m
l yyqyP 21 1)(cos
64
Defining the Harmonics (m0)
Orthogonality (m=m’ and ll’):
We have to choose the function:
Using the change of variable formulation we get:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
1
1
2
'
1
1
1
'
1
0
'
1)()(
)(cos)(cossin)()(
dyyyqyq
dyyPyPdPP
mm
l
m
l
m
l
m
l
m
l
m
l
mm
l
m
l yyqyP 21 1)(cos
65
Defining the Harmonics (m0)
Thus, we require:
1. The polynomials qlm(y) to complete to
homogenous polynomials of degree l-m:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
mm
l
m
l yypyP 21 1)(cos
...)( 2
2
ml
ml
ml
ml
m
l yayayq
66
Defining the Harmonics (m0)
Thus, we require:
1. The polynomials qlm(y) to complete to
homogenous polynomials of degree l-m:
2. And they satisfy the orthogonality condition:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
01)()(
1
1
2
'
dyyyqyqmm
l
m
l
mm
l
m
l yypyP 21 1)(cos
...)( 2
2
ml
ml
ml
ml
m
l yayayq
67
Defining the Harmonics (m0)
This is precisely what we get when we compute
the G.S. orthogonalization of {1,y,y2,…} relative to
the inner-product:
and set:
m
m
lmm
l
y
yPizxY
2
1
1
)(cos,
)()( ypyq m
ml
m
l
mm
l
m
l yypyP 21 1)(cos
1
1
21)()()(),( dyyygyfygyfm
m
68
Defining the Harmonics (m0)
In sum, we get an expression for the spherical
harmonics as:
)(, m
l
imm
l PeY
mm
ml
im
mm
ml
imm
l
pe
peY
sin)(cos
cos1)(cos, 2
mm
l
m
l yypyP 21 1)(cos
69
Defining the Harmonics (m0)
In sum, we get an expression for the spherical
harmonics as:
where is a polynomial of degree l-m.
)(, m
l
imm
l PeY
mm
ml
im
mm
ml
imm
l
pe
peY
sin)(cos
cos1)(cos, 2
mm
l
m
l yypyP 21 1)(cos
)(ypm
ml
70
The Spherical Harmonics
Examples (l=0):
4
1,0
0 Y
71
mm
ml
imm
l peY sin)(cos,
The Spherical Harmonics
Examples (l=1):
i
i
eY
Y
eY
)sin(8
3,
)cos(4
3,
)sin(8
3,
1
1
0
1
1
1
72
mm
ml
imm
l peY sin)(cos,
The Spherical Harmonics
Examples (l=2):
i
i
i
i
eY
eY
Y
eY
eY
222
2
1
2
20
2
1
2
222
2
)(sin32
15,
)cos()sin(8
15,
1)(cos316
5,
)cos()sin(8
15,
)(sin32
15,
73
mm
ml
imm
l peY sin)(cos,