For calculating the correlation with fast Fourier Transform (FFT) a class is set up.
piv.fft_correlator.
FFTCorrelator
(window_a_size, window_b_size, scale_fft='default')[source]¶An FFT Correlation Class for a PIV Evaluation of two frames It uses the pyfftw library for performant FFT. This class is also responsible for calculating the Shift after the correlation.
Initialize fftw objects for FFTs with the pyfftw library
The necessary functions are loaded and memory allocated.
Parameters: |
|
---|
If the window size does not meet the needs of the FFT function, the windows get padded with zeros.
By calling the function for the getting the displacement the correlation is performed as well
FFTCorrelator.
get_displacement
(window_a, window_b, subpixel_method='gaussian')[source]¶Compute the displacement out of correlation.
First the correlation is performed and afterwards the shift is calculated. For the displacement calculation the function
find_peak
(corr, method='gaussian')¶Peak detection algorithm switch
After loading the correlation window an maximum finder is invoked. The correlation window is cut down to the necessary 9 points around the maximum. Afterwards the maximum is checked not to be close to the boarder of the correlation frame. This cropped window is used in along with the chosen method to interpolate the sub pixel shift. Each interpolation method returns a tuple with the sub pixel shift in x and y direction. The maximums position and the sub pixel shift are added and returned. If an error occurred during the sub pixel interpolation the shift is set to nan. Also if the interpolation method is unknown an exception in thrown.
Parameters: |
|
---|---|
Raises: | Sub pixel interpolation method not found |
Returns: | shift in interrogation window |
is called with the subpixel_method passed on as parameter. If a padding was needed, it is removed from the calculated displacement.
Parameters: |
|
---|---|
Returns: | shift in x and y direction as tuple |
FFTCorrelator.
_evaluate_windows
(window_a, window_b)[source]¶Calculate the FFT of both windows, correlate and transform back.
In order to decrease the error a mean subtraction is performed. To compensate for the indexing during the FFT a FFT Shift is performed.
Parameters: |
|
---|---|
Returns: | correlation window |