视角¶
- 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张量,则期望其具有[…, H, W]形状,其中…表示任意数量的前导维度。
- Parameters:
img (PIL Image 或 Tensor) – 要转换的图像。
startpoints (列表的列表,包含python:ints) – 包含四个列表的列表,每个列表包含两个整数,对应于原始图像的四个角落
[左上角, 右上角, 右下角, 左下角]。endpoints (list of list of python:ints) – 包含四个由两个整数组成的列表的列表,对应于变换后图像的四个角
[top-left, top-right, bottom-right, bottom-left]。插值 (InterpolationMode) – 由
torchvision.transforms.InterpolationMode定义的期望插值枚举。默认是InterpolationMode.BILINEAR。 如果输入是张量,仅支持InterpolationMode.NEAREST,InterpolationMode.BILINEAR。 相应的Pillow整数常量,例如PIL.Image.BILINEAR也被接受。fill (sequence 或 number, 可选) –
变换图像外部区域的像素填充值。如果给定一个数字,则该值将分别用于所有波段。
注意
在torchscript模式下,不支持单个int/float值,请使用长度为1的序列:
[value, ]。
- Returns:
转换后的图像。
- Return type:
PIL 图像或张量
使用
perspective的示例: