去除相位差的整数移位

时间:2017-03-19 05:26:03

标签: matlab image-processing signal-processing

我想从两个图像之间的相位差theta(k1,k2)中删除整数偏移。从下图中可以看出,它是一个锯齿信号。

enter image description here

因此,为了获得仅十进制移位的相位差,我需要从原始相位中减去整数移位。那是theta_decimal=theta-theta_int。由于整数移位(IntShift=[dx; dy])是使用相位相关确定的,因此根据本文:基于相位区域最小二乘近似的图像亚像素移位估计 Fujimoto,Fujisawa和Ikehara (第26届欧洲信号处理会议论文集,EUSIPCO '16,第91-95页.IEEE,2016 PDF,等式(14),整数移位可以通过找到相位相关偏移的斜率。也就是theta_decimal=theta-(a*k1+b*k2),其中ab是整数移位的斜率。

减法的结果将给出相位差,如下所示:

enter image description here

问题是我如何获得第一手斜率? 这是我的matlab代码的一部分,我没能得到准确的转变:

    f = im2double(imread('cameraman.tif')); %Reference image
    deltar = -3.48574;
    deltac = 8.73837;
    phase = 2;
    [nr,nc]=size(f);
    Nr = ifftshift((-fix(nr/2):ceil(nr/2)-1));
    Nc = ifftshift((-fix(nc/2):ceil(nc/2)-1));
    [Nc,Nr] = meshgrid(Nc,Nr);
    g = ifft2(fft2(f).*exp(1i*2*pi*(deltar*Nr/nr+deltac*Nc/nc))).*exp(-1i*phase); %Shifted image

    [m, n]=size(f);

    F=(fft2(double(f)));
    G=(fft2(double(g)));

    R=(F.*conj(G))./abs(F.*conj(G));
    r=(ifft2(R));

    [~,w] = max(r(:));
    [del_hat2p, del_hat1p] = ind2sub(size(r),w);

    if del_hat1p<m/2, del_hat1p=-(del_hat1p-1); else, del_hat1p=m-(del_hat1p-1); end
    if del_hat2p<n/2, del_hat2p=-(del_hat2p-1); else, del_hat2p=n-(del_hat2p-1); end

    IntShift=[del_hat1p;del_hat2p];

    theta=angle(F)-angle(G);
    R=exp(1j*theta); 
    theta=atan2(imag(R),real(R)); %Here's the theta
    [ap, bp, theta_int]=lsa(theta);
    theta_decimal=theta-theta_int
    figure; surf(theta);
    figure; surf(theta_decimal); %Still not right

    %actual case should be like this thatap=theta-(integer shift)
    %thetapp=theta-(IntShift); %You can refer equation 14 in the paper
    %surf(thetapp);

function [ a, b, hat ] = lsa( theta )
[m, n]=size(theta);
[M,N] = meshgrid(1:m,1:n);
X = [M(:), N(:)];
B=regress(theta(:), X);
a=B(1);
b=B(2);
hat=reshape(X*B,m,n);
end

如何在matlab中正确完成?谢谢!

0 个答案:

没有答案