1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review...

32
1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform

Transcript of 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review...

Page 1: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

1

Image Processing

• Linear Spaces

• Change of Basis

• Cosines and Sines

• Complex Numbers

Math Review Towards Fourier Transform

Page 2: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

2

Part I: Vector Spaces and Basis Vectors

Page 3: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

3

Basis Vectors

• A given vector value is represented with respect to a coordinate system.

• The coordinate system is arbitrarily chosen.

• A coordinate system is defined by a set of linearly independent vectors forming the system basis.

• Any vector value is represented as a linear sum of the basis vectors.

v1

v2

a

a= 0.5 *v1+1*v2 (0.5 , 1)v

• v1, v2 are basis vectors• The representation of a with respect to this basis is (0.5,1)

Page 4: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

4

Orthonormal Basis Vectors

• If the basis vectors are mutually orthogonal and are unit vectors, the vectors form an orthonormal basis.

• Example: The standard basis is orthonormal:

V1=(1 0)

V2=(0 1)

a

V1=(1 0 0 0 …)

V2=(0 1 0 0 …)

V3=(0 0 1 0 …)

….

Page 5: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

5

Change of Basis

• Question: Given a vector av, represented in an orthonormal basis {vi} , what is the representation of av in a different orthonormal basis {ui}?

• Answer:

ivu u,aia

v2

v1

a

u2

u1

ii

uv uiaa

ibicbcb,cwherei

T

Page 6: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

6

Change of Basis: Matrix Form

• Defining the new basis as a collection of columns in a matrix form

vT

u aUa

v2

v1

a

u2

u1

uv aUa

nuuuU 21

Page 7: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

7

Signal (image) Transforms

1. Basis Functions.

2. Method for finding the transform coefficients given a signal.

3. Method for finding the signal given the transform coefficients.

Page 8: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

8

The Orthonormal Standard Basis - 1D

0

1

2

3

4

5

6

7

8

9

Wave Number

Standard Basis Functions - 1D

N = 16

Page 9: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

9

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Wave Number

N = 16

The Orthonormal Hadamard Basis – 1D

Page 10: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

10

spatial Coordinate

Grayscale Image

[ 2 1 6 1 ]standard=

2 [ 1 0 0 0 ] + 1 [ 0 1 0 0 ] + 6 [ 0 0 1 0 ] + 1 [ 0 0 0 1 ]

Hadamard Transform:

Standard Basis:

Hadamard Transform

Transform Coordinate

Transformed Image

Standard Basis New Basis

[ 2 1 6 1 ]standard =

= 5 [ 1 1 1 1 ]/2 + -2 [ 1 1 -1 -1 ] /2 +

2 [ -1 1 1 -1 ] /2 + -3 [ -1 1 -1 1 ] /2

[ 5 -2 2 -3 ] Hadamard

Page 11: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

11

X = [ 2 1 6 1 ] standard

Hadamard Basis:

Finding the transform coefficients

T0 = [ 1 1 1 1 ] /2

T1 = [ 1 1 -1 -1 ] /2

T2 = [ -1 1 1 -1 ] /2

T3 = [ -1 1 -1 1 ] /2

Signal:

Hadamard Coefficients:

a0 = <X,T0 > = < [ 2 1 6 1 ] , [ 1 1 1 1 ] > /2 = 5

a1 = <X,T1 > = < [ 2 1 6 1 ] , [ 1 1 -1 -1 ] > /2 = -2

a2 = <X,T2 > = < [ 2 1 6 1 ] , [ -1 1 1 -1 ] > /2 = 2

a3 = <X,T3 > = < [ 2 1 6 1 ] , [ -1 1 -1 1 ] > /2 = -3

[ 2 1 6 1 ] Standard [ 5 -2 2 -3 ] Hadamard Signal:

Page 12: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

12

U CoordinatesV

Coo

rdin

ates

X Coordinate

Y C

oord

inat

e

Grayscale Image

TransformedImage

Transforms: Change of Basis - 2D

The coefficients are arranged in a 2D array.

Page 13: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

13

Hadamard Basis Functions

size = 8x8Black = +1 White = -1

Page 14: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

14

1 0

0 0[ ]2 1

6 1[ ] 0 1

0 0[ ] 0 0

1 0[ ] 0 0

0 1[ ]+ 1+ 6+ 1 = 2

Hadamard Transform:

Standard Basis:

Transforms: Change of Basis - 2D

5 -2

2 -3[ ] Hadamard

1 1

1 1[ ]2 1

6 1[ ] 1 1

-1 -1[ ] -1 1

1 -1[ ] -1 1

-1 1[ ] -3+2 -2= 5/2 /2 /2 /2

Page 15: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

15

X =

New Basis:

Finding the transform coefficients

