Table of Contents
Shortcuts

# perspective

torchvision.transforms.functional.perspective(img: Tensor, startpoints: List[List[int]], endpoints: List[List[int]], interpolation: InterpolationMode = InterpolationMode.BILINEAR, fill: Optional[List[float]] = None) → Tensor

  Perform perspective transform of the given image. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions.

  Parameters:

    - img (PIL Image or Tensor) – Image to be transformed.

    - startpoints (list of list of python:ints) – List containing four lists of two integers corresponding to four corners `[top-left, top-right, bottom-right, bottom-left]` of the original image.

    - endpoints (list of list of python:ints) – List containing four lists of two integers corresponding to four corners `[top-left, top-right, bottom-right, bottom-left]` of the transformed image.

    - interpolation (InterpolationMode) – Desired interpolation enum defined by `torchvision.transforms.InterpolationMode`. Default is `InterpolationMode.BILINEAR`. If input is Tensor, only `InterpolationMode.NEAREST`, `InterpolationMode.BILINEAR` are supported. The corresponding Pillow integer constants, e.g. `PIL.Image.BILINEAR` are accepted as well.

    - fill (sequence or number, optional) –

      Pixel fill value for the area outside the transformed image. If given a number, the value is used for all bands respectively.

      Note

      In torchscript mode single int/float value is not supported, please use a sequence of length 1: `[value, ]`.

  Returns:

    transformed Image.

  Return type:

    PIL Image or Tensor

## 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

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.