# What Does It Mean When Cross Correlation Between Two Images Occur at Negative Coordinates

I am using Matlab normxcorr2 to calculate the cross correlation between several images, something like what has been done here: in MATLAB documentation. There are some of the examples that I get negative values for xoffSet and yoffSet, but I am not sure what it means when these values are negative.

Another issue, is practical since I need to give these xoffSet and yoffSet values as an input to coordinates of rectangle in an image, but since these are negative, the function throws an error. I googled it but no success in finding something that can explain such thing. I was thinking of just putting zero instead of negative values, but I'm not sure if that's a right approach.

I would appreciate if someone can explain about the meaning of such negative values and how I can substitute such negative values with appropriate quantities.

• Welcome to DSP.SE! It sounds like the coordinates your call to peak is returning is in the padding area added by normxcorr2. Are you sure you are giving the yoffSet = ypeak-size(onion,1); call the correct image (i.e. your onion patch image).
– Peter K.
Sep 13 '17 at 16:05
• Thank you for your comment! Basically, to find yoffSet, and xoffSet, I need to subtract the first and second dimensions of the template image (the image with the smaller size), respectively, from ypeak and xpeak. So, the answer is yes. Sep 13 '17 at 16:11