Shortcuts

gaussian_blur

torchvision.transforms.functional.gaussian_blur(img: Tensor, kernel_size: List[int], sigma: Optional[List[float]] = None) Tensor[source]

Performs Gaussian blurring on the image by given kernel. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means at most one leading dimension.

Parameters:
  • img (PIL Image or Tensor) – Image to be blurred

  • kernel_size (sequence of python:ints or int) –

    Gaussian kernel size. Can be a sequence of integers like (kx, ky) or a single integer for square kernels.

    Note

    In torchscript mode kernel_size as single int is not supported, use a sequence of length 1: [ksize, ].

  • sigma (sequence of python:floats or float, optional) –

    Gaussian kernel standard deviation. Can be a sequence of floats like (sigma_x, sigma_y) or a single float to define the same sigma in both X/Y directions. If None, then it is computed using kernel_size as sigma = 0.3 * ((kernel_size - 1) * 0.5 - 1) + 0.8. Default, None.

    Note

    In torchscript mode sigma as single float is not supported, use a sequence of length 1: [sigma, ].

Returns:

Gaussian Blurred version of the image.

Return type:

PIL Image or Tensor

Examples using gaussian_blur:

Illustration of transforms

Illustration of transforms

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources