You're here: Home / OpenCV /

Phase Correlation Function in OpenCV

Phase Correlation is a method to check the similarity of two images with equal size. It can be used for template matching, object tracking, motion estimation, etc.

To perform phase correlation, follow these steps:

  1. Load two images, f and g
  2. Perform FFT on each image, resulting in F and G
  3. Obtain the cross power spectrum using this formula:
    cross power spectrum formula
    where G bar is the complex conjugate of G.
  4. Obtain the phase correlation by performing IFFT on R

The result is a 2D array with each element has a value between 0 to 1. The location of the highest value corresponds with the object translation movement from image 1 to image 2.

Here are some results I've got when computing phase correlation:

#     Image 1 Image 2 Result
1.

image 1

image 2

(Image 2 is identical
with image 1)

Max. value = 1.0
in (0,0)
2.

image 1

image 2

(image 1 with some noise)

Max. value = 0.2729
in (0,0)
3.

image 1

image 2

(object moved 6 pixels to
the right and 15 pixels to
the bottom)

Max. value = 0.6344
in (6,15)

Keywords: phase only correlation, phase correlation, poc, phase correlation in opencv, phase correlation examples

Share:  del.icio.us logo Save to del.icio.us  digg logo Digg this!

comment.gifAdd your comment

(required, will not be published) (optional)