Ask Your Question
0

cross-correlation of 2 same sized images

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

anatrong0 gravatar image

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

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
2

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

LBerger gravatar image

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

Finally it is function filter2d

edit flag offensive delete link more

Comments

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 -0600 )edit
0

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

anatrong0 gravatar image

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

to cross-correlate same size images:

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

//MULTIPLY CONJUGATE
cv::cuda::mulSpectrums(G_image1,G_image2,G_image1,true);    

//BACKWARD TRANSFORM
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

Comments

I don't think you need DFT_SCALE twice

LBerger gravatar imageLBerger ( 2015-09-10 01:12:01 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 8,571 times

Last updated: Sep 09 '15