fft_convolve#

pyrost.bin.fft_convolve(array: numpy.ndarray, kernel: numpy.ndarray, axis: int = - 1, mode: str = 'constant', cval: float = 0.0, backend: str = 'numpy', num_threads: int = 1)#

Convolve a multi-dimensional array with one-dimensional kernel along the axis by means of FFT. Output has the same size as array.

Parameters
  • array (numpy.ndarray) – Input array.

  • kernel (numpy.ndarray) – Kernel array.

  • axis (int) – Array axis along which convolution is performed.

  • mode (str) –

    The mode parameter determines how the input array is extended when the filter overlaps a border. Default value is ‘constant’. The valid values and their behavior is as follows:

    • constant, (k k k k | a b c d | k k k k) : The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.

    • nearest, (a a a a | a b c d | d d d d) : The input is extended by replicating the last pixel.

    • mirror, (c d c b | a b c d | c b a b) : The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.

    • reflect, (d c b a | a b c d | d c b a) : The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.

    • wrap, (a b c d | a b c d | a b c d) : The input is extended by wrapping around to the opposite edge.

  • cval (float) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0.

  • backend (str) – Choose between numpy (‘numpy’) or FFTW (‘fftw’) library for the FFT implementation.

  • num_threads (int) – Number of threads used in the calculations.

Raises
Returns

A multi-dimensional array containing the discrete linear convolution of array with kernel.

Return type

numpy.ndarray