快捷方式

透视

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

对给定图像执行透视变换。如果图像是 torch Tensor,则其形状应为 [..., H, W],其中 ... 表示任意数量的前导维度。

参数:
  • img (PIL ImageTensor) – 要转换的图像。

  • startpoints (list of list of python:ints) – 包含四个包含两个整数的列表,对应于原始图像的四个角 [左上, 右上, 右下, 左下]

  • endpoints (list of list of python:ints) – 包含四个包含两个整数的列表,对应于变换后图像的四个角 [左上, 右上, 右下, 左下]

  • interpolation (InterpolationMode) – 由 torchvision.transforms.InterpolationMode 定义的所需的插值枚举。默认为 InterpolationMode.BILINEAR。如果输入是 Tensor,则仅支持 InterpolationMode.NEARESTInterpolationMode.BILINEAR。也可接受相应的 Pillow 整数常量,例如 PIL.Image.BILINEAR

  • fill (sequencenumber, optional) –

    变换后图像区域的像素填充值。如果提供数字,则该值将分别用于所有通道。

    注意

    在 torchscript 模式下,不支持单个 int/float 值,请使用长度为 1 的序列:[value, ]

返回:

变换后的图像。

返回类型:

PIL 图像或张量

使用 perspective 的示例

转换图示

转换图示

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源