{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / _gaussian / gaussian

function

skimage.filters._gaussian:gaussian

source: /dev/scikit-image/src/skimage/filters/_gaussian.py :9

Signature

def   gaussian ( image sigma = 1.0 * mode = nearest cval = 0 preserve_range = False truncate = 4.0 channel_axis = None out = None )

Summary

Multi-dimensional Gaussian filter.

Parameters

image : ndarray

Input image (grayscale or color) to filter.

sigma : scalar 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 mode parameter determines how the array borders are handled, where cval is the value when mode is equal to 'constant'. Default is 'nearest'.

cval : scalar, optional

Value to fill past edges of input if mode is 'constant'. Default is 0.0

preserve_range : bool, optional

If True, keep the original range of values. Otherwise, the input image is converted according to the conventions of img_as_float (Normalized first to values [-1.0 ; 1.0] or [0 ; 1.0] depending on dtype of input)

For more information, see: https://scikit-image.org/docs/dev/user_guide/data_types.html

truncate : float, optional

Truncate the filter at this many standard deviations.

channel_axis : int 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.

out : ndarray, optional

If given, the filtered image will be stored in this array.

Returns

filtered_image : ndarray

the filtered array

Notes

This function is a wrapper around scipy.ndimage.gaussian_filter.

Integer arrays are converted to float.

out should be of floating-point data type since gaussian converts the input image to float. If out is 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 numpy as np
import skimage as ski
a = np.zeros((3, 3))
a[1, 1] = 1
a
ski.filters.gaussian(a, sigma=0.4)  # mild smoothing
ski.filters.gaussian(a, sigma=1)  # more smoothing
ski.filters.gaussian(a, sigma=1, mode='reflect')
image = ski.data.astronaut()
filtered_img = ski.filters.gaussian(image, sigma=1, channel_axis=-1)

Aliases

  • skimage.filters.gaussian