I am using Phase Correlation to register 3D data. There's a clear distinction in the y direction so the resulting shifts seem to be correct. But since there is a lot of similarity in the x direction therefore resulting in spikes. Does anyone have suggestions on any processing techniques that could help get better results.
This is my phase correlation code at the moment.
function peak = PhaseCorrelation(fftr, tar) dim = GetPad(fftr); fftt = fftn(tar, dim); % calculate the power spectrum to remove the magnitude cp_vol = CrossPowerSpectrum(fftr, fftt); % go back to the time domain and find the peak shift_vol = ifftn(cp_vol); shift_vol = fftshift(shift_vol); shift_vol = imgaussfilt(abs(shift_vol), 5); [~, ind] = max(abs(shift_vol(:))); [xsh, ysh, zsh] = ind2sub(size(shift_vol), ind); peak = [xsh, ysh, zsh]; peak = GetOffsetShift(peak, dim); end function [shift] = GetOffsetShift(peak, dim) shift(1:2) = (peak(1:2) - dim(1:2)/2) - 1; if length(dim) == 3 % 3D shifts if peak(3) > dim(3)/2 shift(3) = (peak(3) - dim(3)/2); else shift(3) = (peak(3) + dim(3)/2); end else % 2D shifts % dont have to change the shift of the third dimension shift(3) = peak(3); end function [res] = CrossPowerSpectrum(A, B) y = A.*conj(B); scale = abs(y); res = y./scale; end function [new_dim] = GetPad(ref) dim = nextpow2(size(ref)); new_dim = 2.^dim; end