[−][src]Function opencv::imgproc::phase_correlate
pub fn phase_correlate(
src1: &dyn ToInputArray,
src2: &dyn ToInputArray,
window: &dyn ToInputArray,
response: &mut f64
) -> Result<Point2d>
The function is used to detect translational shifts that occur between two images.
The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see http://en.wikipedia.org/wiki/Phase_correlation
Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with getOptimalDFTSize.
The function performs the following equations:
- First it applies a Hanning window (see http://en.wikipedia.org/wiki/Hann_function) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
- Next it computes the forward DFTs of each source array: where is the forward DFT.
- It then computes the cross-power spectrum of each frequency domain array:
- Next the cross-correlation is converted back into the time domain via the inverse DFT:
- Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.
- If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.
Parameters
- src1: Source floating point array (CV_32FC1 or CV_64FC1)
- src2: Source floating point array (CV_32FC1 or CV_64FC1)
- window: Floating point array with windowing coefficients to reduce edge effects (optional).
- response: Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional).
Returns
detected phase shift (sub-pixel) between the two arrays.
See also
dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
C++ default parameters
- window: noArray()
- response: 0