skan.pre: Image preprocessing#
- skan.pre.hyperball(ndim, radius)[source]#
Return a binary morphological filter containing pixels within radius.
- Parameters:
ndim (int) β The number of dimensions of the filter.
radius (int) β The radius of the filter.
- Returns:
ball β The required structural element
- Return type:
array of bool, shape [2 * radius + 1,] * ndim
- skan.pre.threshold(image, *, sigma=0.0, radius=0, offset=0.0, method='sauvola', smooth_method='Gaussian')[source]#
Use scikit-image filters to βintelligentlyβ threshold an image.
- Parameters:
image (array, shape (M, N, ...[, 3])) β Input image, conformant with scikit-image data type specification [1].
sigma (float, optional) β If positive, use Gaussian filtering to smooth the image before thresholding.
radius (int, optional) β If given, use local median thresholding instead of global.
offset (float, optional) β If given, reduce the threshold by this amount. Higher values result in fewer pixels above the threshold.
method ({'sauvola', 'niblack', 'median'}) β Which method to use for thresholding. Sauvola is 100x faster, but median might be more accurate.
smooth_method ({'Gaussian', 'TV'}) β Which method to use for smoothing. Choose from Gaussian smoothing and total variation denoising.
- Returns:
thresholded β The thresholded image.
- Return type:
image of bool, same shape as image
References