This tool can be used to perform a Gaussian filter on a raster image. A Gaussian filter can be used to emphasize the longer-range variability in an image, effectively acting to smooth the image. This can be useful for reducing the noise in an image. The algorithm operates by convolving a kernel of weights with each grid cell and its neighbours in an image. The weights of the convolution kernel are determined by the 2-dimensional Gaussian (i.e. normal) curve, which gives stronger weighting to cells nearer the kernel centre. It is this characteristic that makes the Gaussian filter an attractive alternative for image smoothing and noise reduction than the mean_filter. The size of the filter is determined by setting the standard deviation parameter (sigma
), which is in units of grid cells; the larger the standard deviation the larger the resulting filter kernel. The standard deviation can be any number in the range 0.5-20.
gaussian_filter works with both greyscale and red-green-blue (RGB) colour images. RGB images are decomposed into intensity-hue-saturation (IHS) and the filter is applied to the intensity channel. NoData values in the input image are ignored during processing.
Like many low-pass filters, Gaussian filtering can significantly blur well-defined edges in the input image. The edge_preserving_mean_filter and bilateral_filter offer more robust feature preservation during image smoothing. gaussian_filter is relatively slow compared to the fast_almost_gaussian_filter tool, which offers a fast-running approximatation to a Gaussian filter for larger kernel sizes.
fast_almost_gaussian_filter, mean_filter, median_filter, rgb_to_ihs
def gaussian_filter(self, raster: Raster, sigma: float = 0.75) -> Raster: ...