OpenCV  3.4.13-dev Open Source Computer Vision
Arithm Operations on Matrices

## Classes

class  cv::cuda::Convolution
Base class for convolution (or cross-correlation) operator. : More...

class  cv::cuda::DFT
Base class for DFT operator as a cv::Algorithm. : More...

## Functions

Ptr< Convolutioncv::cuda::createConvolution (Size user_block_size=Size())
Creates implementation for cuda::Convolution . More...

Ptr< DFTcv::cuda::createDFT (Size dft_size, int flags)
Creates implementation for cuda::DFT. More...

void cv::cuda::dft (InputArray src, OutputArray dst, Size dft_size, int flags=0, Stream &stream=Stream::Null())
Performs a forward or inverse discrete Fourier transform (1D or 2D) of the floating point matrix. More...

void cv::cuda::gemm (InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags=0, Stream &stream=Stream::Null())
Performs generalized matrix multiplication. More...

void cv::cuda::mulAndScaleSpectrums (InputArray src1, InputArray src2, OutputArray dst, int flags, float scale, bool conjB=false, Stream &stream=Stream::Null())
Performs a per-element multiplication of two Fourier spectrums and scales the result. More...

void cv::cuda::mulSpectrums (InputArray src1, InputArray src2, OutputArray dst, int flags, bool conjB=false, Stream &stream=Stream::Null())
Performs a per-element multiplication of two Fourier spectrums. More...

## ◆ createConvolution()

 Ptr cv::cuda::createConvolution ( Size user_block_size = Size() )

#include <opencv2/cudaarithm.hpp>

Creates implementation for cuda::Convolution .

Parameters
 user_block_size Block size. If you leave default value Size(0,0) then automatic estimation of block size will be used (which is optimized for speed). By varying user_block_size you can reduce memory requirements at the cost of speed.

## ◆ createDFT()

 Ptr cv::cuda::createDFT ( Size dft_size, int flags )

#include <opencv2/cudaarithm.hpp>

Creates implementation for cuda::DFT.

Parameters
 dft_size The image size. flags Optional flags: DFT_ROWS transforms each individual row of the source matrix. DFT_SCALE scales the result: divide it by the number of elements in the transform (obtained from dft_size ). DFT_INVERSE inverts DFT. Use for complex-complex cases (real-complex and complex-real cases are always forward and inverse, respectively). DFT_COMPLEX_INPUT Specifies that inputs will be complex with 2 channels. DFT_REAL_OUTPUT specifies the output as real. The source matrix is the result of real-complex transform, so the destination matrix must be real.

## ◆ dft()

 void cv::cuda::dft ( InputArray src, OutputArray dst, Size dft_size, int flags = 0, Stream & stream = Stream::Null() )

#include <opencv2/cudaarithm.hpp>

Performs a forward or inverse discrete Fourier transform (1D or 2D) of the floating point matrix.

Parameters
 src Source matrix (real or complex). dst Destination matrix (real or complex). dft_size Size of a discrete Fourier transform. flags Optional flags: DFT_ROWS transforms each individual row of the source matrix. DFT_SCALE scales the result: divide it by the number of elements in the transform (obtained from dft_size ). DFT_INVERSE inverts DFT. Use for complex-complex cases (real-complex and complex-real cases are always forward and inverse, respectively). DFT_COMPLEX_INPUT Specifies that input is complex input with 2 channels. DFT_REAL_OUTPUT specifies the output as real. The source matrix is the result of real-complex transform, so the destination matrix must be real. stream Stream for the asynchronous version.

Use to handle real matrices ( CV32FC1 ) and complex matrices in the interleaved format ( CV32FC2 ).

The source matrix should be continuous, otherwise reallocation and data copying is performed. The function chooses an operation mode depending on the flags, size, and channel count of the source matrix:

• If the source matrix is complex and the output is not specified as real, the destination matrix is complex and has the dft_size size and CV_32FC2 type. The destination matrix contains a full result of the DFT (forward or inverse).
• If the source matrix is complex and the output is specified as real, the function assumes that its input is the result of the forward transform (see the next item). The destination matrix has the dft_size size and CV_32FC1 type. It contains the result of the inverse DFT.
• If the source matrix is real (its type is CV_32FC1 ), forward DFT is performed. The result of the DFT is packed into complex ( CV_32FC2 ) matrix. So, the width of the destination matrix is dft_size.width / 2 + 1 . But if the source is a single column, the height is reduced instead of the width.
dft

## ◆ gemm()

 void cv::cuda::gemm ( InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags = 0, Stream & stream = Stream::Null() )

#include <opencv2/cudaarithm.hpp>

Performs generalized matrix multiplication.

Parameters
 src1 First multiplied input matrix that should have CV_32FC1 , CV_64FC1 , CV_32FC2 , or CV_64FC2 type. src2 Second multiplied input matrix of the same type as src1 . alpha Weight of the matrix product. src3 Third optional delta matrix added to the matrix product. It should have the same type as src1 and src2 . beta Weight of src3 . dst Destination matrix. It has the proper size and the same type as input matrices. flags Operation flags: GEMM_1_T transpose src1 GEMM_2_T transpose src2 GEMM_3_T transpose src3 stream Stream for the asynchronous version.

The function performs generalized matrix multiplication similar to the gemm functions in BLAS level

1. For example, gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T) corresponds to

$\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T$

Note
Transposition operation doesn't support CV_64FC2 input type.
gemm

## ◆ mulAndScaleSpectrums()

 void cv::cuda::mulAndScaleSpectrums ( InputArray src1, InputArray src2, OutputArray dst, int flags, float scale, bool conjB = false, Stream & stream = Stream::Null() )

#include <opencv2/cudaarithm.hpp>

Performs a per-element multiplication of two Fourier spectrums and scales the result.

Parameters
 src1 First spectrum. src2 Second spectrum with the same size and type as a . dst Destination spectrum. flags Mock parameter used for CPU/CUDA interfaces similarity, simply add a 0 value. scale Scale constant. conjB Optional flag to specify if the second spectrum needs to be conjugated before the multiplication. stream Stream for the asynchronous version.

Only full (not packed) CV_32FC2 complex spectrums in the interleaved format are supported for now.

mulSpectrums

## ◆ mulSpectrums()

 void cv::cuda::mulSpectrums ( InputArray src1, InputArray src2, OutputArray dst, int flags, bool conjB = false, Stream & stream = Stream::Null() )

#include <opencv2/cudaarithm.hpp>

Performs a per-element multiplication of two Fourier spectrums.

Parameters
 src1 First spectrum. src2 Second spectrum with the same size and type as a . dst Destination spectrum. flags Mock parameter used for CPU/CUDA interfaces similarity. conjB Optional flag to specify if the second spectrum needs to be conjugated before the multiplication. stream Stream for the asynchronous version.

Only full (not packed) CV_32FC2 complex spectrums in the interleaved format are supported for now.