Representing Images and Sounds Class 4. 3 Sep 2009 Instructor: - - PowerPoint PPT Presentation

representing images and sounds
SMART_READER_LITE
LIVE PREVIEW

Representing Images and Sounds Class 4. 3 Sep 2009 Instructor: - - PowerPoint PPT Presentation

11-755 Machine Learning for Signal Processing Representing Images and Sounds Class 4. 3 Sep 2009 Instructor: Bhiksha Raj Representing an Elephant It was six men of Indostan, The fifth, who chanced to touch the ear, n n To learning much


slide-1
SLIDE 1

11-755 Machine Learning for Signal Processing

Representing Images and Sounds

Class 4. 3 Sep 2009 Instructor: Bhiksha Raj

slide-2
SLIDE 2

11-755 MLSP: Bhiksha Raj

Representing an Elephant

n

It was six men of Indostan, To learning much inclined, Who went to see the elephant, (Though all of them were blind), That each by observation Might satisfy his mind.

n

The first approached the elephant, And happening to fall Against his broad and sturdy side, At once began to bawl: "God bless me! But the elephant Is very like a wall!“

n

The second, feeling of the tusk, Cried: "Ho! What have we here, So very round and smooth and sharp? To me 'tis very clear, This wonder of an elephant Is very like a spear!“

n

The third approached the animal, And happening to take The squirming trunk within his hands, Thus boldly up and spake: "I see," quoth he, "the elephant Is very like a snake!“

n

The fourth reached out an eager hand, And felt about the knee. "What most this wondrous beast is like Is might plain," quoth he; "Tis clear enough the elephant Is very like a tree."

n

The fifth, who chanced to touch the ear, Said: "E'en the blindest man Can tell what this resembles most: Deny the fact who can, This marvel of an elephant Is very like a fan.“

n

The sixth no sooner had begun About the beast to grope, Than seizing on the swinging tail That fell within his scope, "I see," quoth he, "the elephant Is very like a rope.“

n

And so these men of Indostan Disputed loud and long, Each in his own opinion Exceeding stiff and strong. Though each was partly right, All were in the wrong.

slide-3
SLIDE 3

11-755 MLSP: Bhiksha Raj

Representation

n Describe these

images

q Such that a listener

can visualize what you are describing

n More images

slide-4
SLIDE 4

11-755 MLSP: Bhiksha Raj

Still more images

How do you describe them?

slide-5
SLIDE 5

11-755 MLSP: Bhiksha Raj

Sounds

n

Sounds are just sequences of numbers

n

When plotted, they just look like blobs

q

Which leads to the natural “sounds are blobs”

n

Or more precisely, “sounds are sequences of numbers that, when plotted, look like blobs”

q

Which wont get us anywhere

slide-6
SLIDE 6

11-755 MLSP: Bhiksha Raj

Representation

n Representation is description n But in compact form n Must describe the salient characteristics of the data

q

E.g. a pixel-wise description of the two images here will be completely different

n Must allow identification, comparison, storage..

slide-7
SLIDE 7

11-755 MLSP: Bhiksha Raj

Representing images

n The most common element in the image:

background

q

Or rather large regions of relatively featureless shading

q

Uniform sequences of numbers

slide-8
SLIDE 8

11-755 MLSP: Bhiksha Raj

Image =

  • N

pixel pixel pixel . 2 1

Representing images using a “plain” image

n

Most of the figure is a more-or-less uniform shade

q

Dumb approximation – a image is a block of uniform shade

n

Will be mostly right!

q

How much of the figure is uniform?

n

How? Projection

q

Represent the images as vectors and compute the projection of the image on the “basis”

  • 1

. 1 1

B =

age B B B B BW PROJECTION age B pinv W age BW

T T

