67
Transforms

Ch15 transforms

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Ch15 transforms

Transforms

Page 2: Ch15 transforms

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-8

-6

-4

-2

0

2

4

6

8

5*sin (24t)

Amplitude = 5

Frequency = 4 Hz

seconds

A sine wave

Page 3: Ch15 transforms

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-8

-6

-4

-2

0

2

4

6

8

5*sin(24t)

Amplitude = 5

Frequency = 4 Hz

Sampling rate = 256 samples/second

seconds

Sampling duration =1 second

A sine wave signal

Page 4: Ch15 transforms

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1.5

-1

-0.5

0

0.5

1

1.5

2sin(28t), SR = 8.5 Hz

An undersampled signal

Page 5: Ch15 transforms

The Nyquist Frequency

• The Nyquist frequency is equal to one-half of the sampling frequency.

• The Nyquist frequency is the highest frequency that can be measured in a signal.

Page 6: Ch15 transforms

Fourier series

• Periodic functions and signals may be expanded into a series of sine and cosine functions

Page 7: Ch15 transforms

The Fourier Transform

• A transform takes one function (or signal) and turns it into another function (or signal)

Page 8: Ch15 transforms

The Fourier Transform

• A transform takes one function (or signal) and turns it into another function (or signal)

• Continuous Fourier Transform:

close your eyes if you don’t like integrals

Page 9: Ch15 transforms

The Fourier Transform

• A transform takes one function (or signal) and turns it into another function (or signal)

• Continuous Fourier Transform:

dfefHth

dtethfH

ift

ift

2

2

Page 10: Ch15 transforms

• A transform takes one function (or signal) and turns it into another function (or signal)

• The Discrete Fourier Transform:

The Fourier Transform

1

0

2

1

0

2

1 N

n

Niknnk

N

k

Niknkn

eHN

h

ehH

Page 11: Ch15 transforms

Fast Fourier Transform

• The Fast Fourier Transform (FFT) is a very efficient algorithm for performing a discrete Fourier transform

• FFT principle first used by Gauss in 18??• FFT algorithm published by Cooley & Tukey in

1965• In 1969, the 2048 point analysis of a seismic trace

took 13 ½ hours. Using the FFT, the same task on the same machine took 2.4 seconds!

Page 12: Ch15 transforms

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 20 40 60 80 100 1200

50

100

150

200

250

300

Famous Fourier Transforms

Sine wave

Delta function

Page 13: Ch15 transforms

Famous Fourier Transforms

0 5 10 15 20 25 30 35 40 45 500

0.1

0.2

0.3

0.4

0.5

0 50 100 150 200 2500

1

2

3

4

5

6

Gaussian

Gaussian

Page 14: Ch15 transforms

Famous Fourier Transforms

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-0.5

0

0.5

1

1.5

-100 -50 0 50 1000

1

2

3

4

5

6

Sinc function

Square wave

Page 15: Ch15 transforms

Famous Fourier Transforms

Sinc function

Square wave

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-0.5

0

0.5

1

1.5

-100 -50 0 50 1000

1

2

3

4

5

6

Page 16: Ch15 transforms

Famous Fourier Transforms

Exponential

Lorentzian

0 50 100 150 200 2500

5

10

15

20

25

30

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

Page 17: Ch15 transforms

FFT of FID

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 20 40 60 80 100 1200

10

20

30

40

50

60

70

f = 8 Hz SR = 256 HzT2 = 0.5 s

2exp2sin

Tt

fttF

Page 18: Ch15 transforms

FFT of FID

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 20 40 60 80 100 1200

2

4

6

8

10

12

14

f = 8 HzSR = 256 HzT2 = 0.1 s

Page 19: Ch15 transforms

FFT of FID

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 20 40 60 80 100 1200

50

100

150

200

f = 8 Hz SR = 256 HzT2 = 2 s

Page 20: Ch15 transforms

Effect of changing sample rate

0 10 20 30 40 50 600

10

20

30

40

50

60

70

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 10 20 30 40 50 600

5

10

15

20

25

30

35

f = 8 Hz T2 = 0.5 s

Page 21: Ch15 transforms

Effect of changing sample rate

0 10 20 30 40 50 600

10

20

30

40

50

60

70

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 10 20 30 40 50 600

5

10

15

20

25

30

35

SR = 256 HzSR = 128 Hz

f = 8 HzT2 = 0.5 s

Page 22: Ch15 transforms

Effect of changing sample rate

• Lowering the sample rate:– Reduces the Nyquist frequency, which– Reduces the maximum measurable frequency– Does not affect the frequency resolution

Page 23: Ch15 transforms

Effect of changing sampling duration

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 2 4 6 8 10 12 14 16 18 200

10

20

30

40

50

60

70

f = 8 Hz T2 = .5 s

Page 24: Ch15 transforms

Effect of changing sampling duration

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 2 4 6 8 10 12 14 16 18 200

10

20

30

40

50

60

70

ST = 2.0 sST = 1.0 s

f = 8 HzT2 = .5 s

Page 25: Ch15 transforms

