I am using MATLAB to calculate cross-correlation between images. I have two 132*1024 images that are more or less the same, but one being shifted alongside the Y axis by somewhat like 50-70 pixels, and maybe a few pixels (<10) alongisde the X axis.
I used the xcorr2
function to calculate the cross-correlation matrix, so I end up with a 263*2047 matrix, which I can easily 3D-plot using mesh
. The surface plot looks perfectly fine but what I don't uderstand is : how do I find the "shift value" in pixels ? The max of the xcorr2
matrix is at [130, 987] and I don't know how to relate this to the expected result that should be something like [50, 5].
Thanks a lot !
EDIT : I don't want to use the imregister
method that has been proposed. My goal is to compare the xcorr2
fuction with a cross-correlation code I made myself in C#.