Im . ) ( Im ) ( Im

1

  • =

= = »

slide-9
SLIDE 9

11-755 MLSP: Bhiksha Raj

Adding more bases

n

Lets improve the approximation

n

Images have some fast varying regions

q

Dramatic changes

q

Add a second picture that has very fast changes

n

A checkerboard where every other pixel is black and the rest are white

  • =

1 1 1 1 1 1 1 1 1 1 B ] [ Im

2 1 2 1 2 2 1 1

B B B w w W B w B w age =

  • =

+ »

B1 B2 B2 B1

age B B B B BW PROJECTION age B pinv W age BW

T T

Im . ) ( Im ) ( Im

1

  • =

= = »

slide-10
SLIDE 10

11-755 MLSP: Bhiksha Raj

Adding still more bases

n Regions that change with different speeds

age B B B B BW PROJECTION age B pinv W age BW

T T

Im . ) ( Im ) ( Im

1

  • =

= = » ] [ . . ... Im

3 2 1 3 2 1 3 3 2 2 1 1

B B B B w w w W B w B w B w age =

  • =

+ + + »

B1 B2 B3 B4 B5 B6 Getting closer at 625 bases!

slide-11
SLIDE 11

11-755 MLSP: Bhiksha Raj

Representation using checkerboards

n

A “standard” representation

q

Checker boards are the same regardless of what picture you’re trying to describe

n

As opposed to using “nose shape” to describe faces and “leaf colour” to describe trees.

n

Any image can be specified as (for example) 0.8*checkerboard(0) + 0.2*checkerboard(1) + 0.3*checkerboard(2) ..

n

The definition is sufficient to reconstruct the image to some degree

q

Not perfectly though

slide-12
SLIDE 12

11-755 MLSP: Bhiksha Raj

What about sounds?

n Square wave equivalents of checker boards

slide-13
SLIDE 13

11-755 MLSP: Bhiksha Raj

Projecting sounds

Signal B B B B BW PROJECTION Signal B pinv W Signal BW

T

. ) ( ) (

1

  • =

= = » ] [

3 2 1 3 2 1 3 3 2 2 1 1

B B B B w w w W B w B w B w Signal =

  • =

+ + »

  • B1

B2 B3

  • 3

2 1

w w w

=

slide-14
SLIDE 14

11-755 MLSP: Bhiksha Raj

Why checkerboards are great bases

n

We cannot explain one checkerboard in terms of another

q

The two are orthogonal to one another!

n

This means that we can find out the contributions of individual bases separately

q

Joint decompostion with multiple bases with give us the same result as separate decomposition with each of them

q

This never holds true if one basis can explain another

  • =

1 1 1 1 1 1 1 1 1 1 B

B1 B2

  • =
  • =

=

2 1 2 1

Im ) ( Im ) ( Im ) ( Im ) ( w w age B Pinv age B Pinv age B Pinv age B Pinv W ] [ Im

2 1 2 1 2 2 1 1

B B B w w W B w B w age =

  • =

+ »

slide-15
SLIDE 15

11-755 MLSP: Bhiksha Raj

Checker boards are not good bases

n Sharp edges

q Can never be used to explain rounded curves

slide-16
SLIDE 16

11-755 MLSP: Bhiksha Raj

Sinusoids ARE good bases

n They are orthogonal n They can represent rounded shapes nicely

q

Unfortunately, they cannot represent sharp corners

slide-17
SLIDE 17

11-755 MLSP: Bhiksha Raj

What are the frequencies of the sinusoids

n Follow the same format as

the checkerboard:

q

DC

q

The entire length of the signal is one period

q

The entire length of the signal is two periods.

n And so on.. n The k-th sinusoid:

q

F(n) = sin(2pkn/N)

n

N is the length of the signal

n

k is the number of periods in N samples

slide-18
SLIDE 18

11-755 MLSP: Bhiksha Raj

How many frequencies in all?

n

A max of L/2 periods are possible

n

If we try to go to (L/2 + X) periods, it ends up being identical to having (L/2 – X) periods

q

With sign inversion

n

Example for L = 20

q

Red curve = sine with 9 cycles (in a 20 point sequence)

n

Y(n) = sin(2p9n/20)

q

Green curve = sine with 11 cycles in 20 points

n

Y(n) = -sin(2p11n/20)

q

The blue lines show the actual samples obtained

n

These are the only numbers stored on the computer

n

This set is the same for both sinusoids

slide-19
SLIDE 19

11-755 MLSP: Bhiksha Raj

How to compose the signal from sinusoids

n

The sines form the vectors of the projection matrix

q

Pinv() will do the trick as usual

Signal B B B B BW PROJECTION Signal B pinv W Signal BW

T

. ) ( ) (

1

  • =

= = » ] [

3 2 1 3 2 1 3 3 2 2 1 1

B B B B w w w W B w B w B w Signal =

  • =

+ + »

  • B1

B2 B3

  • 3

2 1

w w w

=

slide-20
SLIDE 20

11-755 MLSP: Bhiksha Raj

How to compose the signal from sinusoids

n

The sines form the vectors of the projection matrix

q

Pinv() will do the trick as usual

Signal B B B B BW PROJECTION Signal B pinv W Signal BW

T

. ) ( ) (

1

  • =

= = »

  • =

=

  • =

+ + » ] 1 [ . ] 1 [ ] [ ] [

3 2 1 3 2 1 3 3 2 2 1 1

L s s s Signal B B B B w w w W B w B w B w Signal

  • =
  • ]

