140 likes | 244 Views
L34: Noise and Signal. Announcements. Away next Friday, the class will be taught by …. No office hours next Wednesday Assignment 4. Smoothing functions Audio processing Image processing. What does this code do?. t= linspace (0,2*pi,101); y=sin(t); y=sin(t)+0.1*(rand(size(t))-0.5);
E N D
Announcements • Away next Friday, the class will be taught by …. • No office hours next Wednesday • Assignment 4
Smoothing functions • Audio processing • Image processing
What does this code do? t=linspace(0,2*pi,101); y=sin(t); y=sin(t)+0.1*(rand(size(t))-0.5); y_mod=y; for i=2:length(t)-1 y_mod(i)=(y(i-1)+y(i)+y(i+1))/3; end
Noise vs Signal plots plot(t,y); hold on; plot(t,y_mod,’r’);
Other ways of smoothing • Vector additions y_mod=y; y_mod(2:end-1)=(y(1:end-2)+y(2:end-1)+y(3:end))/3; • Convolution/Filtering y_mod=imfilter(y,[1 1 1]/3);
What does this code do? t=linspace(0,2*pi,101); y=sin(t)+0.1*(rand(size(t))-0.5); y_mod=y; for i=2:length(t)-1 y_mod(i)=y(i)-y(i-1); end plot(t,y_mod);
Other ways of doing the same thing • Vector minus y_mod=y; y_mod(2:end)=y(2:end)-y(1:end-1); • Convolution/Filtering y_mod=imfilter(y,[-1 1]);
Takeaways • Averaging smoothens i.e. suppresses high frequency jitter • Differentiating amplifies noise i.e. suppresses low frequency signal
Audio processing • Reading in a wav file • [audio_var,fs]=wavread(‘hootie.wav’); • Audio variables are just two column matrices: first column is the left channel and the second column is the right channel • Playing audio • soundsc(audio_var,fs); • soundsc(audio_var(:,1),fs); %plays left channel
Vector operations on audio files left=audio_var(:,1); right=audio_var(:,2); plot(left) soundsc(left(end:-1:1,:),fs)
Adding echo N=10000; left_echo=left; for i=N+1:length(left) left_echo=left(i)+left(i-N); end
Removing vocals • Vocals are, in general, recorded on both the left and right channel. So…. • soundsc(left-right, fs)
High frequency (noise) and low frequency (signal) • Suppressing high frequency (smoothing) left_smooth=imfilter(left,ones(10,1)); • Suppressing low frequency (differentiating) left_der=left(2:end)-left(1:end-1);