You are on page 1of 9

Image Synthesis Convolution

Exercise class 5b

Sampling Theory

Convolution

1
Spring 2009

Convolution
Definition

( f * g )( x) = f (t ) g ( x t )dt

Intuition
f(t) g(t)

g(-t) g(x-t)

0 x
Spring 2009
Image Synthesis, CGGC, Technion 2

M. Ben-Chen
Computer Science Dept. Technion Page 1
Image Synthesis Convolution
Exercise class 5b

Commutativity of Convolution

( f * g )( x) = ( g * f )( x)

Intuition
f(t) g(t)

f*g g*f

Spring 2009
Image Synthesis, CGGC, Technion 3

Commutativity of Convolution - Proof



( f * g )( x) = f (t ) g ( x t )dt

After a variable change such that


u = x t => t = x u , du = -dt

f ( x u ) g (u ) d u =

g (u ) f ( x u ) du =

( g * f )( x )
Spring 2009
Image Synthesis, CGGC, Technion 4

M. Ben-Chen
Computer Science Dept. Technion Page 2
Image Synthesis Convolution
Exercise class 5b

Example 1

W - W2 t W2
f (t ) = 2
W/2

0 otherwise -W/2 W/2

t 0 t W2
g (t ) = W/2
0 otherwise


( f * g )( x ) =

f ( t ) g ( x t ) dt

Spring 2009
Image Synthesis, CGGC, Technion 5

Example 1 (cont.)
W/2

x < W -W/2 W/2


2

W/2

W x < 0 -W/2
x
W/2
2

W/2

0 x<W -W/2
x
W/2
2

W/2
W x <W x
-W/2 W/2
2

Spring 2009
Image Synthesis, CGGC, Technion 6

M. Ben-Chen
Computer Science Dept. Technion Page 3
Image Synthesis Convolution
Exercise class 5b

Example 1 (cont.)

W
0 x<
2

W 2
x+
W 2
-
W
x<0
2 2 2
2
W
W

2 W
( f * g )( x) = 0 x<
2 2 2

W 2 2

W
x -W/2 W/2 W
W
2 2 W
x <W
2 2 2 2




0 Wx

Spring 2009
Image Synthesis, CGGC, Technion 7

Example 2 Delta Function


Convolution with Delta = Identity

f ( x) * ( x) =

f (t ) ( x t )dt = f ( x)

f f

Convolution with shifted Delta = shift



f ( x) * ( x x0 ) =

f (t ) ( x x0 t )dt = f ( x x0 )

f ( x x0 ) f ( x x0 )

Spring 2009
Image Synthesis, CGGC, Technion 8

M. Ben-Chen
Computer Science Dept. Technion Page 4
Image Synthesis Convolution
Exercise class 5b

Example 3 - Comb

The comb function: Cl ( x) = (x
j =
jl )

Cl
f

f * Cl

Spring 2009
Image Synthesis, CGGC, Technion 9

Example 3 Comb (cont)



The comb function: Cl ( x) = (x
j =
jl )

f ( x) * Cl ( x) =

f ( x) * (x
j =
jl ) =


j =
f ( x ) * ( x jl ) =


j =
f ( x jl )

Spring 2009
Image Synthesis, CGGC, Technion 10

M. Ben-Chen
Computer Science Dept. Technion Page 5
Image Synthesis Convolution
Exercise class 5b

Example 4
The first order B-Spline basis function:

1 + t 1 t < 0

B1 = 1 t 0 t <1
0 | t |> 1 -1 0 1

A sampled function
f (t ) t = ti = i 1
f ( t ) =
0 otherwise ti-1 ti ti+1 ti+2

Spring 2009
Image Synthesis, CGGC, Technion 11

Example 4 (cont.)
At the sampled points ( f * B1 )( xi ) = f ( xi )

1 1

xi-1 xi xi+1 xi+2 xi-1 xi xi+1 xi+2

Between sampled points ( f * B1 )( x [ xi , xi +1 )) = (1 t ) f ( xi ) + t f ( xi +1 )

x x
xi-1 xi xi+1 xi+2 xi-1 xi xi+1 xi+2

Spring 2009
Image Synthesis, CGGC, Technion 12

M. Ben-Chen
Computer Science Dept. Technion Page 6
Image Synthesis Convolution
Exercise class 5b

Example 4 (cont.)
For x [xi, xi+1):

( f * B1 )( x ) = 1

xi-1 xi
x
xi+1 xi+2



f ( t ) B1 ( x t ) dt =

f ( xi ) B1 ( xi x ) + f ( x i +1 ) B1 ( x i +1 x ) =
((1 + xi x ) f ( x i ) + ((1 xi +1 + x ) f ( xi +1 ) =
(1 ( x x i )) f ( xi ) + (1 xi 1 + x ) f ( xi +1 ) =
(1 t ) f ( x ) + t f ( x ),
i i +1 t = ( x x ) [0, 1) i

Spring 2009
Image Synthesis, CGGC, Technion 13

Example 5
Let f be a discrete function obtained by sampling a
continuous function f.
f (t ) t = t i = il , i Z , l > 0
f ( t ) =
0 otherwise

We would like to compute the convolution of sinc(t) with


f ( t )

Spring 2009
Image Synthesis, CGGC, Technion 14

M. Ben-Chen
Computer Science Dept. Technion Page 7
Image Synthesis Convolution
Exercise class 5b

Example 5 (cont.)

( f * sinc)( x ) = f (t ) sinc( x t ) dt =
i =
f ( t i ) sinc( x t i )

Computing the convolution value


for x = 0.3:

The sinc is mirrored along the X axis


and shifted to the 0.3 point.

This mirrored and shifted sinc is used


as a weight function for f

Spring 2009
Image Synthesis, CGGC, Technion 15

Example 5 (cont.)
Sinc is infinite f ( t i )
Truncate to get a finite number of points
For 9 points:
f(0.3) = 0.2388
Approximated = 0.2546

i xi f(xi) sinc(0.3-xi) f(xi)sinc(0.3-xi)


-3 -0.6 -0.7263 -0.0669 0.0532
-2 -0.4 -0.8106 0.0532 -0.0431
-1 -0.2 -0.1366 0 0
f ( t i )sinc(0.3 t i )
0 0 0.5 -0.1241 -0.062
1 0.2 0.4395 0.6023 0.2647
2 0.4 0.0654 0.6023 0.0394
3 0.6 0.0586 -0.1241 -0.0073
4 0.8 0.3124 0 0
5 1 0.2702 0.0532 0.0144

= 0.2546

Spring 2009
Image Synthesis, CGGC, Technion 16

M. Ben-Chen
Computer Science Dept. Technion Page 8
Image Synthesis Convolution
Exercise class 5b

Example 5 (cont.)
The convolution is defined for any x
The resulting function is defined over the continuous domain
In this example

f ( x i ) * sinc= f ( x )
To be continued

* =

Spring 2009
Image Synthesis, CGGC, Technion 17

M. Ben-Chen
Computer Science Dept. Technion Page 9