prtools.gauss_blur#

gauss_blur(img, sigma, oversample=1)[source]#

Blur an image using a Gaussian filter using the FFT.

Parameters:
  • img (array_like) – Array to be blurred

  • sigma (float or (2,) array_like) – Standard deviation for the Gaussian kernel. Providing two values allows for non-symmetric Gaussian interpreted as (sigma_row, sigma_col)

  • oversample (float, optional) – Oversampling factor of img. Default is 1.

Return type:

ndarray

Examples

>>> img = np.zeros((100,100))
>>> img[0:50,0:50] = 1
>>> img[50:100,50:100] = 1
>>> img = np.tile(img, (3,3))
>>> img_blurred = prtools.gauss_blur(img, sigma=3)
>>> fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(5,2))
>>> ax[0].imshow(img, cmap='gray')
>>> ax[0].set_title('Input image')
>>> ax[1].imshow(img_blurred, cmap='gray')
>>> ax[1].set_title('Blurred image')
../_images/prtools-gauss_blur-1.png