Upload
dangngoc
View
225
Download
0
Embed Size (px)
Citation preview
2
Part 2: Aliasing in Frequency Domain
3
Ex: x(t)=5 cos (2pi*2000* t)3+ cos (2pi *3000* t)
Fs=8000 Hz
Fs> 2Fm=2*3000=6 kHZ
Sampled Signal
4
Ex: x(t)=5 cos (2pi*2000* t)3+ cos (2pi *5000* t)
Fs=8000 Hz
Fs< 2Fm=2*5000=10 kHZ
5
Part 2: Aliasing in Frequency Domain
See the related video
6
7
8
9
10
Part 3: Quantization
function y=uquant(x,n)
del=((max(max(x))-(min(min(x)))))/(n-1);
r=(x-min(min(x)))/del;
r=round(r);
y=r*del+min(min(x));
end
11
Example: Quantized x=2sin (2pi*t) using 16 levels.
max min 2 ( 2)4 /15
1 16 1
X Xdel
L
2
2
4
0
12
4
0
13
14
2
2
15
0
15
t=0:.001:1;
y=2*sin(2*pi*t)
figure(1)
subplot(311)
plot(y)
q1=uquant(y,4)
subplot(312)
plot(q1)
q2=uquant(y,32)
subplot(313)
plot(q2)
Ps=mean(y.^2);
Pq1=mean(q1.^2);
Pq2=mean(q2.^2);
SQR1=Ps/Pq1
SQR2=Ps/Pq2
16
0 200 400 600 800 1000 1200-2
0
2
0 200 400 600 800 1000 1200-2
0
2
0 200 400 600 800 1000 1200-2
0
2
17
Image Quantization
Exercise 1
18
clc
clear all
y1=imread('office_4.jpg');
y=rgb2gray(y1);
for i=1:7;
L=2^i;
Q=uquant(y,L);
i=i+1;
pause
L
figure(i)
imshow(Q)
end
19
b=1
20
b=2
21
b=3
22
b=4
23
b=5
24
b=6
25
b=7
26
clc
clear all
[y,fs]=wavread('speech_dft.wav');
sound(y,fs)
for b=1:7;
L=2.^b;
yQ=uquant(y,L);
pause
b
sound(yQ,fs);
end
Audio Quantization
27
semilogy
Exercise 2
Audio Quantization
Hint : x=original signal , q=quantized signal , Error=x-q , SQNR=Px/PE , Px=mean(x.^2)
28
2 3 4 5 6 7 810
-2
10-1
100
101
102
103
104
plotting SNR
0 1 2 3 4 5 6 7 80
200
400
600
800
1000
1200
1400plotting SNR
29
Simulink model for sampling and quantization
30
Exercise 3
31
32
Q ua ntization error : ( ) ( ) ( )q qe n x n x n
2 2error
max minQuantization step =1
x x
L
0.1 0.1
2 2error
Quantization
33
Quantization of sinusoidal signal
2 2
2 2
0 0
2 2
2
2
2
1 1P ( ) ( sin )
2 2
( ) for ( T t T )2
1 1P ( ( )) ( )
2 2
1
2 2
2
2
sig
q
T T
q q
T T
T
T
S t dt A wt dt
e t tT
e t dt t dtT T T
t dtT T
A
Average power of sinusoidal signal :
Average power of quantized signal :
2
12
34
Signal to quantization noise ratio
2
12
2
max min
2
2
2
2
2
the signal to quantization noise ratio
P
P
( ) 2
P 2
P
2
12
4
12
3
2
sig
q
sig
q
SQNR
x x A A A
L L L
A
SQNR
A
LA
L
2
10 10
3( ) 10log ( ) 10log ( 2 ) 1.76 6.02
2
bSQNR dB SQNR b
35
If the desired sampling rate is lower than the sampling
rate of the available data, in this case, we may use
a process called downsampling.
Scaling
X(n) ={ ---- , 0 , 2 , 0 , 1 , 0 , ….}
X(n/3) ={ ---- , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , ….}
36
X(n) ={ ---- , 9 , 5 , 2 , 0 , 1 , 2 , 4 , 8 ,…..}
X(3n) ={ ---- , 0 , 0 , 0 , 9 , 0 , 4 , 0 , 0 , ….}
37
If the original sequence with a sampling period T= 0.1 second (sampling rate =
10 samples per sec) is given by:
x(n) : 8 7 4 8 9 6 4 2 2 5 7 7 6 4 . . .
and we downsample the data sequence by a factor of 3, we obtain the
downsampled sequence as
y(m) =y(3n)= 8 8 4 5 6 . . .
with the resultant sampling period T = 3 x 0.1 = 0.3 second (the sampling rate
now is 3.33 samples per second).
Example
38
By MATLAB, we can do this in an easy way. For example,
>> x=1:1:10
x =
1 2 3 4 5 6 7 8 9 10
>> x2=x(1:2:end)
x2 =
1 3 5 7 9
39
Anti-aliasing Filter
LOGO
40