After going through the manual alignment of the point cloud data noted in the last post, I've gotten the translation step of automatic alignment using phase correlation.
Phase correlation requires the use of a 2d fft, which I couldn't find in Processing (would have to bring in a java lib for that somehow?). Instead I used Octave, which has the fft2, inverse ifft2 function, and many other convenient math functions. The Matlab/Octave file is here.
The fundamental phase correlation code is this:
a = imread('one.png')
b = imread('two.png')
af = fft2(a);
bf = fft2(b);
% cross power
cp = af.*conj(bf) ./ abs(af.*conj(bf));
icp = (ifft2(cp));
mmax = max(max(icp));
[sx,sy,v] = find(mmax == icp);
And sx and sy are the translation to apply to b to make it line up with image a. An additional check is to make sure the largest value in icp is above some threshold- if it is lower than the threshold then there is no good translation to align the data.
I'm a little suspicious that my input pngs are too regular and easy, every frame seems a constant displacement from the former as the vehicle with the lidar was moving at a constant velocity.
Rotation is mostly working in isolation but I need to revisit the proper method to make simultaneous rotation and translation work- there was a paper somewhere I need to dig up.
Post a Comment