Ask Your Question

cross-correlation of 2 same sized images

asked 2015-08-23 18:36:57 -0500

anatrong0 gravatar image

updated 2015-08-23 19:01:09 -0500

Is there a way to compute full cross-correlation (or phase correlation) for two images of same size?

-resulting image should be same size as 2 source images. Convolution will only give me one pixel image the way it is implemented.

Or do I have to compute it by dft and therefore code it manually? Essentially I am looking for subpixel template matching (for 2 same sized images where an object within shifts)

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-08-24 02:23:34 -0500

LBerger gravatar image

updated 2015-08-28 10:55:21 -0500

Finally it is function filter2d

edit flag offensive delete link more


Thanks, other software I used did not say how is the cross-correlation produced. I realised you just need to zero pad one of the images and use openCV convolution(ccor=true)

anatrong0 gravatar imageanatrong0 ( 2015-08-28 10:10:38 -0500 )edit

answered 2015-09-09 13:46:04 -0500

anatrong0 gravatar image

updated 2015-09-09 13:48:57 -0500

to cross-correlate same size images:

cv::cuda::dft(image1, G_image1, Size(SIZE,SIZE), DFT_SCALE);        
cv::cuda::dft(image2, G_image2, Size(SIZE,SIZE), DFT_SCALE);        


cv::cuda::dft(G_image1,RESULT,Size(SIZE,SIZE),DFT_REAL_OUTPUT | DFT_SCALE);
  • result in unscaled cross-correlation
  • to scale between (-1,1): normalize source images to have mean(src's) = 0, StdDev(src's) = 1 before computation
edit flag offensive delete link more


I don't think you need DFT_SCALE twice

LBerger gravatar imageLBerger ( 2015-09-10 01:12:01 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-08-23 18:36:57 -0500

Seen: 4,276 times

Last updated: Sep 09 '15