gpu::convolve crops borders (Bug #1639)
Description
Hello,
I have found something which is either an error in the documentation or a real bug.
When you do a convolution of a matrix (let's say of size n*m) with a kernel of size k, the output matrix will have a size of (n-(k-1))*(m-(k-1)).
But the documentation says that the result matrix needs to be of the same size than the source one. So either the documentation is really wrong in this case, or the behavior of the function is erroneous.
While I understand why you would do something like that, I find this a bit inefficient. If for any reason you need to process multiple convolutions on the same image you will loose many pixels through the different operations. Or you would loose time in order to create a bigger image which would possess more lines than it should.
Associated revisions
updated image for StereoConstantSpaceBP regression test
updated gpu tests for CornerHarris and CornerMinEigen
moved direct convolution implementation to gpu::filter2D, gpu::convolve now use only DFT-based algorithm (Bug #1639)
History
Updated by Anatoly Baksheev about 13 years ago
- Assignee changed from Anatoly Baksheev to Alexey Spizhevoy
Updated by Alexey Spizhevoy about 13 years ago
Hi,
gpu::convolve() has such behaviour to be used easily and efficiently in gpu::matchTemplate(). I've fixed docs.
If the use case described by you is a really important one we probably should add border handling as an option (or keep the current behaviour as an option).
Updated by Alexey Spizhevoy about 13 years ago
Vlad,
I've noticed that your specializations of gpu::convolve() differ from the original behaviour:- there is no support of correlation/convolution flag
- specializations use another kernel anchor
- no border cropping (it should be for consistency)
- Assignee changed from Alexey Spizhevoy to Vladislav Vinogradov
Updated by Charles-Henry Houdemer about 13 years ago
Hi,
Thanks for the fast response.
If it is not too much of a hassle, it would be marvelous to add the border handling as an option (in order to keep the current standard behavior).
Updated by Vladislav Vinogradov about 13 years ago
I've moved direct convolution implementation to gpu::filter2D. Now gpu::convolve function uses only DFT-based algorithm. For small kernel sizes (<= 16) it's better to use filter2D. Also in filter2D there is no border cropping.
Updated by Vladislav Vinogradov almost 13 years ago
- Status changed from Open to Done
- Target version set to 2.4.0