Digital Image Processing
Lab 1
Part of the contents of this lab are from the book:
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458.
2003 Pearson Education, Inc.
Exercise 1
Generating a sound
Fs = 8000; % Sample everything at 8000 Hz
Fo = 660; % Use 660 Hz as the fundamental freq of each waveform
T_total = 1.2; % Compute a total of 1.2 seconds so the sound can be played
tt = 0:(1/Fs):T_total; % Set up the time axis
% ===== First the cosine =====
y1 = cos(2*pi*Fo*tt);
range = 801:880; % Only plot a part of the signal
subplot('Position',[0.1 0.8 0.8 0.15])
plot(tt(range),y1(range))
xlabel('TIME (sec)')
title(['SINE WAVE at ',num2str(Fo),' Hz'])
sound(y1, Fs)
Exercise 2
Saving a sound as a WAV file
fs = 8000;
ZZ = [ (386 + j*6101);
(-4433 + j*14024);
(24000 - j*4498);
(828 - j*6760);
(2362 + j*0) ];
%
Fo = 100;
ff = Fo * [ 2, 4, 5, 16, 17 ]; %-- row
dur = 4/Fo;
tt = 0 : (1/fs) : dur;
xi = exp( -2i*pi*tt'*ff ); %--- components
xx = xi * ZZ;
%
dur_long = 1.5;
ttt = 0 : (1/fs) : dur_long;
titleFontSize=12;
labelFontSize=12;
gcaFontSize=12;
tms = tt*1000; %--- convert to msec
% subplot('Position',[0.12 0.6 0.8 0.3])
jkl = 1;
x1 = xi(:,jkl)*ZZ(jkl);
hp = plot( tms, real( x1 ) );
set(hp,'LineWidth',2)
title('x = Re(A_2 exp(j*2*pi*2*f0*t) )','FontSize',titleFontSize)
set(gca,'FontSize',gcaFontSize)
ylabel('Amplitude','FontSize',labelFontSize)
disp('<CR> to play sound'), pause
xxx = real(exp( -2i*pi*ttt'*ff(jkl) )*ZZ(jkl));
soundsc( xxx, fs );
wavwrite(xxx/max(abs(xxx)),fs,16,'k02.wav')
Exercise 3
Discrete LTI systems
Try the DLTI of the book.
Exercise 4
Poles and zeros
Try the pez_31 of the book.