Signal:

New Coefficients:

a11 = <X,T11 > = sum(sum(X.*T11)) = 5

a12 = <X,T12 > = sum(sum(X.*T12)) = -2

a21 = <X,T21 > = sum(sum(X.*T21)) = 2

a22 = <X,T22 > = sum(sum(X.*T22)) = -3

Signal:

standard

2 1

6 1[ ]

1 1

1 1[ ]/2 1 1

-1 -1[ ]/2

-1 1

1 -1[ ]/2 -1 1

-1 1[ ]/2T21 =

T11 = T12 =

T22 =

X = a11T11 +a12T12 + a21T21 + a22T22

X 5 -2

2 -3 ][new

Page 16: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

16

1 1

1 1[ ] 1 1

-1 -1[ ]-1 1

1 -1[ ] -1 1

-1 1[ ] 5 -2

2 -3 ][

Hadamard Transform:

Standard Basis:

[[

[1 0

0 0[ ] 0 1

0 0 ] 0 0

1 0 ] 0 0

0 1 ] 2 1

6 1[ ]

Hadamard

Hadamard

Standardcoefficients

Basis Elements

Basis Elements

coefficients

/2 /2

/2 /2

Page 17: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

17

Part II: Sines and Cosines

Page 18: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

18

1

1

cos()

sin()

x

2

– The wavelength of sin(x) is 2 .

– The frequency is 1/(2) .

1

Wavelength and Frequency of Sine/Cosin

xsin

Page 19: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

19

x

1

2

x

1

kxsin

x

k/2

1

xsin

xsin 2

2/2

Page 20: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

20

xπω2sin

ω1

– The wavelength of sin(2x) is 1/ .

– The frequency is .

x

1

– Define K=2

Page 21: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

21

x

xA πω2sin

A

– Changing Amplitude:

– Changing Phase:

x

φπω2sin xA

2

Page 22: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

22

Sine vs Cosine

sin(x) = cos(x) with a phase shift of /2.

}

/2

sin(x) + cos(x) = ?

Page 23: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

23

Sine vs Cosine

3 sin(kx)

4 cos(kx)

5 sin(kx + 0.3)

3 sin(kx) + 4 cos(kx) = sin(kx) with amplitude scaled by 5 and phase shift of 0.3

sin(x) + cos(x) = sin(x) scaled by with a phase shift of /4.

2

Page 24: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

24

Combining Sine and Cosine

• If we add a Sine wave to a Cosine wave with the same frequency we get a scaled and shifted (Co-) Sine wave with the same frequency:

• What is the result if a=0?• What is the result if b=0?

kxRkxbkxa sin cossin

a

bbaR 122 tanandwhere

(prove it!)

tan()

Page 25: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

25

Part III: Complex Numbers

Page 26: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

26

Complex Numbers

The Complex Plane

Real

Imaginary

(a,b)

a

b

• Two kind of representations for a point (a,b) in the complex plane

– The Cartesian representation:

12 iwhereibaZ

– The Polar representation:θReiZ

R

• Conversions:

– Polar to Cartesian:

– Cartesian to Polar

θsinθcosRe θ iRRi abiebaiba /tan22 1

(Complex exponential)

Page 27: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

27

• Conjugate of Z is Z*:

– Cartesian rep.

– Polar rep.

ibaiba

θθ ReRe ii

Reala

b

-

-b

θReiiba

θRe iiba

R

R

Imaginary

Page 28: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

28

Algebraic operations:

• addition/subtraction:

• multiplication:

• inner Product:

• norm:

)db(i)ca()idc()iba(

adbcibdacidciba

βαβα iii ABeBeAe

222baibaibaiba

2θθθθ2θ ReReReReRe Riiiii

))(()()()(),( * idcibaidcibaidciba

Page 29: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

29

Number Multiplication

Re

Im

A

iii ABeBeAe

B

A*B

Page 30: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

30

• The (Co-)Sinusoid as complex exponential:

Or

2

ixix eexcos

iee

xsinixix

2

The (Co-) Sinusoid

ixex Realcos

ixex Imagsin

sinicosei

• What about generalization?

S sin(kx) + C cos(kx) = ?

Page 31: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

31

We saw that :

S sin(kx) + C cos(kx) = R sin(kx + )

Using Complex exponentials:

Scaling and phase shifting can be represented as a multiplication with

and also

)(Imagsin ikxi eeRkxR

iZ Re

)( *2

1 ikxikxi

eZeZ

)(sin2

1 ikxiikxii

eeReeRkxR

)(Imag ikxeZ

122

SC

tanandRwhere CS

Page 32: 1 Image Processing Linear Spaces Change of Basis Cosines and Sines Complex Numbers Math Review Towards Fourier Transform.

32

T H E E N D