phasecorr_doc.patch

Will Lucas, 2012-06-05 12:09 am

Download (3 kB)

 
modules/imgproc/doc/motion_analysis_and_object_tracking.rst (working copy)
144 144

  
145 145
phaseCorrelate
146 146
--------------
147
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 esitimation. For more information please see http://en.wikipedia.org/wiki/Phase\_correlation .
147
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 esitimation. For more information, please see http://en.wikipedia.org/wiki/Phase\_correlation .
148 148

  
149 149
Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with :ocv:func:`getOptimalDFTSize`.
150 150

  
......
158 158

  
159 159
The function performs the following equations
160 160

  
161
*
162
    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.
161
* 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.
163 162

  
164
*
165
    Next it computes the forward DFTs of each source array:
166
    .. math::
163
* Next it computes the forward DFTs of each source array:
167 164

  
165
.. math::
166

  
168 167
        \mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}
169 168

  
170
    where
171
    :math:`\mathcal{F}` is the forward DFT.
169
where
170
:math:`\mathcal{F}` is the forward DFT.
172 171

  
173
*
174
    It then computes the cross-power spectrum of each frequency domain array:
175
    .. math::
172
* It then computes the cross-power spectrum of each frequency domain array:
176 173

  
174
.. math::
175

  
177 176
        R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}
178 177

  
179
*
180
    Next the cross-correlation is converted back into the time domain via the inverse DFT:
181
    .. math::
178
* Next the cross-correlation is converted back into the time domain via the inverse DFT:
182 179

  
180
.. math::
181

  
183 182
        r = \mathcal{F}^{-1}\{R\}
184
*
185
    Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.
186
    .. math::
187 183

  
188
       (\Delta x, \Delta y) = \texttt{weighted_centroid}\{\arg \max_{(x, y)}\{r\}\}
184
* Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.
189 185

  
186
.. math::
187

  
188
       (\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\} 
189

  
190 190
.. seealso::
191 191
    :ocv:func:`dft`,
192 192
    :ocv:func:`getOptimalDFTSize`,