Ch15 transforms

Post on 14-Nov-2014

579 views 0 download

description

 

Transcript of Ch15 transforms

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

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

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

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.

Fourier series

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

The Fourier Transform

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

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

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

• 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

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!

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

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

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

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

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

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

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

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

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

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

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

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

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

Effect of changing sampling duration

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

can measure

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

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

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

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

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

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

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

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:

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

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

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.

DFT vs FFT

DFT vs FFT

DFT vs FFT

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”.

Periodicity and Windowing

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

Spatial discontinuities

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

DCT in Matrix Form

G CgCc

where the kernel elements are

C mi m

Ni m, cos 2 1

2

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

DST in Matrix Form

G TgTc

where the kernel elements are

TN

i k

Ni k, sin2

1

1 1

1

DCT Basis Functions*

(Log Magnitude) DCT Example*

Hartley Transform

• Alternative to Fourier

• Produces N Real Numbers

• Use Cosine Shifted 45o to the Right

cas

cos sin

cos24

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

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

Hartley in Matrix Form

G TgTHartley

i kTN

ik

N

where the kernel elements are

cas,

1 2

What is an even function?

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

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( ) ( )* ( )

Rectangular Wave Transforms

• Binary Valued {1, -1}

• Fast to Compute

• Examples– Hadamard– Walsh– Slant– Haar

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

Walsh Transform, N=4

*Gonzalez, Wintz

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

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

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

Ordered Hadamard Transform*

*Gonzalez, Wintz

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.

Haar Transform*, H4

H4

1 1 1 1

1 1 1 1

2 2 0 0

0 0 2 2

*Castleman

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

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

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

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

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