Arithm Operations on Matrices
Overview
// classes class cv::cuda::Convolution; class cv::cuda::DFT; // global functions Ptr<Convolution> cv::cuda::createConvolution(Size user_block_size = Size()); Ptr<DFT> cv::cuda::createDFT( Size dft_size, int flags ); void cv::cuda::dft( InputArray src, OutputArray dst, Size dft_size, int flags = 0, Stream& stream = Stream::Null() ); void cv::cuda::gemm( InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags = 0, Stream& stream = Stream::Null() ); void cv::cuda::mulAndScaleSpectrums( InputArray src1, InputArray src2, OutputArray dst, int flags, float scale, bool conjB = false, Stream& stream = Stream::Null() ); void cv::cuda::mulSpectrums( InputArray src1, InputArray src2, OutputArray dst, int flags, bool conjB = false, Stream& stream = Stream::Null() );
Detailed Documentation
Global Functions
Ptr<Convolution> cv::cuda::createConvolution(Size user_block_size = Size())
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. |
Ptr<DFT> cv::cuda::createDFT( Size dft_size, int flags )
Creates implementation for cuda::DFT.
Parameters:
dft_size | The image size. |
flags | Optional flags:
|
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.
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.
Parameters:
src | Source matrix (real or complex). |
dst | Destination matrix (real or complex). |
dft_size | Size of a discrete Fourier transform. |
flags | Optional flags:
|
stream | Stream for the asynchronous version. |
See also:
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.
The function performs generalized matrix multiplication similar to the gemm functions in BLAS level
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\]
Transposition operation doesn’t support CV_64FC2 input type.
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:
|
stream | Stream for the asynchronous version. |
See also:
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.
Only full (not packed) CV_32FC2 complex spectrums in the interleaved format are supported for now.
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. |
See also:
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.
Only full (not packed) CV_32FC2 complex spectrums in the interleaved format are supported for now.
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. |
See also: