Image.smooth#

Image.smooth(sigma: float = 0, h: int | None = None, mode: str = 'same', border: str = 'reflect', bordervalue: int | float = 0) Any[source]#

Smooth image

Parameters:
  • sigma (float) – standard deviation of the Gaussian kernel

  • h (int) – half-width of the kernel

  • mode (str, optional) – option for convolution, see convolve, defaults to ‘same’

  • border (str, optional) – option for boundary handling, see convolve, defaults to ‘reflect’

  • bordervalue (scalar, optional) – padding value, see convolve, defaults to 0

Returns:

smoothed image

Return type:

Image

Smooth the image by convolving with a Gaussian kernel of standard deviation sigma. If h is not given the kernel half width is set to \(2 \mbox{ceil}(3 \sigma) + 1\). If sigma is not given it is computed from h using the rule of thumb that \(\sigma = 0.3 \mathtt{h} + 0.8\) which ensures that most of the Gaussian is contained within the window.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('monalisa.png')
>>> img.smooth(sigma=3).disp()
<matplotlib.image.AxesImage object at 0x7f076d0254f0>

Note

  • Smooths all planes of the input image.

  • The Gaussian kernel has a unit volume.

  • If input image is integer it is converted to float, convolved, then converted back to integer.

References:
Seealso:

machinevisiontoolbox.Kernel.Gauss convolve