透视变换¶
- torchvision.transforms.functional.perspective(img: Tensor, startpoints: List[List[int]], endpoints: List[List[int]], interpolation: InterpolationMode = InterpolationMode.BILINEAR, fill: Optional[List[float]] = None) Tensor [source]¶
对给定图像执行透视变换。如果图像是 torch Tensor,则其形状应为 […, H, W],其中 … 表示任意数量的引导维度。
- 参数:
img (PIL Image 或 Tensor) – 要进行变换的图像。
startpoints (list of list of python:ints) – 一个包含四个列表的列表,每个列表包含两个整数,分别对应原始图像的四个角
[左上角, 右上角, 右下角, 左下角]
。endpoints (list of list of python:ints) – 一个包含四个列表的列表,每个列表包含两个整数,分别对应变换后图像的四个角
[左上角, 右上角, 右下角, 左下角]
。interpolation (InterpolationMode) – 所需的插值枚举,由
torchvision.transforms.InterpolationMode
定义。默认为InterpolationMode.BILINEAR
。如果输入是 Tensor,仅支持InterpolationMode.NEAREST
和InterpolationMode.BILINEAR
。也接受相应的 Pillow 整数常量,例如PIL.Image.BILINEAR
。fill (序列 或 数字, 可选) –
变换图像外部区域的像素填充值。如果给定一个数字,则该值用于所有通道。
注意
在 torchscript 模式下,不支持单个 int/float 值,请使用长度为 1 的序列:
[值, ]
。
- 返回:
变换后的图像。
- 返回类型:
PIL Image 或 Tensor
使用
perspective
示例