Boost logo

Boost :

From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2019-07-15 20:37:27


Hi,

In this thread, I'm archiving some comments related to discussion
we recently held with Miral on Gitter due to issues with implementation
of convolution in the current Numeric extension.
That is, convolve_cols and convolve_rows.

First, reminder that the Numeric implements 2D separable convolution [1].
More precisely, it is 2D spatial separable convolution [2] and, AFAIU,
no depth-wise convolving happens.

The implication is that it requires use of separable kernels [3] (that is
kernels with matrix rank equal to 1).

For a moment, I thought that Miral's may have hit this limitation, but
it does not apply to the averaging kernel which has rank 1, of course:

>>> import numpy as np
>>> avg = np.array([[1,1,1],[1,1,1],[1,1,1]])
>>> np.linalg.matrix_rank(avg)
1

BTW, Gaussian, Sobel are also separable filters.

So, there must be something else going on in the Numeric's convolve
functions. I've added basic testing infrastructure for those functions
with first tests [5] and I'm hoping to add more soon, and that it will help
to identify where is the problem.

Any help and feedback is appreciated.

Meanwhile, Miral may work out a basic bespoke implementation of
convolution dedicated for her needs.

[1] https://blogs.mathworks.com/steve/2006/10/04/separable-convolution/
[2] https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728
[3] https://en.wikipedia.org/wiki/Separable_filter
[4] https://blogs.mathworks.com/steve/2006/11/28/separable-convolution-part-2/
[5] https://github.com/boostorg/gil/pull/335

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net

Boost list run by Boost-Gil-Owners