ConvolvePointList#
Convolution on a subset of points only.
Paralllel convolution of a kernel at specified points of the source only. Useful to speed up processing in large arrays and only a smaller number of convolution points.
Note
This module is heavily used in the :mod”~ClearMap.ImageProcessing.Skeletonization algorithm.
- convolve_3d(source, kernel, points=None, indices=None, x=None, y=None, z=None, sink=None, sink_dtype=None, strides=None, check_border=True, processes=12)[source]#
Convolves source with a specified kernel at specific points only.
Arguments
- sourcearray
3d binary array to convolve.
- kernelarray
Convolution kernel.
- pointsarray
List of points to convolve.
- indicesarray
Indices to convolve.
- x,y,zarray
Arrays of x,y,z coordinates of points to convolve on
- sinkarray
Optional sink to write result to.
- sink_dtypedtype)
Optional type of the sink. If None, the kernel type is used as default.
- stridesarray
The strides of the source in case its given as a 1d list.
- check_borderbool
If True, check if each kernel element is inside the source array shape.
- processesint or None
Number of processes to use.
Returns
- convolvedarray
List of results of convolution at specified points
Note
Either points x,y,z or an index array needs to be given. This function wraps more specialized functions
See also
- convolve_3d_find_smaller_than(source, search, indices, max_value, sink=None, processes=12)[source]#
Convolves source with a specified kernel at specific points given by a flat array indx under conditon the value is smaller than a number
- Arguments:
source (array): 3d binary array to convolve kernel (array): binary orinteger kernel to convolve points (array): list of points to convolve given by the flat array coordinates max_value (int): if result of convolution is smaller then this value return True otherwise False in the sink array processes (int): number of processors
- Returns:
array: list of results of convolution at specified points
- Note:
cython does not support bools -> use view on uint8 as numpy does
- convolve_3d_indices(source, kernel, indices, sink=None, sink_dtype=None, strides=None, check_border=True, processes=12)[source]#
Convolves source with a specified kernel at specific points given by a flat array index.
Arguments
- sourcearray
3d binary array to convolve.
- kernelarray
Convolution kernel.
- indicesarray
Indices to convolve.
- sinkarray
Optional sink to write result to.
- sink_dtypedtype)
Optional type of the sink. If None, the kernel type is used as default.
- stridesarray
The strides of the source in case its given as a 1d list.
- check_borderbool
If True, check if each kernel element is inside the source array shape.
- processesint or None
Number of processes to use.
Returns
- convolvedarray
List of results of convolution.
- convolve_3d_indices_if_smaller_than(source, kernel, indices, max_value, sink=None, strides=None, check_border=True, processes=12)[source]#
Convolves source with a specified kernel at specific points given by a flat array indx under conditon the value is smaller than a number
Arguments
- sourcearray
3d binary array to convolve.
- kernelarray
Convolution kernel.
- indicesarray
Indices to convolve.
- max_valuefloat
Checks if the convolution result is smaller than this value.
- sinkarray
Optional sink to write result to.
- stridesarray
The strides of the source in case its given as a 1d list.
- check_borderbool
If True, check if each kernel element is inside the source array shape.
- processesint or None
Number of processes to use.
Returns
- convolvedarray
List of results of convolution at specified points
- convolve_3d_points(source, kernel, points, sink=None, sink_dtype=None, check_border=True, processes=12)[source]#
Convolves source with a specified kernel at specific points only
Arguments
- sourcearray
3d binary array to convolve.
- kernelarray
Convolution kernel.
- pointsarray
List of points to convolve.
- sinkarray
Optional sink to write result to.
- sink_dtypedtype)
Optional type of the sink. If None, the kernel type is used as default.
- check_borderbool
If True, check if each kernel element is inside the source array shape.
- processesint or None
Number of processes to use.
Returns
- convolvedarray
List of results of convolution at specified points
- convolve_3d_xyz(source, kernel, x, y, z, sink=None, sink_dtype=None, check_border=True, processes=12)[source]#
Convolves source with a specified kernel at specific points only
Arguments
- sourcearray
3d binary array to convolve.
- kernelarray
Convolution kernel.
- x,y,zarray
Arrays of x,y,z coordinates of points to convolve on
- sinkarray
Optional sink to write result to.
- sink_dtypedtype)
Optional type of the sink. If None, the kernel type is used as default.
- check_borderbool
If True, check if each kernel element is inside the source array shape.
- processesint or None
Number of processes to use.
Returns
- convolvedarray
List of results of convolution.