skimage2.filters.gaussian#
- skimage2.filters.gaussian(image, sigma=1.0, *, mode='nearest', cval=0, truncate=4.0, channel_axis=None, out=None)[source]#
Filter with Multi-dimensional Gaussian kernel.
- Parameters:
- imagendarray
Input image (grayscale or color) to filter.
- sigmascalar or sequence of scalars, optional
Standard deviation for Gaussian kernel. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
- mode{âreflectâ, âconstantâ, ânearestâ, âmirrorâ, âwrapâ}, optional
The
modeparameter determines how the array borders are handled, wherecvalis the value when mode is equal to âconstantâ. Default is ânearestâ.- cvalscalar, optional
Value to fill past edges of input if
modeis âconstantâ. Default is 0.0.- truncatefloat, optional
Truncate the filter at this many standard deviations.
- channel_axisint or None, optional
If None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.
- outndarray, optional
If given, the filtered image will be stored in this array.
- Returns:
- filtered_imagendarray
the filtered array
Notes
This function is a wrapper around
scipy.ndimage.gaussian_filter().Integer arrays are converted to float.
outshould be of floating-point data type sincegaussianconverts the inputimageto float. Ifoutis not provided, another array will be allocated and returned as the result.The multi-dimensional filter is implemented as a sequence of one-dimensional convolution filters. The intermediate arrays are stored in the same data type as the output. Therefore, for output types with a limited precision, the results may be imprecise because intermediate results may be stored with insufficient precision.
Examples
>>> import _skimage2 as ski2 >>> import _skimage2 as ski2 >>> a = np.zeros((3, 3)) >>> a[1, 1] = 1 >>> a array([[0., 0., 0.], [0., 1., 0.], [0., 0., 0.]]) >>> ski2.filters.gaussian(a, sigma=0.4) # mild smoothing array([[0.00163116, 0.03712502, 0.00163116], [0.03712502, 0.84496158, 0.03712502], [0.00163116, 0.03712502, 0.00163116]]) >>> ski2.filters.gaussian(a, sigma=1) # more smoothing array([[0.05855018, 0.09653293, 0.05855018], [0.09653293, 0.15915589, 0.09653293], [0.05855018, 0.09653293, 0.05855018]]) >>> # Several modes are possible for handling boundaries >>> ski2.filters.gaussian(a, sigma=1, mode='reflect') array([[0.08767308, 0.12075024, 0.08767308], [0.12075024, 0.16630671, 0.12075024], [0.08767308, 0.12075024, 0.08767308]]) >>> # For RGB images, each is filtered separately >>> image = ski2.data.astronaut() >>> filtered_img = ski2.filters.gaussian(image, sigma=1, channel_axis=-1)