bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / _gaussian / difference_of_gaussians
function
skimage.filters._gaussian:difference_of_gaussians
source: /dev/scikit-image/src/skimage/filters/_gaussian.py :147
Signature
def difference_of_gaussians ( image , low_sigma , high_sigma = None , * , mode = nearest , cval = 0 , channel_axis = None , truncate = 4.0 ) Summary
Find features between low_sigma and high_sigma in size.
Extended Summary
This function uses the Difference of Gaussians method for applying band-pass filters to multi-dimensional arrays. The input array is blurred with two Gaussian kernels of differing sigmas to produce two intermediate, filtered images. The more-blurred image is then subtracted from the less-blurred image. The final output image will therefore have had high-frequency components attenuated by the smaller-sigma Gaussian, and low frequency components will have been removed due to their presence in the more-blurred intermediate.
Parameters
image: ndarrayInput array to filter.
low_sigma: scalar or sequence of scalarsStandard deviation(s) for the Gaussian kernel with the smaller sigmas across all axes. The standard deviations are given for each axis as a sequence, or as a single number, in which case the single number is used as the standard deviation value for all axes.
high_sigma: scalar or sequence of scalars, optional (default is None)Standard deviation(s) for the Gaussian kernel with the larger sigmas across all axes. The standard deviations are given for each axis as a sequence, or as a single number, in which case the single number is used as the standard deviation value for all axes. If None is given (default), sigmas for all axes are calculated as 1.6 * low_sigma.
mode: {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optionalThe
modeparameter determines how the array borders are handled, wherecvalis the value when mode is equal to 'constant'. Default is 'nearest'.cval: scalar, optionalValue to fill past edges of input if
modeis 'constant'. Default is 0.0channel_axis: int or None, optionalIf None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.
truncate: float, optional (default is 4.0)Truncate the filter at this many standard deviations.
Returns
filtered_image: ndarraythe filtered array.
Notes
This function will subtract an array filtered with a Gaussian kernel with sigmas given by high_sigma from an array filtered with a Gaussian kernel with sigmas provided by low_sigma. The values for high_sigma must always be greater than or equal to the corresponding values in low_sigma, or a ValueError will be raised.
When high_sigma is none, the values for high_sigma will be calculated as 1.6x the corresponding values in low_sigma. This ratio was originally proposed by Marr and Hildreth (1980) [1] and is commonly used when approximating the inverted Laplacian of Gaussian, which is used in edge and blob detection.
Input image is converted according to the conventions of img_as_float.
Except for sigma values, all parameters are used for both filters.
Examples
Apply a simple Difference of Gaussians filter to a color image:from skimage.data import astronaut from skimage.filters import difference_of_gaussians filtered_image = difference_of_gaussians(astronaut(), 2, 10, channel_axis=-1)✓
filtered_image = difference_of_gaussians(astronaut(), 2, channel_axis=-1)✓
from skimage.data import camera filtered_image = difference_of_gaussians(camera(), (2,5), (3,20))✓
See also
Aliases
-
skimage.filters.difference_of_gaussians