Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

phase correlation to find shift

Status
Not open for further replies.

keremcant

Member level 5
Member level 5
Joined
Dec 25, 2009
Messages
87
Helped
6
Reputation
12
Reaction score
5
Trophy points
1,288
Visit site
Activity points
1,910
Hello,
So I have a function that has an inverse Lorentzian shape (i.e. -L(x)) and thus it has a local minimum. Now the minimum is at zero, if there is no shift. However as I measure it, the minimum is not exactly at zero, but it is a bit off, i.e. shifted to the left or to the right. What I need is to find this shift. I, of course, don't have the analytical function but the sampled points on it and I assume I can increase the number of samples by interpolation (I use cubic interpolation) without loss of information.
I thought it would be best to use phase correlation to detect this shift.
So now I first take the mirror image of the sampled points I have, thus I have a function that is shifted to the right by s, for example and when I mirror it, I have a function that is shifted to the left by s. And since the Lorentzian is a symmetric function, the both functions look similar except for the location of their minima.
As in wikipedia, https://en.wikipedia.org/wiki/Phase_correlation, I calculate the phase correlation (pc). However the result of phase correlation gives me a delta peak at zero, i.e. no shift.
I couldn't figure out why I don't get the shift between the two signals with phase correlation, the result should be a delta peak at 2*s in my opinion.
You can find my code as below:
Code:
%to generate the lorentzian:
shift=2;
x=-15:0.1:15;
ls=1/pi * 1./((x-shift).^2 + 1^2);
lsi=-ls;%invert
lsi=lsi-min(lsi);
lsi=lsi./lsi(1);%normalize
lsim=flipdim(lsi,2);%mirror
ns=rand(1,301)*0.1;%add noise, optional
lsin=lsi+ns;
lsimn=lsim+ns;

%calculate the phase correlation
pcab=pcorr(lsi,lsim);
plot(x,fftshift(pcab));

%the pcorr funtion:
function [pc] = pcorr(f1,f2);
F1=fft(f1);
F2=fft(f2);
F2c=conj(F2);
PC=F1.*F2c./abs(F1.*F2c);
pc=ifft(PC);

When I do it theoretically, I get the shift, however not in practice.
Any help appreciated, thanks in advance.
Kerem
 
Last edited:

Hello Adem,

I couldn't understand the relation of your question to mine. I have no compression, just the normal images.

If you are asking a question yourself, the best way is to that you rather start a new thread and being more specific about your question usually helps, what kind of compression etc...

Take care,
Kerem
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top