Phase correlation
Estimate translation from the phase relationship between two images in the frequency domain.
Orange is shifted seven samples relative to violet.
A translation changes Fourier phase while preserving the magnitudes in this ideal periodic example.
The normalized product isolates the relative phase; this plot shows the real component for a seven-sample shift.
The ideal inverse transform concentrates the response at the displacement. Real images produce a broader, noisy peak.
Transform back and locate the correlation peak.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Estimate a global translation between grayscale images, then align the second image to the first.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Measure global image shifts, stabilize a translating scene, or compare log-polar representations.
How it works
- 01Transform both images into the frequency domain.
- 02Normalize their cross-power spectrum.
- 03Transform back and locate the correlation peak.
R = (F1 · conjugate(F2)) / |F1 · conjugate(F2)|
What to tune
Use matching single-channel float images. The response score measures peak concentration and should be checked alongside the shift.
Where it breaks down
Changing content, occlusion and periodic texture weaken the estimate. Windowing helps reduce discontinuities at the image boundary.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Template matching
Slide a patch across an image and score how well it agrees at each location.
ECC alignment
Refine a warp by maximizing enhanced correlation between an image and a template.
Brute-force descriptor matching
Compare each query descriptor with every training descriptor using a chosen distance.
FLANN nearest neighbours
Organize descriptors so nearest-neighbour queries can avoid an exhaustive scan.