0
votes

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#.

1
This is very clearly explained in the documentation: mathworks.com/help/signal/ref/xcorr2.htmlCris Luengo

1 Answers

0
votes

What you are dealing with here is a quite simple rigid registration problem.

Use the imregister method to register the two images (you can specify that only translation–movement in x/y–is allowed; rigid stands for translation+rotation).

https://www.mathworks.com/help/images/ref/imregister.html