Correlation of signals MATLAB tutorial series (Part 1.2) Pouyan - - PowerPoint PPT Presentation

β–Ά
correlation of signals
SMART_READER_LITE
LIVE PREVIEW

Correlation of signals MATLAB tutorial series (Part 1.2) Pouyan - - PowerPoint PPT Presentation

Correlation of signals MATLAB tutorial series (Part 1.2) Pouyan Ebrahimbabaie Laboratory for Signal and Image Exploitation (INTELSIG) Dept. of Electrical Engineering and Computer Science University of Lige Lige, Belgium Applied digital


slide-1
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
SLIDE 2

Motivation

  • We wish to measure the similarity between a

signal of interest and a reference signal.

2

slide-3
SLIDE 3

Motivation

  • We wish to measure the similarity between a

signal of interest and a reference signal.

3

slide-4
SLIDE 4

Motivation

  • We wish to measure the similarity between a

signal of interest and a reference signal.

4

slide-5
SLIDE 5

Correlation signal π’”π’šπ’› π’Ž = ෍

𝒐=βˆ’βˆž ∞

π’š 𝒐 Γ— 𝒛 𝒐 βˆ’ π’Ž βˆ’ ∞ < π’Ž < ∞

5

Correlation signal (main formula):

slide-6
SLIDE 6

Correlation signal π’”π’šπ’› π’Ž = ෍

𝒐=βˆ’βˆž ∞

π’š 𝒐 Γ— 𝒛 𝒐 βˆ’ π’Ž βˆ’ ∞ < π’Ž < ∞ Correlation signal (main formula): It is certainly not a convolution!

slide-7
SLIDE 7

Correlation signal π’”π’šπ’› π’Ž = ෍

𝒐=βˆ’βˆž ∞

π’š 𝒐 Γ— 𝒛 𝒐 βˆ’ π’Ž βˆ’ ∞ < π’Ž < ∞

7

Correlation signal (main formula): It is certainly not a convolution! Alternative formula: π’”π’šπ’› π’Ž = π’š π’Ž βˆ— 𝒛[βˆ’π’Ž]

slide-8
SLIDE 8

Correlation signal π’”π’šπ’› π’Ž = ෍

𝒐=βˆ’βˆž ∞

π’š 𝒐 Γ— 𝒛 𝒐 βˆ’ π’Ž βˆ’ ∞ < π’Ž < ∞

8

Correlation signal (main formula): It is certainly not a convolution! Alternative formula: π’”π’šπ’› π’Ž = π’š π’Ž βˆ— 𝒛[βˆ’π’Ž] Normalized correlation: βˆ’πŸ ≀ π‡π’šπ’›[π’Ž] β‰œ π’”π’šπ’› π’Ž π‘­π’š 𝑭𝒛 ≀ 𝟐

slide-9
SLIDE 9

How does it work?!

9

Example 1: let π’š 𝒐 = 𝒅𝒛 𝒐 βˆ’ π’πŸ , 𝒅 > 𝟏

slide-10
SLIDE 10

How does it work?!

10

Example 1: let π’š 𝒐 = 𝒅𝒛 𝒐 βˆ’ π’πŸ , 𝒅 > 𝟏 π‡π’šπ’› π’Ž 𝟐 π’Ž π’πŸ

slide-11
SLIDE 11

How does it work?!

11

Example 1: let π’š 𝒐 = 𝒅𝒛 𝒐 βˆ’ π’πŸ , 𝒅 > 𝟏 β†’ π‡π’šπ’› π’πŸ = 𝟐 . π‡π’šπ’› π’Ž 𝟐 π’Ž π’πŸ

slide-12
SLIDE 12

How does it work?!

12

Example 2: let π’š 𝒐 and 𝒛 𝒐 be two uncorrelated signal. π‡π’šπ’› π’Ž 𝟐 π’Ž

slide-13
SLIDE 13

Autocorrelation Autocorrelation is the correlation of signal with itself. π’”π’š π’Ž = π’š π’Ž βˆ— π’š[βˆ’π’Ž]

slide-14
SLIDE 14

Autocorrelation Autocorrelation is the correlation of signal with itself. π’”π’š π’Ž = π’š π’Ž βˆ— π’š[βˆ’π’Ž] Wiener-Khintchine theorem: π’”π’š π’Ž = π’š π’Ž βˆ— π’š βˆ’π’Ž

𝐄𝐔𝐆𝐔 π‘Ίπ’š 𝝏 = 𝒀(π’‡π’Œπ) πŸ‘

slide-15
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
SLIDE 16

Echo 𝒛 𝒐 = π’š[𝒐]

slide-17
SLIDE 17

Echo 𝒛 𝒐 = π’š[𝒐]

slide-18
SLIDE 18

Echo 𝒛 𝒐 = π’š 𝒐 + 𝒃 π’š[𝒐 βˆ’ 𝑬]

slide-19
SLIDE 19

Echo 𝒛 𝒐 = π’š 𝒐 + 𝒃 π’š[𝒐 βˆ’ 𝑬] Attenuation Distance

slide-20
SLIDE 20

Echo 𝒛 𝒐 = π’š 𝒐 + 𝒃 𝒛[𝒐 βˆ’ 𝑬] β†’ 𝒁 π’œ = 𝒀 π’œ + 𝒃 𝒀 π’œ π’œβˆ’π‘¬

slide-21
SLIDE 21

Echo 𝒛 𝒐 = π’š 𝒐 + 𝒃 𝒛[𝒐 βˆ’ 𝑬] β†’ 𝒁 π’œ = 𝒀 π’œ + 𝒃 𝒀 π’œ π’œβˆ’π‘¬ β†’ 𝑰[π’œ] = 𝒁 [π’œ]/𝒀[π’œ] = (𝟐 + π’ƒπ’œβˆ’π‘¬) Echo filter:

slide-22
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
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
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
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
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
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
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
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
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
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
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
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
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