Upload
sanne
View
59
Download
0
Embed Size (px)
DESCRIPTION
Tutorials 11,12,13 discrete signals and systems. Technion, CS department, SIPC 236327 Winter 2012-2013. 1. Discrete LSI system. Linear Space invariant. 2. Discrete LSI system. Linear Space invariant. 3. E xample. - PowerPoint PPT Presentation
Citation preview
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Tutorials 11,12,13discrete signals and systems
Technion, CS department, SIPC 236327Winter 2012-2013
1
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Discrete LSI system
Linear
Space invariant
2
𝐻1 𝐷 nx ny
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Discrete LSI system
Linear
Space invariant
3
nmg , nmf , 𝐻2 𝐷
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
For compression, a rule to predict the pixel value is used:
Is the system linear? Space invariant?
4
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Discrete LSI system
System is defined with its impulse response
5
nhxknhkxnyk
*
𝛿 [𝑛 ]
𝑛
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Cyclic convolution
• Infinite support
• DTFT
6
• Finite support
• DFT• Efficient implementation
Convolution
knhkxnhxk
* NknhkxnhxN
k
mod1
0
12
10
01211012
23011210
12
10
NxNx
xx
hhNhNhNhhNhNh
hhhhhhNhh
NyNy
yy
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Exercise
Q: How can we use this system to calculate a linear convolution?A: Zero padding, and truncation of the result.
7
]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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Exercise
Q: How can we use this system to calculate a cyclic convolution?A: Duplicate one signal, and truncation of the result.
8
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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Discrete Fourier Transform (DFT, FFT)
Infinite support infinite supportContiniuous continuous
Finite support Finite supportDiscrete Discrete
9
)(txFourier)(tx
][nx ][nxDFT
עיבוד תמונות ואותות במחשבDFT: 10תרגול
DFT
מתבצעות בדרך הרגילה DFT-1 וDFTהתמרות ה•
המקדמים מחזוריים:•[ בד"כ מסתכלים על N-1,0לכן במקום להתייחס לתחום ]•
[.N/2,N/2-1התחום ]-
10
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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
DFTהפעלת
11
0 50 100-1
-0.5
0
0.5
1
t
x]t[
-50 0 500
5
10
15
20
k|X
]k[|
עיבוד תמונות ואותות במחשבDFT: 10תרגול
DFTדוגמאות
12
10,2cos
10,
00
00
NknNkDFT
NnnnDFT
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Summary – Fourier Transforms
Fourier transform– Time domain – non-periodic infinite signals– Continuous time (t)– Continuous frequency (f)– Formulas
13/39
TransformFourier )( )(
TransformFourier Inverse )()(
2
2
dtetxfX
dkefXtx
fti
fti
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Summary – Fourier Transforms
DTFT: Discrete Time Fourier Transform– Time domain – non-periodic infinite signals– Discrete time (n)– Continuous frequency (f)– Formulas
14/39
ansformFourier tr DT ][ )(
ansformFourier tr DT inverse )(21][
2
-n
2
fni
fti
etxfX
dfekXnx
מד נל
לא
קורסב
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Summary – Fourier Transforms
Fourier series– Time domain – periodic infinite signals– Continuous time (t)– Discrete frequency (f)– Formulas
15/39
fixed is , 1 Lperiod has
)(T1 ),(][
][)(
)2()2(
)2(
ff
x(t)
dtetxetxkX
ekXtx
T
ktfiktfi
k
ktfi
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Summary – Fourier Transforms
DFT or Discrete Time Fourier Series– Time domain – periodic infinite signals– Discrete time (n)– Discrete frequency (f)– Formulas
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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
DFT ומערכת LSI
17
nhxny nx nh kX kH
kHkXkY
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Exercise
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
18
][][)1(][ nNhnhnf n
]}[{]}[)1{(
nNhDFTnhDFT n
עיבוד תמונות ואותות במחשבDFT: 10תרגול
19/39
Example – discrete frequency filtration
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.
mm fnAnmnoise 2cos],[
עיבוד תמונות ואותות במחשבDFT: 10תרגול
20/39
Example – added noise in line 100
radA
325.137.22
100
100
עיבוד תמונות ואותות במחשבDFT: 10תרגול
21/39
Example – discrete frequency filtration
עיבוד תמונות ואותות במחשבDFT: 10תרגול
22/39
Example – discrete frequency filtration - smoothing
עיבוד תמונות ואותות במחשבDFT: 10תרגול
23/39
Example – discrete frequency filtration – smoothing vs median (8 pixels)
No noise but image is blurred
עיבוד תמונות ואותות במחשבDFT: 10תרגול
24/39
Example – discrete frequency filtration
DFT of the noise in line i
elsekA
niNoiseDFT
N
nN
AfnAfnAniNoise
i
iiii
032
),(
256
322cos2cos2cos),(
עיבוד תמונות ואותות במחשבDFT: 10תרגול
25/39
Example – discrete frequency filtration
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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
26/39
Example – discrete frequency filtration
Original signal in frequency domain
Filtered signal in frequency domain
עיבוד תמונות ואותות במחשבDFT: 10תרגול
27/39
Example – discrete frequency filtration
Noise removed completely
Original image not fully restored
–We cannot restore the attenuated frequencies
עיבוד תמונות ואותות במחשבDFT: 10תרגול
28/39
Example – discrete frequency filtration
Smoothing filter of 8 pixels
Notch filter
עיבוד תמונות ואותות במחשבDFT: 10תרגול
29/39
Example –frequency filtration - implementation
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
Notch filter in freq. domain
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Tutorials 11,12,13discrete signals and systemsPart II: 2D
Technion, CS department, SIPC 236327Winter 2012-2013
30
עיבוד תמונות ואותות במחשבDFT: 10תרגול
2D - definitions
2D convolution:
31
mnhxmny ,*, mnx , mnh ,
k l
lnkmhlkxnmhx ,,,*
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Cyclic 2D-convolution:
2D DFT:
32
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
עיבוד תמונות ואותות במחשבDFT: 10תרגול
DFT is linear, we have an operation matrix:
2D-DFT can be implemented as:
If the input is separable:
33
nXDnXDFT
TDnmDXnmXDFT ,,
lk nXDFTmXDFTnmXDFT
nXmXnmX
21
21
,,
2D - notes
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
Noisy image 512X512
The noise:Add 100 gray levels for all 16i lines
34
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
35
Noisy image Average filteroriginal + noise mean 4X4
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
36
Noisy image Average filteroriginal + noise mean 16X16
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
How does the noise look like in the frequency domain?
37
else
kkmknmnr
0,16161
,
עיבוד תמונות ואותות במחשבDFT: 10תרגול
Example
38
After freq. filtration• 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 );
עיבוד תמונות ואותות במחשבDFT: 10תרגול 39
לפני סינון תדרDFT of image + noise
עיבוד תמונות ואותות במחשבDFT: 10תרגול 40
לפני סינון תדר (הגדלה של מרכז)
עיבוד תמונות ואותות במחשבDFT: 10תרגול 41
אחרי סינון תדר (הגדלה של מרכז)