1 [ . . ] 1 [ ] [ . . /L) ) 1 ).( 2 / ( . sin(2 . . /L) ) 1 .( 1 . sin(2 /L) ) 1 .( . sin(2 . . . . . . . . . . /L) 1 ). 2 / ( . sin(2 . . /L) 1 . 1 . sin(2 /L) 1 . . sin(2 /L) ). 2 / ( . sin(2 . . /L) . 1 . sin(2 /L) . . sin(2

2 / 2 1

L s s s w w w L L L L L L

L

p p p p p p p p p

L/2 columns only

slide-21
SLIDE 21

11-755 MLSP: Bhiksha Raj

Interpretation..

n Each sinusoid’s amplitude is adjusted until it gives

us the least squared error

q

The amplitude is the weight of the sinusoid

n This can be done independently for each sinusoid

slide-22
SLIDE 22

11-755 MLSP: Bhiksha Raj

Interpretation..

n Each sinusoid’s amplitude is adjusted until it gives

us the least squared error

q

The amplitude is the weight of the sinusoid

n This can be done independently for each sinusoid

slide-23
SLIDE 23

11-755 MLSP: Bhiksha Raj

Interpretation..

n Each sinusoid’s amplitude is adjusted until it gives

us the least squared error

q

The amplitude is the weight of the sinusoid

n This can be done independently for each sinusoid

slide-24
SLIDE 24

11-755 MLSP: Bhiksha Raj

Interpretation..

n Each sinusoid’s amplitude is adjusted until it gives

us the least squared error

q

The amplitude is the weight of the sinusoid

n This can be done independently for each sinusoid

slide-25
SLIDE 25

11-755 MLSP: Bhiksha Raj

Sines by themselves are not enough

n Every sine starts at zero

q

Can never represent a signal that is non-zero in the first sample!

n Every cosine starts at 1

q

If the first sample is zero, the signal cannot be represented!

slide-26
SLIDE 26

11-755 MLSP: Bhiksha Raj

The need for phase

n Allow the sinusoids to move! n How much do the sines shift?

.... ) / 2 sin( ) / 2 sin( ) / 2 sin(

3 3 2 2 1 1

+ + + + + + = f p f p f p N kn w N kn w N kn w signal

slide-27
SLIDE 27

11-755 MLSP: Bhiksha Raj

Determining phase

n Least squares fitting: move the sinusoid left / right,

and at each shift, try all amplitudes

q

Find the combination of amplitude and phase that results in the lowest squared error

n We can still do this separately for each sinusoid

q

The sinusoids are still orthogonal to one another

slide-28
SLIDE 28

11-755 MLSP: Bhiksha Raj

Determining phase

n Least squares fitting: move the sinusoid left / right,

and at each shift, try all amplitudes

q

Find the combination of amplitude and phase that results in the lowest squared error

n We can still do this separately for each sinusoid

q

The sinusoids are still orthogonal to one another

slide-29
SLIDE 29

11-755 MLSP: Bhiksha Raj

Determining phase

n Least squares fitting: move the sinusoid left / right,

and at each shift, try all amplitudes

q

Find the combination of amplitude and phase that results in the lowest squared error

n We can still do this separately for each sinusoid

q

The sinusoids are still orthogonal to one another

slide-30
SLIDE 30

11-755 MLSP: Bhiksha Raj

Determining phase

n Least squares fitting: move the sinusoid left / right,

and at each shift, try all amplitudes

q

Find the combination of amplitude and phase that results in the lowest squared error

n We can still do this separately for each sinusoid

q

The sinusoids are still orthogonal to one another

slide-31
SLIDE 31

11-755 MLSP: Bhiksha Raj

The problem w ith phase

n

This can no longer be expressed as a simple linear algebraic equation

q

The phase is integral to the bases

n

I.e. there’s a component of the basis itself that must be estimated!

n

Linear algebraic notation can only be used if the bases are fully known

q

We can only (pseudo) invert a known matrix

  • =
  • +
  • +
  • +
  • +

+ + + + + ] 1 [ . . ] 1 [ ] [ . . ) /L ) 1 ).( 2 / ( . sin(2 . . ) /L ) 1 .( 1 . sin(2 ) /L ) 1 .( . sin(2 . . . . . . . . . . ) /L 1 ). 2 / ( . sin(2 . . ) /L 1 . 1 . sin(2 ) /L 1 . . sin(2 ) /L ). 2 / ( . sin(2 . . ) /L . 1 . sin(2 ) /L . . sin(2

2 / 2 1 L/2 1 L/2 1 L/2 1

L s s s w w w L L L L L L

L

f p f p f p f p f p f p f p f p f p

L/2 columns only

slide-32
SLIDE 32

11-755 MLSP: Bhiksha Raj

Complex Exponential to the rescue

n The cosine is the real part of a complex exponential

q

The sine is the imaginary part

n A phase term for the sinusoid becomes a

multiplicative term for the complex exponential!!

) * sin( ] [ n freq n b =

1 ) * sin( ) * cos( ) * * exp( ] [

  • =

+ = = j n freq j n freq n freq j n b

) * sin( ) * cos( ) exp( ) * * exp( ) * * exp( f f f f + + + = = + n freq j n freq n freq j n freq j

slide-33
SLIDE 33

11-755 MLSP: Bhiksha Raj

A A A A x

Explaining with Complex Exponentials

+ + + + = = = = + + + +

B B B B x C x

slide-34
SLIDE 34

11-755 MLSP: Bhiksha Raj

  • +

+

  • L

n x L j L n x L j ) 2 / ( 2 exp ) 2 / ( 2 exp p p

Complex exponentials are w ell behaved

n Like sinusoids, a complex exponential of one

frequency can never explain one of another

q

They are orthogonal

n They represent smooth transitions n Bonus: They are complex

q

Can even model complex data!

n They can also model real data

q

exp(j x ) + exp(-j x) is real

n

cos(x) + j sin(x) + cos(x) – j sin(x) = 2cos(x)

n More importantly

q

is real

n

The complex exponentials with frequencies equally spaced from L/2 are complex conjugates

slide-35
SLIDE 35

11-755 MLSP: Bhiksha Raj

Complex exponentials are w ell behaved

n

is real

q

The complex exponentials with frequencies equally spaced from L/2 are complex conjugates

n

“Frequency = k” Ł k periods in L samples

q

Is also real

q

If the two exponentials are multiplied by numbers that are conjugates of one another the result is real

  • +

+

  • L

n x L j L n x L j ) 2 / ( 2 exp ) 2 / ( 2 exp p p

  • +

+

  • L

n x L j a conjugate L n x L j a ) 2 / ( 2 exp ) ( ) 2 / ( 2 exp p p

slide-36
SLIDE 36

11-755 MLSP: Bhiksha Raj

Complex Exponential bases

n

Explain the data using L complex exponential bases

n

The weights given to the (L/2 + k)th basis and the (L/2 – k)th basis should be complex conjugates, to make the result real

q

Because we are dealing with real data

n

Fortunately, a least squares fit will give us identical weights to both bases automatically; there is no need to impose the constraint externally

b0 b1 bL/2

  • +
  • 1

1 2 / 2 / 1 2 /

. .

L L L L

w w w w w

  • =

Complex conjugates

) (

2 / 2 / k L k L

w conjugate w

  • + =
slide-37
SLIDE 37

11-755 MLSP: Bhiksha Raj

Complex Exponential Bases: Algebraic Formulation

n Note that SL/2+x = conjugate(SL/2-x)

  • =
  • ]

1 [ . . ] 1 [ ] [ . . /L) ) 1 ).( 1 ( . exp(j2 . /L) ) 1 ).( 2 / ( . exp(j2 . /L) ) 1 .( . exp(j2 . . . . . . . . . . /L) 1 ). 1 ( . exp(j2 . . /L) 1 ). 2 / ( . exp(j2 . /L) 1 . . exp(j2 /L) ). 1 ( . exp(j2 . . /L) ). 2 / ( . exp(j2 . /L) . . exp(j2

1 2 /

L s s s S S S L L L L L L L L L

L L

p p p p p p p p p

slide-38
SLIDE 38

11-755 MLSP: Bhiksha Raj

Shorthand Notation

n Note that SL/2+x = conjugate(SL/2-x)

( )

  • =
  • +

= =

  • ]

1 [ . . ] 1 [ ] [ . . . . . . . . . . . . . . . . . . . . ) / 2 sin( ) / 2 cos( 1 ) / 2 exp( 1

1 2 / 1 , 1 1 , 2 / 1 , 1 , 1 1 , 2 / 1 , , 1 , 2 / , ,

L s s s S S S W W W W W W W W W L kn j L kn L L kn j L W

L L L L L L L L L L L L L L L L L L L L n k L

p p p

slide-39
SLIDE 39

11-755 MLSP: Bhiksha Raj

A quick detour

n

Real Orthonormal matrix:

q

XXT = X XT = I

n

But only if all entries are real

q

The inverse of X is its own transpose

n

Definition: Hermitian

q

XH = Complex conjugate of XT

n

Conjugate of a number a + ib = a – ib

n

Conjugate of exp(ix) = exp(-ix)

n

Complex Orthonormal matrix

q

XXH = XH X = I

q

The inverse of a complex orthonormal matrix is its own Hermitian

slide-40
SLIDE 40

11-755 MLSP: Bhiksha Raj

Doing it in matrix form

n The complex exponential basis matrix to the

left is an orthonormal matrix

q Its inverse is its own Hermition q W

  • 1 = W

H

( ) ( )

  • =
  • =
  • =
  • =

= + = =

  • ]

1 [ . . ] 1 [ ] [ . . . . . . . . . . . . . . . . . . . . ) / 2 sin( ) / 2 cos( 1 ) / 2 exp( 1 ) ( ) / 2 sin( ) / 2 cos( 1 ) / 2 exp( 1

) 1 ( ), 1 ( 2 / ), 1 ( ), 1 ( 1 , 1 2 / , 1 , , 1 1 , 2 / , , 1 2 / , , ,

L s s s W W W W W W W W W S S S L kn j L kn L L kn j L W conjugate W L kn j L kn L L kn j L W

L L L L L L L L L L L L L L L L L L L L n k L n k L n k L

p p p p p p

slide-41
SLIDE 41

11-755 MLSP: Bhiksha Raj

The Discrete Fourier Transform

n The matrix to the right is called the “Fourier

Matrix”

n The weights (S0, S1. . Etc.) are called the

Fourier transform

  • =
  • ]

1 [ . . ] 1 [ ] [ . . . . . . . . . . . . . . . . . . . .

) 1 ( ), 1 ( 2 / ), 1 ( ), 1 ( 1 , 1 2 / , 1 , , 1 1 , 2 / , , 1 2 /

L s s s W W W W W W W W W S S S

L L L L L L L L L L L L L L L L L L L L

slide-42
SLIDE 42

11-755 MLSP: Bhiksha Raj

The Inverse Discrete Fourier Transform

n The matrix to the left is the inverse Fourier matrix n Multiplying the Fourier transform by this matrix gives

us the signal right back from its Fourier transform

  • =
  • ]

1 [ . . ] 1 [ ] [ . . . . . . . . . . . . . . . . . . . .

1 2 / 1 , 1 1 , 2 / 1 , 1 , 1 1 , 2 / 1 , , 1 , 2 / ,

L s s s S S S W W W W W W W W W

L L L L L L L L L L L L L L L L L L L L

slide-43
SLIDE 43

11-755 MLSP: Bhiksha Raj

The Fourier Matrix

n Left panel: The real part of the Fourier matrix

q

For a 32-point signal

n Right panel: The imaginary part of the Fourier matrix

slide-44
SLIDE 44

11-755 MLSP: Bhiksha Raj

The FAST Fourier Transform

n

The outcome of the transformation with the Fourier matrix is the DISCRETE FOURIER TRANSFORM (DFT)

n

The FAST Fourier transform is an algorithm that takes advantage of the symmetry of the matrix to perform the matrix multiplication really fast

n

The FFT computes the DFT

q

Is much faster if the length of the signal can be expressed as 2N

slide-45
SLIDE 45

11-755 MLSP: Bhiksha Raj

Images

n The complex exponential is two dimensional

q Has a separate X frequency and Y frequency

n

Would be true even for checker boards!

q The 2-D complex exponential must be unravelled

to form one component of the Fourier matrix

n

For a KxL image, we’d have K*L bases in the matrix

slide-46
SLIDE 46

11-755 MLSP: Bhiksha Raj

DFT: Properties

n

The DFT coefficients are complex

q

Have both a magnitude and a phase

q

EQUN

n

Simple linear algebra tells us that

q

DFT(A + B) = DFT(A) + DFT(B)

q

The DFT of the sum of two signals is the DFT of their sum

n

A horribly common approximation in sound processing

q

Magnitude(DFT(A+B)) = Magnitude(DFT(A)) + Magnitude(DFT(B))

q

Utterly wrong

q

Absurdly useful

slide-47
SLIDE 47

11-755 MLSP: Bhiksha Raj

The Fourier Transform and Perception: Sound

n The Fourier transforms

represents the signal analogously to a bank of tuning forks

n Our ear has a bank of

tuning forks

n The output of the Fourier

transform is perceptually very meaningful

+

FT Inverse FT

slide-48
SLIDE 48

11-755 MLSP: Bhiksha Raj

Symmetric signals

n

If a signal is symmetric around L/2, the Fourier coefficients are real!

q

A(L/2-k) * exp(-j *f*(L/2-k)) + A(L/2+k) * exp(-j*f*(L/2+k)) is always real if

A(L/2-k) = A(L/2+k)

q

We can pair up samples around the center all the way; the final summation term is always real

n

Overall symmetry properties

q

If the *signal* is real, the FT is symmetric

q

If the signal is symmetric, the FT is real

q

If the signal is real and symmetric, the FT is real and symmetric

** ** ** * * **** * * * * * * * * * * * * *

Contributions from points equidistant from L/2 combine to cancel out imaginary terms

slide-49
SLIDE 49

11-755 MLSP: Bhiksha Raj

The Discrete Cosine Transform

n

Compose a symmetric signal or image

q

Images would be symmetric in two dimensions

n

Compute the Fourier transform

q

Since the FT is symmetric, sufficient to store only half the coefficients (quarter for an image)

n

Or as many coefficients as were originally in the signal / image

slide-50
SLIDE 50

11-755 MLSP: Bhiksha Raj

DCT

n Not necessary to compute a 2xL sized FFT

q

Enough to compute an L-sized cosine transform

q

Taking advantage of the symmetry of the problem

n This is the Discrete Cosine Transform

  • =
  • +
  • +
  • +
  • ]

1 [ . . ] 1 [ ] [ . . /2L) ) 1 ).( 5 . ( . cos(2 . . /2L) ) 1 .( 0.5) 1 .( cos(2 /2L) ) 1 ).( 5 . ( . cos(2 . . . . . . . . . . /2L) 1 ). 5 . ( . cos(2 . . /2L) 1 . 0.5) 1 .( cos(2 /2L) 1 ). 5 . ( . cos(2 /2L) ). 5 . ( . cos(2 . . /2L) . 0.5) 1 .( cos(2 /2L) ). 5 . ( cos(2

1 1

L s s s w w w L L L L L L

L

p p p p p p p p p

L columns

slide-51
SLIDE 51

11-755 MLSP: Bhiksha Raj

Representing images

n

Most common coding is the DCT

n

JPEG: Each 8x8 element of the picture is converted using a DCT

n

The DCT coefficients are quantized and stored

q

Degree of quantization = degree of compression

n

Also used to represent textures etc for pattern recognition and

  • ther forms of analysis

DCT Multiply by DCT matrix

slide-52
SLIDE 52

11-755 MLSP: Bhiksha Raj

What does the DFT represent

n

The DFT can be written formulaically as above

n

There is no restriction on computing the formula for n < 0 or n > L-1

q

Its just a formula

q

But computing these terms behind 0 or beyond L-1 tells us what the signal composed by the DFT looks like outside our narrow window

  • =
  • ]

1 [ . . ] 1 [ ] [ . . /L) ) 1 ).( 1 ( . exp(j2 . /L) ) 1 ).( 2 / ( . exp(j2 . /L) ) 1 .( . exp(j2 . . . . . . . . . . /L) 1 ). 1 ( . exp(j2 . . /L) 1 ). 2 / ( . exp(j2 . /L) 1 . . exp(j2 /L) ). 1 ( . exp(j2 . . /L) ). 2 / ( . exp(j2 . /L) . . exp(j2

1 2 /

L s s s S S S L L L L L L L L L

L L

p p p p p p p p p

  • =

=

1

) / 2 exp( ] [

L k k

L kn j S n s p

slide-53
SLIDE 53

11-755 MLSP: Bhiksha Raj

What does the DFT represent

n If you extend the DFT-based representation

beyond 0 (on the left) or L (on the right) it repeats the signal!

n So what does the DFT really mean

s[n] DFT

[S0 S1 .. S31]

  • =

=

1

) / 2 exp( ] [

L k k

L kn j S n s p

31 63

  • 32
slide-54
SLIDE 54

11-755 MLSP: Bhiksha Raj

What does the DFT represent

n The DFT represents the properties of the

infinitely long repeating signal that you can generate with it

q Of which the observed signal is ONE period

n This gives rise to some odd effects

slide-55
SLIDE 55

11-755 MLSP: Bhiksha Raj

n

The discrete Fourier transform of the above signal actually computes the properties of the periodic signal shown below

q

Which extends from –infinity to +infinity

q

The period of this signal is 32 samples in this example

The discrete Fourier transform

slide-56
SLIDE 56

11-755 MLSP: Bhiksha Raj

n

The DFT of one period of the sinusoid shown in the figure computes the spectrum of the entire sinusoid from –infinity to +infinity

n

The DFT of a real sinusoid has only one non zero frequency

q

The second peak in the figure also represents the same frequency as an effect of aliasing

Windowing

slide-57
SLIDE 57

11-755 MLSP: Bhiksha Raj

n

The DFT of one period of the sinusoid shown in the figure computes the spectrum of the entire sinusoid from –infinity to +infinity

n

The DFT of a real sinusoid has only one non zero frequency

q

The second peak in the figure also represents the same frequency as an effect of aliasing

Windowing

slide-58
SLIDE 58

11-755 MLSP: Bhiksha Raj

n

The DFT of one period of the sinusoid shown in the figure computes the spectrum of the entire sinusoid from –infinity to +infinity

n

The DFT of a real sinusoid has only one non zero frequency

q

The second peak in the figure is the “reflection” around L/2 (for real signals) Magnitude spectrum

Windowing

slide-59
SLIDE 59

11-755 MLSP: Bhiksha Raj

Windowing

n

The DFT of any sequence computes the spectrum for an infinite repetition of that sequence

n

The DFT of a partial segment of a sinusoid computes the spectrum of an infinite repetition of that segment, and not of the entire sinusoid

n

This will not give us the DFT of the sinusoid itself!

slide-60
SLIDE 60

11-755 MLSP: Bhiksha Raj

Windowing

n

The DFT of any sequence computes the spectrum for an infinite repetition of that sequence

n

The DFT of a partial segment of a sinusoid computes the spectrum of an infinite repetition of that segment, and not of the entire sinusoid

n

This will not give us the DFT of the sinusoid itself!

slide-61
SLIDE 61

11-755 MLSP: Bhiksha Raj

Windowing

Magnitude spectrum

n

The DFT of any sequence computes the spectrum for an infinite repetition of that sequence

n

The DFT of a partial segment of a sinusoid computes the spectrum of an infinite repetition of that segment, and not of the entire sinusoid

n

This will not give us the DFT of the sinusoid itself!

slide-62
SLIDE 62

11-755 MLSP: Bhiksha Raj

Windowing

Magnitude spectrum of segment Magnitude spectrum of complete sine wave

slide-63
SLIDE 63

11-755 MLSP: Bhiksha Raj

n

The difference occurs due to two reasons:

n

The transform cannot know what the signal actually looks like

  • utside the observed window

n

The implicit repetition of the observed signal introduces large discontinuities at the points of repetition

q

This distorts even our measurement of what happens at the boundaries of what has been reliably observed

Windowing

slide-64
SLIDE 64

11-755 MLSP: Bhiksha Raj

Windowing

n

The difference occurs due to two reasons:

n

The transform cannot know what the signal actually looks like

  • utside the observed window

n

The implicit repetition of the observed signal introduces large discontinuities at the points of repetition

q

These are not part of the underlying signal

n

We only want to characterize the underlying signal

q

The discontinuity is an irrelevant detail

slide-65
SLIDE 65

11-755 MLSP: Bhiksha Raj

Windowing

n

While we can never know what the signal looks like outside the window, we can try to minimize the discontinuities at the boundaries

n

We do this by multiplying the signal with a window function

q

We call this procedure windowing

q

We refer to the resulting signal as a “windowed” signal

n

Windowing attempts to do the following:

q

Keep the windowed signal similar to the original in the central regions

q

Reduce or eliminate the discontinuities in the implicit periodic signal

slide-66
SLIDE 66

11-755 MLSP: Bhiksha Raj

Windowing

n

While we can never know what the signal looks like outside the window, we can try to minimize the discontinuities at the boundaries

n

We do this by multiplying the signal with a window function

q

We call this procedure windowing

q

We refer to the resulting signal as a “windowed” signal

n

Windowing attempts to do the following:

q

Keep the windowed signal similar to the original in the central regions

q

Reduce or eliminate the discontinuities in the implicit periodic signal

slide-67
SLIDE 67

11-755 MLSP: Bhiksha Raj

Windowing

n

While we can never know what the signal looks like outside the window, we can try to minimize the discontinuities at the boundaries

n

We do this by multiplying the signal with a window function

q

We call this procedure windowing

q

We refer to the resulting signal as a “windowed” signal

n

Windowing attempts to do the following:

q

Keep the windowed signal similar to the original in the central regions

q

Reduce or eliminate the discontinuities in the implicit periodic signal

slide-68
SLIDE 68

11-755 MLSP: Bhiksha Raj

Windowing

n

The DFT of the windowed signal does not have any artefacts introduced by discontinuities in the signal

n

Often it is also a more faithful reproduction of the DFT of the complete signal whose segment we have analyzed

Magnitude spectrum

slide-69
SLIDE 69

11-755 MLSP: Bhiksha Raj

Windowing

Magnitude spectrum of windowed signal Magnitude spectrum of complete sine wave Magnitude spectrum of original segment

slide-70
SLIDE 70

11-755 MLSP: Bhiksha Raj

Windowing

n

Windowing is not a perfect solution

q

The original (unwindowed) segment is identical to the original (complete) signal within the segment

q

The windowed segment is often not identical to the complete signal anywhere

n

Several windowing functions have been proposed that strike different tradeoffs between the fidelity in the central regions and the smoothing at the boundaries

slide-71
SLIDE 71

11-755 MLSP: Bhiksha Raj

n Cosine windows:

q

Window length is M

q

Index begins at 0

n Hamming: w[n] = 0.54 – 0.46 cos(2pn/M) n Hanning: w[n] = 0.5 – 0.5 cos(2pn/M) n Blackman: 0.42 – 0.5 cos(2pn/M) + 0.08 cos(4pn/M)

Windowing

slide-72
SLIDE 72

11-755 MLSP: Bhiksha Raj

n Geometric windows:

q

Rectangular (boxcar):

q

Triangular (Bartlett):

q

Trapezoid:

Windowing

slide-73
SLIDE 73

11-755 MLSP: Bhiksha Raj

Zero Padding

n

We can pad zeros to the end of a signal to make it a desired length

q

Useful if the FFT (or any other algorithm we use) requires signals

  • f a specified length

q

E.g. Radix 2 FFTs require signals of length 2n i.e., some power

  • f 2. We must zero pad the signal to increase its length to the

appropriate number

n

The consequence of zero padding is to change the periodic signal whose Fourier spectrum is being computed by the DFT

slide-74
SLIDE 74

11-755 MLSP: Bhiksha Raj

n

We can pad zeros to the end of a signal to make it a desired length

q

Useful if the FFT (or any other algorithm we use) requires signals of a specified length

q

E.g. Radix 2 FFTs require signals of length 2n i.e., some power of 2. We must zero pad the signal to increase its length to the appropriate number

n

The consequence of zero padding is to change the periodic signal whose Fourier spectrum is being computed by the DFT

Zero Padding

slide-75
SLIDE 75

11-755 MLSP: Bhiksha Raj

n

The DFT of the zero padded signal is essentially the same as the DFT of the unpadded signal, with additional spectral samples inserted in between

q

It does not contain any additional information over the original DFT

q

It also does not contain less information

Zero Padding

Magnitude spectrum

slide-76
SLIDE 76

11-755 MLSP: Bhiksha Raj

Magnitude spectra

slide-77
SLIDE 77

11-755 MLSP: Bhiksha Raj

n Zero padding windowed signals results in signals

that appear to be less discontinuous at the edges

q

This is only illusory

q

Again, we do not introduce any new information into the signal by merely padding it with zeros

Zero Padding

slide-78
SLIDE 78

11-755 MLSP: Bhiksha Raj

Zero Padding

n

The DFT of the zero padded signal is essentially the same as the DFT of the unpadded signal, with additional spectral samples inserted in between

q

It does not contain any additional information over the original DFT

q

It also does not contain less information

slide-79
SLIDE 79

11-755 MLSP: Bhiksha Raj

Magnitude spectra

slide-80
SLIDE 80

11-755 MLSP: Bhiksha Raj

8000 8000 8000 8000Hz 8000 8000 8000 8000Hz time frequency frequency

128 samples from a speech signal sampled at 16000 Hz The first 65 points of a 128 point DFT. Plot shows log of the magnitude spectrum The first 513 points of a 1024 point DFT. Plot shows log of the magnitude spectrum

Zero padding a speech signal

slide-81
SLIDE 81

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

slide-82
SLIDE 82

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-83
SLIDE 83

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-84
SLIDE 84

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-85
SLIDE 85

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-86
SLIDE 86

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-87
SLIDE 87

11-755 MLSP: Bhiksha Raj

The process of parameterization

n The signal is processed in segments of 25-64 ms

q

Because the properties of audio signals change quickly

q

They are “stationary” only very briefly

n Adjacent segments overlap by 15-48 ms

slide-88
SLIDE 88

11-755 MLSP: Bhiksha Raj

The process of parameterization

Each segment is typically 25-64 milliseconds wide

Audio signals typically do not change significantly within this short time interval

Segments shift every 10- 16 milliseconds

slide-89
SLIDE 89

11-755 MLSP: Bhiksha Raj

The process of parameterization

Each segment is windowed and a DFT is computed from it Windowing Frequency (Hz) Complex spectrum

slide-90
SLIDE 90

11-755 MLSP: Bhiksha Raj

The process of parameterization

Each segment is windowed and a DFT is computed from it Windowing

slide-91
SLIDE 91

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

slide-92
SLIDE 92

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency

slide-93
SLIDE 93

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-94
SLIDE 94

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-95
SLIDE 95

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-96
SLIDE 96

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-97
SLIDE 97

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-98
SLIDE 98

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-99
SLIDE 99

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-100
SLIDE 100

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-101
SLIDE 101

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-102
SLIDE 102

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-103
SLIDE 103

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-104
SLIDE 104

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-105
SLIDE 105

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-106
SLIDE 106

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-107
SLIDE 107

11-755 MLSP: Bhiksha Raj

Computing a Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side

frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency frequency

slide-108
SLIDE 108

11-755 MLSP: Bhiksha Raj

Computing the Spectrogram

Compute Fourier Spectra of segments of audio and stack them side-by-side The Fourier spectrum of each window can be inverted to get back the signal. Hence the spectrogram can be inverted to obtain a time-domain signal In this example each segment was 25 ms long and adjacent segments overlapped by 15 ms

slide-109
SLIDE 109

11-755 MLSP: Bhiksha Raj

The result of parameterization

n

Each column here represents the FT of a single segment of signal 64ms wide.

q

Adjacent segments overlap by 48 ms.

n

DFT details

q

1024 points (16000 samples a second).

q

2048 point DFT – 1024 points of zero padding.

q

Only 1025 points of each DFT are shown

n

The rest are “reflections”

n

The value shown is actually the magnitude of the complex spectral values

q

Most of our analysis / operations are performed on the magnitude

slide-110
SLIDE 110

11-755 MLSP: Bhiksha Raj

Magnitude and phase

n All the operations (e.g. the examples shown in the

previous class) are performed on the magnitude

n The phase of the complex spectrum is needed to invert

a DFT to a signal

q

Where does that come from?

n Deriving phase is a serious, not-quite solved problem.

  • =
  • ]

1 [ . . ] 1 [ ] [ . . . . . . . . . . . . . . . . . . . .

1 1 , 1 1 , 2 / 1 , 1 , 1 1 , 2 / 1 , , 1 , 2 / ,

L s s s S S S W W W W W W W W W

L k L L L L L L L L L L L L L L L L L L

)) ( . exp( | |

k k k

S phase j S S =

?

slide-111
SLIDE 111

11-755 MLSP: Bhiksha Raj

Phase

n

Common tricks: Obtain the phase from the original signal

q

Sft = DFT(signal)

q

Phase1 = phase(Sft)

n

Each term is of the form real + j imag

n

For each element, compute arctan(imag/real)

q

Smagnitude = magnitude(Sft)

n

For each element compute Sqrt(real*real + imag*imag)

q

ProcessedSpectrum= Process(Smagnitude)

q

New SFT = ProcessedSpectrum*exp(j*Phase)

q

Recover signal from SFT

n

Some other tricks:

q

Compute the FT of a different signal of the same length

q

Use the phase from that signal

slide-112
SLIDE 112

11-755 MLSP: Bhiksha Raj

Returning to the speech signal

n

For each complex spectral vector, compute a signal from the inverse DFT

q

Make sure to have the complete FT (including the reflected portion)

n

If need be window the retrieved signal

n

Overlap signals from adjacent vectors in exactly the same manner as during analysis

q

E.g. If a 48ms (768 sample) overlap was used during analysis, overlap adjacent segments by 768 samples

Actually a matrix of complex numbers 16ms (256 samples)

slide-113
SLIDE 113

11-755 MLSP: Bhiksha Raj

Additional tricks

n

The basic representation is the magnitude spectrogram

n

Often it is transformed to a log spectrum

q

By computing the log of each entry in the spectrogram matrix

q

After processing, the entry is exponentiated to get back the magnitude spectrum

n

To which phase may be factored in to get a signal

n

The log spectrum may be “compressed” by a dimensionality reducing matrix

q

Usually a DCT matrix

Log() x DCT(24x1025)