透視¶
- 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 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 (sequence 或 number, optional) –
變換後圖像區域的畫素填充值。如果提供數字,則該值將分別用於所有通道。
注意
在 torchscript 模式下,不支援單個 int/float 值,請使用長度為 1 的序列:
[value, ]。
- 返回:
變換後的影像。
- 返回型別:
PIL 影像或張量
使用
perspective的示例