SLIDE 1 Correlation of signals
Pouyan Ebrahimbabaie Laboratory for Signal and Image Exploitation (INTELSIG)
- Dept. of Electrical Engineering and Computer Science
University of Liège Liège, Belgium Applied digital signal processing (ELEN0071-1) 19 February 2020
MATLAB tutorial series (Part 1.2)
SLIDE 2 Motivation
- We wish to measure the similarity between a
signal of interest and a reference signal.
2
SLIDE 3 Motivation
- We wish to measure the similarity between a
signal of interest and a reference signal.
3
SLIDE 4 Motivation
- We wish to measure the similarity between a
signal of interest and a reference signal.
4
SLIDE 5 Correlation signal πππ π = ΰ·
π=ββ β
π π Γ π π β π β β < π < β
5
Correlation signal (main formula):
SLIDE 6
Correlation signal πππ π = ΰ·
π=ββ β
π π Γ π π β π β β < π < β Correlation signal (main formula): It is certainly not a convolution!
SLIDE 7 Correlation signal πππ π = ΰ·
π=ββ β
π π Γ π π β π β β < π < β
7
Correlation signal (main formula): It is certainly not a convolution! Alternative formula: πππ π = π π β π[βπ]
SLIDE 8 Correlation signal πππ π = ΰ·
π=ββ β
π π Γ π π β π β β < π < β
8
Correlation signal (main formula): It is certainly not a convolution! Alternative formula: πππ π = π π β π[βπ] Normalized correlation: βπ β€ πππ[π] β πππ π ππ ππ β€ π
SLIDE 9 How does it work?!
9
Example 1: let π π = π
π π β ππ , π
> π
SLIDE 10 How does it work?!
10
Example 1: let π π = π
π π β ππ , π
> π πππ π π π ππ
SLIDE 11 How does it work?!
11
Example 1: let π π = π
π π β ππ , π
> π β πππ ππ = π . πππ π π π ππ
SLIDE 12 How does it work?!
12
Example 2: let π π and π π be two uncorrelated signal. πππ π π π
SLIDE 13
Autocorrelation Autocorrelation is the correlation of signal with itself. ππ π = π π β π[βπ]
SLIDE 14
Autocorrelation Autocorrelation is the correlation of signal with itself. ππ π = π π β π[βπ] Wiener-Khintchine theorem: ππ π = π π β π βπ
ππππ πΊπ π = π(πππ) π
SLIDE 15
Numerical computation of correlation signal Cross correlation: MATLAB function: [rxy,Lag]=xcorr(x,y) % returns cross-correlation
rxy=conv(x,flipud(y)) % alternative method
πππ π = ΰ·
π=ββ β
π π Γ π π β π β β < π < β
SLIDE 16
Echo π π = π[π]
SLIDE 17
Echo π π = π[π]
SLIDE 18
Echo π π = π π + π π[π β π¬]
SLIDE 19
Echo π π = π π + π π[π β π¬] Attenuation Distance
SLIDE 20
Echo π π = π π + π π[π β π¬] β π π = π π + π π π πβπ¬
SLIDE 21
Echo π π = π π + π π[π β π¬] β π π = π π + π π π πβπ¬ β π°[π] = π [π]/π[π] = (π + ππβπ¬) Echo filter:
SLIDE 22
Application (sound) MATLAB functions: [x,Fs]=audioread(βFilename.wavβ)
% Reads audio file and return sampled signal x (all channels), and sampling frequency Fs. sound(x,Fs) % play the sound filter(b,a,x)% filter the signal x using the rational transfer function
SLIDE 23
Example 1.6: play and plot a sound % read audio file .wav [x,Fs]=audioread('Atonment.wav'); % play the sound sound(x,Fs) % plot left or right channel figure(1) plot(x(:,1)) % compute autocorrelation sequence [acorrX,lagX]=xcorr(x(:,1),x(:,1)); % plot autocorrelation function figure(2) plot(lagX,acorrX,'LineWidth',2.5)
SLIDE 24
Example 1.6: play and plot a sound % read audio file .wav [x,Fs]=audioread('Atonment.wav'); % play the sound sound(x,Fs) % plot left or right channel figure(1) plot(x(:,1)) % compute autocorrelation sequence [acorrX,lagX]=xcorr(x(:,1),x(:,1)); % plot autocorrelation function figure(2) plot(lagX,acorrX,'LineWidth',2.5)
SLIDE 25
Example 1.6: play and plot a sound % read audio file .wav [x,Fs]=audioread('Atonment.wav'); % play the sound sound(x,Fs) % plot left or right channel figure(1) plot(x(:,1)) % compute autocorrelation sequence [acorrX,lagX]=xcorr(x(:,1),x(:,1)); % plot autocorrelation function figure(2) plot(lagX,acorrX,'LineWidth',2.5)
SLIDE 26
Example 1.7: generate reverberation % read audio file [x,Fs]=audioread('Atonment.wav'); % delay in seconds (e.g. 0.3, 0.4, 0.5). % play with these! delay=0.2; %alpha (metal room 0.9) alpha=0.6; % delay in samples d=delay*Fs; % echo filter coefficents b=1; a=[1, zeros(1,d-1), -alpha];
SLIDE 27
Example 1.7: generate reverberation % read audio file [x,Fs]=audioread('Atonment.wav'); % delay in seconds (e.g. 0.3, 0.4, 0.5). % play with these! delay=0.2; %alpha (metal room 0.9) alpha=0.6; % delay in samples d=delay*Fs; % echo filter coefficents b=1; a=[1, zeros(1,d-1), -alpha];
SLIDE 28
Example 1.7: generate reverberation % read audio file [x,Fs]=audioread('Atonment.wav'); % delay in seconds (e.g. 0.3, 0.4, 0.5). % play with these! delay=0.2; %alpha (metal room 0.9) alpha=0.6; % delay in samples d=delay*Fs; % echo filter coefficents b=1; a=[1, zeros(1,d-1), -alpha];
SLIDE 29
Example 1.7: generate reverberation % read audio file [x,Fs]=audioread('Atonment.wav'); % delay in seconds (e.g. 0.3, 0.4, 0.5). % play with these! delay=0.2; %alpha (metal room 0.9) alpha=0.6; % delay in samples d=delay*Fs; % echo filter coefficents b=1; a=[1, zeros(1,d-1), -alpha];
SLIDE 30
Example 1.7: generate reverberation % read audio file [x,Fs]=audioread('Atonment.wav'); % delay in seconds (e.g. 0.3, 0.4, 0.5). % play with these! delay=0.2; %alpha (metal room 0.9) alpha=0.6; % delay in samples d=delay*Fs; % reverberator b=1; a=[1, zeros(1,d-1), -alpha];
SLIDE 31
Example 1.7: generate reverberation % generate signal + reverbration y=filter(b,a,x); % play new sound sound(y,Fs) % compuet autocorrelation [acorrY,lagY]=xcorr(y(:,1),y(:,1)); % plot autocorr of echo % /!\ find delay from autocorrelation signal plot(lagY,acorrY,'LineWidth',2.5)
SLIDE 32
Example 1.7: generate reverberation % generate signal + reverberation y=filter(b,a,x); % play new sound sound(y,Fs) % compuet autocorrelation [acorrY,lagY]=xcorr(y(:,1),y(:,1)); % plot autocorr of echo % /!\ find delay from autocorrelation signal plot(lagY,acorrY,'LineWidth',2.5)
SLIDE 33
Example 1.7: generate reverberation % generate signal + reverberation y=filter(b,a,x); % play new sound sound(y,Fs) % compuet correlation [acorrY,lagY]=xcorr(y(:,1),y(:,1)); % plot autocorr of reverberated signal % /!\ find delay from autocorrelation signal plot(lagY,acorrY,'LineWidth',2.5)
SLIDE 34 Useful links
- https://nl.mathworks.com/help/matlab/ref/audioread.ht
ml
- https://nl.mathworks.com/help/matlab/ref/filter.html
- https://nl.mathworks.com/help/signal/ref/xcorr.html