I would like to implement a convolution between an image and a kernel, somewhat like MATLAB conv2(img, kernel,'same'), which indicates that the result image is the same size as the original image.
Before, I use filter2d, like: filter2D(source, dest, img.depth(), kernel, anchor, 0, borderMode);
However, filter2D is a little bit slow when dealing with large images. That's why I think cv::cuda::Convolution::convolve
might be a little bit faster.
I read the documentation of cv::cuda::Convolution::convolve
virtual void cv::cuda::Convolution::convolve ( InputArray image,
InputArray templ,
OutputArray result,
bool ccorr = false,
Stream & stream = Stream::Null()
)
I am a little bit confused, does the word 'template image' equals to kernel? Also there seems no way to choose the size of the result image (which I would like the result image to be the same size as the original one) and border mode, unlike filter2D.
Really hope there is a cuda::filter2D version.......
So could cv::cuda::Convolution::convolve
do what I want? If cv::cuda::Convolution::convolve
function really can't work for my purpose, then how to use this function?