Effect of changing sampling duration

• Reducing the sampling duration:– Lowers the frequency resolution– Does not affect the range of frequencies you

can measure

Page 26: Ch15 transforms

Effect of changing sampling duration

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 2 4 6 8 10 12 14 16 18 200

50

100

150

200

f = 8 Hz T2 = 2.0 s

Page 27: Ch15 transforms

Effect of changing sampling duration

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-2

-1

0

1

2

0 2 4 6 8 10 12 14 16 18 200

2

4

6

8

10

12

14

ST = 2.0 sST = 1.0 s

f = 8 Hz T2 = 0.1 s

Page 28: Ch15 transforms

Measuring multiple frequencies

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-3

-2

-1

0

1

2

3

0 20 40 60 80 100 1200

20

40

60

80

100

120

f1 = 80 Hz, T21 = 1 s

f2 = 90 Hz, T22 = .5 s

f3 = 100 Hz, T2

3 = 0.25 s

SR = 256 Hz

Page 29: Ch15 transforms

Measuring multiple frequencies

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-3

-2

-1

0

1

2

3

0 20 40 60 80 100 1200

20

40

60

80

100

120

f1 = 80 Hz, T21 = 1 s

f2 = 90 Hz, T22 = .5 s

f3 = 200 Hz, T2

3 = 0.25 s

SR = 256 Hz

Page 30: Ch15 transforms
Page 31: Ch15 transforms

L: period; u and v are the number of cycles fitting into one horizontal and

vertical period, respectively of f(x,y).

Page 32: Ch15 transforms

Discrete Fourier Transform

1 12 ( ) /

0 0

1( , ) ( , )

w hj ux vy wh

x y

F u v f x y ewh

1 1

0 0

1 2 ( ) 2 ( )( , ) ( , ) cos sin

w h

x y

ux vy ux vyF u v f x y j

wh wh wh

Page 33: Ch15 transforms

Discrete Fourier Transform (DFT).

• When applying the procedure to images, we must deal explicitly with the fact that an image is:– Two-dimensional– Sampled– Of finite extent

• These consideration give rise to the The DFT of an NxN image can be written:

Page 34: Ch15 transforms

Discrete Fourier Transform• For any particular spatial frequency specified by u and v, evaluating

equation 8.5 tell us how much of that particular frequency is present in the image.

• There also exist an inverse Fourier Transform that convert a set of Fourier coefficients into an image.

1

0

/)(21

0

),(1

),(N

x

NvyuxjN

y

evuFN

yxf

Page 35: Ch15 transforms

PSD• The magnitudes correspond to the amplitudes of the basic images

in our Fourier representation.• The array of magnitudes is termed the amplitude spectrum (or

sometime ‘spectrum’).• The array of phases is termed the phase spectrum.• The power spectrum is simply the square of its amplitude

spectrum:

),(),(),(),( 222vuIvuRvuFvuP

Page 36: Ch15 transforms

FFT

• The Fast Fourier Transform is one of the most important algorithms ever developed

– Developed by Cooley and Tukey in mid 60s.

– Is a recursive procedure that uses some cool math tricks to combine sub-problem results into the overall solution.

Page 37: Ch15 transforms

DFT vs FFT

Page 38: Ch15 transforms

DFT vs FFT

Page 39: Ch15 transforms

DFT vs FFT

Page 40: Ch15 transforms

Periodicity assumption• The DFT assumes that an image is part of an infinitely repeated set of

“tiles” in every direction. This is the same effect as “circular indexing”.

Page 41: Ch15 transforms

Periodicity and Windowing

• Since “tiling” an image causes “fake” discontinuities, the spectrum includes “fake” high-frequency components

Spatial discontinuities

Page 42: Ch15 transforms

Discrete Cosine Transform

Real-valued

G m n m n g i ki m

N

k n

N

g i k m n G m ni m

N

k n

N

Nm

Nm N

ck

N

i

N

c cn

N

m

N

, ( ) ( ) , cos cos

, ( ) ( ) , cos cos

( ) ( )

2 1

2

2 1

2

2 1

2

2 1

2

01 2

1

0

1

0

1

0

1

0

1

with an inverse

where

and for

Page 43: Ch15 transforms

DCT in Matrix Form

G CgCc

where the kernel elements are

C mi m

Ni m, cos 2 1

2

Page 44: Ch15 transforms

Discrete Sine Transform

Most Convenient when N=2 p - 1

G m nN

g i ki m

N

k n

N

g i kN

G m ni m

N

k n

N

k

N

i

N

sn

N

m

N

sin

sin

, , sin sin

, , sin sin

2

1

1 1

1

1 1

1

2

1

1 1

1

1 1

1

0

1

0

1

0

1

0

1

with an inverse

Page 45: Ch15 transforms

DST in Matrix Form

G TgTc

where the kernel elements are

TN

i k

Ni k, sin2

1

1 1

1

Page 46: Ch15 transforms

DCT Basis Functions*

Page 47: Ch15 transforms

(Log Magnitude) DCT Example*

Page 48: Ch15 transforms

Hartley Transform

• Alternative to Fourier

• Produces N Real Numbers

• Use Cosine Shifted 45o to the Right

cas

cos sin

cos24

Page 49: Ch15 transforms

Square Hartley Transform

1 1

0 0

1 1

0 0

21, ,

*

with an inverse

2, ,

N N

Hartley Hi k

N N

Hartley Hm n

im knG m n g i k cas

N N N

im kng i k G m n cas

N

Page 50: Ch15 transforms

Rectangular Hartley Transform

1 1

0 0

1 1

0 0

1 2 2, ,

0.. , 0..

with an inverse

2 2, ,

h w

Hartley Hy x

h w

Hartley Hy x

mx nyG m n g x y cas

wh w h

m h n w

mx nyg m n G x y cas

w h

Page 51: Ch15 transforms

Hartley in Matrix Form

G TgTHartley

i kTN

ik

N

where the kernel elements are

cas,

1 2

Page 52: Ch15 transforms

What is an even function?

• the function f is even if the following equation holds for all x in the domain of f:

Page 53: Ch15 transforms

Hartley Convolution Theorem

• Computational Alternative to Fourier Transform

• If One Function is Even, Convolution in one Domain is Multiplication in Hartley Domain

g x f x h x G F H F Heven odd( ) ( )* ( )

Page 54: Ch15 transforms

Rectangular Wave Transforms

• Binary Valued {1, -1}

• Fast to Compute

• Examples– Hadamard– Walsh– Slant– Haar

Page 55: Ch15 transforms

Hadamard Transform

• Consists of elements of +/- 1

• A Normalized N x N Hadamard matrix satisfies the relation H Ht = I

H

HH H

H H

2

2

1

2

1 1

1 1

1

2

Walsh Tx can be constructed as

NN N

N N

Page 56: Ch15 transforms

Walsh Transform, N=4

*Gonzalez, Wintz

Page 57: Ch15 transforms

Non-ordered Hadamard Transform H8

H8

1 1

1 1

1 1

1 11 1

1 1

1 1

1 1

1 1

1 1

1 1

1 11 1

1 1

1 1

1 11 1

1 1

1 1

1 11 1

1 1

1 1

1 1

1 1

1 1

1 1

1 11 1

1 1

1 1

1 1

Page 58: Ch15 transforms

Sequency

• In a Hadamard Transform, the Number of Sign Changes in a Row Divided by Two

• It is Possible to Construct an H matrix with Increasing Sequency per row

Page 59: Ch15 transforms

Ordered Hadamard Transform

F u vN

F j k

q j k u v g u j g v k

u u

u u u

u u u

u u u

q j k u v

k

N

j

N

i i i ii

N

n

n n

n n

, ,

, , ,

( )

( )

( )

( )

, , ,

11

0

1

0

1

0

1

1

1 2

2 3

1 0

where

and

g

g

g

g

0

1

2

n-1

Page 60: Ch15 transforms

Ordered Hadamard Transform*

*Gonzalez, Wintz

Page 61: Ch15 transforms

Haar Transform

• Derived from Haar Matrix• Sampling Process in which Subsequent

Rows Sample the Input Data with Increasing Resolution

• Different Types of Differential Energy Concentrated in Different Regions– Power taken two at a time– Power taken a power of two at a time, etc.

Page 62: Ch15 transforms

Haar Transform*, H4

H4

1 1 1 1

1 1 1 1

2 2 0 0

0 0 2 2

*Castleman

Page 63: Ch15 transforms

Karhunen-Loeve Transform

• Variously called the K-L, Hotelling, or Eignevector

• Continuous Form Developed by K-L• Discrete Version Credited to Hotelling• Transforms a Signal into a Set of Uncorrelated

Representational Coefficients• Keep Largest Coefficients for Image Compression

Page 64: Ch15 transforms

Discrete K-L

F u v F j k A j k u v

A j k u v K j k j k A j k u v

K j k j k

K

k

N

j

N

Fk

N

j

N

F

F

( , ) , , ; ,

, ; , , ; , , ; ,

, ; ,

,

0

1

0

1

0

1

0

1

where the kernel satisfies

u, v

where

is the image covariance function

u, v is a constant for a fixed u, v the eigenvalues of

Page 65: Ch15 transforms

Singular Value Decomposition

An x matrix A can be expressed as

where

Columns of are Eigenvectors of

Columns of are Eigenvectors of

is the x diagonal matrix of singular values

t

t

N N

N N

t

t

A U V

U AA

V A A

L

U AV

Page 66: Ch15 transforms

Singular Value Decomposition

• If A is symmetric, then U=V

• Kernel Depends on Image Being Transformed

• Need to Compute AAt and AtA and Find the Eigenvalues

• Small Values can be Ignored to Yield Compression

Page 67: Ch15 transforms

Transform Domain Filtering

• Similar to Fourier Domain Filtering

• Applicable to Images in which Noise is More Easily Represented in Domain other than Fourier– Vertical and horizontal line detection: Haar

transform produces non-zero entries in first row and/or first column