tutorials 12,13 discrete signals and systems

45
Technion, CS department, SIPC 236327 Spring 2014 Tutorials 12,13 discrete signals and systems 1/39

Upload: peggy

Post on 23-Feb-2016

54 views

Category:

Documents


0 download

DESCRIPTION

Tutorials 12,13 discrete signals and systems. Technion, CS department, SIPC 236327 Spring 2014. Discrete LSI system. Linear Space invariant. Discrete LSI system. Linear Space invariant. Example. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Tutorials 12,13 discrete signals and systems

Technion, CS department, SIPC 236327Spring 2014

Tutorials 12,13discrete signals and systems

1/39

Page 2: Tutorials 12,13 discrete signals and systems

• Linear

• Space invariant

Discrete LSI system

2/39

𝐻1 𝐷 nx ny

Page 3: Tutorials 12,13 discrete signals and systems

• Linear

• Space invariant

Discrete LSI system

3/39

nmg , nmf , 𝐻2 𝐷

Page 4: Tutorials 12,13 discrete signals and systems

• For compression, a rule to predict the pixel value is used:

Is the system linear? Space invariant?

Example

4/39

Page 5: Tutorials 12,13 discrete signals and systems

• System is defined with its impulse response

Discrete LSI system

5/39

nhxknhkxnyk

*

𝛿 [𝑛 ]

𝑛

Page 6: Tutorials 12,13 discrete signals and systems

• Infinite support

• DTFT

Cyclic convolution

6/39

• Finite support

• DFT• Efficient implementation

Convolution

knhkxnhxk

* NknhkxnhxN

k

mod1

0

12

10

01211012

23011210

12

10

NxNx

xx

hhNhNhNhhNhNh

hhhhhhNhh

NyNy

yy

Page 7: Tutorials 12,13 discrete signals and systems

Q: How can we use this system to calculate a linear convolution?A: Zero padding, and truncation of the result.

Exercise

