[Numpy-discussion] shift for optimal superimposition of two 3D matrices according to correlation computed using FFT
Klaus Kopec
klaus.kopec at tuebingen.mpg.de
Tue Apr 7 11:56:21 EDT 2009
Hello everybody,
I have two 3D density maps (meaning volumetric data, each one
essentially a IxJxK matrix containing real values that sum to one) and
want to find translation of between the two that maximises correlation.
This can be done by computing the correlation between the two
(correlation theorem -> I use FFT for this) and then shifting one of the
two maps by the vector that corresponds to the index of the maximum in
the 3D correlation matrix.
My problem with this method is, however, that the shift wraps around the
edges of the matrix. e.g: for a 30x30x30 matrix that needs to be
slightly shifted to fit the seconds 3D matrix, sometimes shift vectors
like (0, 29, 0) appear, that actually mean a shift by (0, -1, 0). This
means that the size of the matrix needs to be subtracted from some
components of the shift vector in special cases.
So far, I have been unable to determine the cutoff value, outside of
which I need to subtract the matrix size from a component of the shift
vector, as this cutoff seems to vary between different data sets.
Can anybody help me out with this? Best regards,
Klaus
More information about the NumPy-Discussion
mailing list