convolution
: Convolution¶
Module for convolution on CPU/GPU.
-
class
Convolution
(shape, kernel, axes=None, mode=None, ctx=None, devicetype='all', platformid=None, deviceid=None, profile=False, extra_options=None)[source]¶ Bases:
silx.opencl.processing.OpenclProcessing
A class for performing convolution on CPU/GPU with OpenCL.
-
gaussian_kernel
(sigma, cutoff=4, force_odd_size=False)[source]¶ Generates a Gaussian convolution kernel.
- Parameters
sigma – Standard Deviation of the Gaussian curve.
cutoff – Parameter tuning the truncation of the Gaussian. The higher cutoff, the biggest the array will be (and the closest to a “true” Gaussian function).
force_odd_size – when set to True, the resulting array will always have an odd size, regardless of the values of “sigma” and “cutoff”.
- Returns
a numpy.ndarray containing the truncated Gaussian function. The array size is 2*c*s+1 where c=cutoff, s=sigma.
- Nota: due to the quick decay of the Gaussian function, small values of the
“cutoff” parameter are usually fine. The energy difference between a Gaussian truncated to [-c, c] and a “true” one is
erfc(c/(sqrt(2)*s))
so choosing cutoff=4*sigma keeps the truncation error below 1e-4.