7/39

]0,0,0,3,2,1,0[]0,0,0,4,3,2,1[]3,2,1,0[*]4,3,2,1[

H nx nyx )( ny

Q: If both signals are of length N, how many zeros will we add?

A: N-1 zeros

Page 8: Tutorials 12,13 discrete signals and systems

Q: How can we use this system to calculate a cyclic convolution?A: Duplicate one signal, and truncation of the result.

Exercise

8/39

H nx nyx )*( ny

]3,2,1,0[*]3,2,1,4,3,2,1[]3,2,1,0[]4,3,2,1[ Q: If both signals are of length N, how much should we

duplicateA: N-1 cells

Page 9: Tutorials 12,13 discrete signals and systems

Infinite support Infinite supportContiniuous Continuous

Finite support Finite supportDiscrete Discrete

Discrete Fourier Transform (DFT, FFT)

9/39

)(txFourier)(tx

][nx ][nxDFT

Page 10: Tutorials 12,13 discrete signals and systems

מתבצעות בדרך הרגילה DFT-1 וDFTהתמרות ה•

המקדמים מחזוריים:•[ בד"כ N-1,0לכן במקום להתייחס לתחום ]•

[.N/2,N/2-1מסתכלים על התחום ]-

DFT

10/39

1

0

/2

1

0

/2/2

1

0

*

1][

11,][

,

N

k

Nkni

N

n

NkniNkni

N

n

ekXN

nx

enxN

eN

nxkX

ngnfngnf

...2,1,0, mmNkXkX

Page 11: Tutorials 12,13 discrete signals and systems

DFTהפעלת

11/39

0 50 100-1

-0.5

0

0.5

1

t

x[t]

-50 0 500

5

10

15

20

k|X

[k]|

Page 12: Tutorials 12,13 discrete signals and systems

DFTדוגמאות

12/39

10,2cos

10,

00

00

NknNkDFT

NnnnDFT

Page 13: Tutorials 12,13 discrete signals and systems

• Fourier transform– Time domain – non-periodic infinite signals– Continuous time (t)– Continuous frequency (f)– Formulas

Summary – Fourier Transforms

13/39

TransformFourier )( )(

TransformFourier Inverse )()(

2

2

dtetxfX

dkefXtx

fti

fti

Page 14: Tutorials 12,13 discrete signals and systems

• DTFT: Discrete Time Fourier Transform– Time domain – non-periodic infinite signals– Discrete time (n)– Continuous frequency (f)– Formulas

Summary – Fourier Transforms

14/39

ansformFourier tr DT ][ )(

ansformFourier tr DT inverse )(21][

2

-n

2

fni

fti

etxfX

dfekXnx

מד נל

לא

קורסב

Page 15: Tutorials 12,13 discrete signals and systems

• Fourier series– Time domain – periodic infinite signals– Continuous time (t)– Discrete frequency (f)– Formulas

Summary – Fourier Transforms

15/39

fixed is , 1 Lperiod has

)(T1 ),(][

][)(

)2()2(

)2(

ff

x(t)

dtetxetxkX

ekXtx

T

ktfiktfi

k

ktfi

Page 16: Tutorials 12,13 discrete signals and systems

• DFT or Discrete Time Fourier Series– Time domain – periodic infinite signals– Discrete time (n)– Discrete frequency (f)– Formulas

Summary – Fourier Transforms

16/39

N period a have X[k] and x[n]

1][

11,][

1

0

/2

1

0

/2/2

N

k

Nkni

N

n

NkniNkxi

ekXN

nx

enxN

eN

nxkX

Page 17: Tutorials 12,13 discrete signals and systems

DFT ומערכת LSI

17/39

nhxny nx nh kX kH

kHkXkY

Page 18: Tutorials 12,13 discrete signals and systems

• We have an N-length filter with impulse response h[n].We create a new filter as follows:

Express F[k] with H[k], where H[k]=DFT{h[n]},F[k]=DFT{f[n]}

• Instructions: calculate

Exercise

18/39

][][)1(][ nNhnhnf n

]}[{]}[)1{(

nNhDFTnhDFT n

Page 19: Tutorials 12,13 discrete signals and systems

• Noisy image of size 256X256Im_out[m,n]=Im_in[m,n]+noise[m,n]

• Harmonic noise:

• f = 1/(8 pixels)• Amplitude A and phase φ are random and independent

for each line.

Example – discrete frequency filtration

19/39

mm fnAnmnoise 2cos],[

Page 20: Tutorials 12,13 discrete signals and systems

Example – added noise in line 100

20/39

radA

325.137.22

100

100

Page 21: Tutorials 12,13 discrete signals and systems

Example – discrete frequency filtration

21/39

Page 22: Tutorials 12,13 discrete signals and systems

Example – discrete frequency filtration - smoothing

22/39

Page 23: Tutorials 12,13 discrete signals and systems

Example – discrete frequency filtration – smoothing vs median (8 pixels)

23/39

No noise but image is blurred

Page 24: Tutorials 12,13 discrete signals and systems

• DFT of the noise in line i

Example – discrete frequency filtration

24/39

elsekeA

elsekeAniNoiseDFT

N

nN

AfnAniNoise

ii

i iiN

ikN

i

iiii

032

032),(

256

322cos2cos),(

3222

Page 25: Tutorials 12,13 discrete signals and systems

• Design an LSI filter– Such filter multiplies each frequency with a complex

number– Can handle each frequency separately

• In this example, we want to handle frequencies 32 and -32.– Notch filter – attenuates specific frequency

Example – discrete frequency filtration

25/39

Page 26: Tutorials 12,13 discrete signals and systems

Example – discrete frequency filtration

26/39

Original signal in frequency domain

Filtered signal in frequency domain

Page 27: Tutorials 12,13 discrete signals and systems

• Noise removed completely

• Original image not fully restored– We cannot restore the

attenuated frequencies

Example – discrete frequency filtration

27/39

Page 28: Tutorials 12,13 discrete signals and systems

Example – discrete frequency filtration

28/39

Smoothing filter of 8 pixels

Notch filter

Page 29: Tutorials 12,13 discrete signals and systems

• Filter in freq. domain:Filter=ones(1,256);Filter(32+1)=0;Filter(224+1)=0;• Filtration:For k=1:size(I,1),

Y=fft(I(k,:)).*Filter;I(k,:)=ifft(Y);

end

Example –frequency filtration - implementation

29/39

Notch filter in freq. domain

Page 30: Tutorials 12,13 discrete signals and systems

Technion, CS department, SIPC 236327Spring 2014

Tutorials 12,13discrete signals and systemsPart II: 2D

30/39

Page 31: Tutorials 12,13 discrete signals and systems

2D convolution:

2D - definitions

31/39

mnhxmny ,*, mnx , mnh ,

k l

lnkmhlkxnmhx ,,,*

Page 32: Tutorials 12,13 discrete signals and systems

• Cyclic 2D-convolution:

• 2D DFT:

32/39

nmhxnmy ,, nmx , nmh ,

lkX , lkH ,

lkHlkXlkY ,,,

1

0

1

0modmod ,,,

M

k

N

lNM lnkmhlkxnmhx

1

0

1

0

22

, ,1,M

m

N

n

Nnli

Mmki

lk eenmxMN

nmxDFT

2D - definitions

Page 33: Tutorials 12,13 discrete signals and systems

• DFT is linear, we have an operation matrix:

• 2D-DFT can be implemented as:

• If the input is separable:

33/39

nXDnXDFT

TDnmDXnmXDFT ,,

lk nXDFTmXDFTnmXDFT

nXmXnmX

21

21

,,

2D - notes

Page 34: Tutorials 12,13 discrete signals and systems

• Noisy image 512X512

• The noise:Add 100 gray levels for all 16i lines

Example

34/39

Page 35: Tutorials 12,13 discrete signals and systems

mean 4X4

Example

35/39

Noisy image Average filteroriginal + noise

Page 36: Tutorials 12,13 discrete signals and systems

mean 16X16

Example

36/39

Noisy image Average filteroriginal + noise

Page 37: Tutorials 12,13 discrete signals and systems

• How does the noise look like in the frequency domain?

Example

37/39

else

kkmknmnr

0,16161

,

Page 38: Tutorials 12,13 discrete signals and systems

• Filter implementation in the freq. domain:

H=ones(512,512);for n=1:32:512

H(n,1) = H(1,n) = 0;endH(1,1) = 1;

• Image filtration:out = ifft( fft(img).*H );

Example

38/39

After freq. filtration

Page 39: Tutorials 12,13 discrete signals and systems

לפני סינון תדרDFT of image + noise

39/39

Page 40: Tutorials 12,13 discrete signals and systems

לפני סינון תדר (הגדלה של מרכז)

40/39

Page 41: Tutorials 12,13 discrete signals and systems

אחרי סינון תדר (הגדלה של מרכז)

41/39

Page 42: Tutorials 12,13 discrete signals and systems

Image filtration

42/39

000011000

h

000110000

h

000101000

21h

Page 43: Tutorials 12,13 discrete signals and systems

• Roberts

• Prewitt

• Sobel

Edge detection of Image A

43/39

AGAG yx *0110

*10

01

AGAG yx *111

000111

*101101101

AGAG yx *121

000121

*101202101

22 ),(),(),( nmGnmGnmG yx

Page 44: Tutorials 12,13 discrete signals and systems

Edge detection of Image A

44/44

Original Roberts

SobelPrewitt

Page 45: Tutorials 12,13 discrete signals and systems

Unsharp masking – edge enhancement

45/44

LInkInOut

L

*

010141

010