Ask Your Question

junyan's profile - activity

2015-12-25 15:52:34 -0600 received badge  Supporter (source)
2015-12-25 15:52:21 -0600 commented answer how to use cv::cuda::Convolution::convolve in opencv?

Thank you for replying! And how to choose the template size? Or just using the kernel size?^_^

2015-12-25 12:19:38 -0600 asked a question how to use cv::cuda::Convolution::convolve in opencv?

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?