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 [來源]¶
執行給定影像的透視變換。如果影像是 torch Tensor,則預期具有 […, H, W] 形狀,其中 … 表示任意數量的領先維度。
- 參數:
img (PIL Image 或 Tensor) – 要轉換的影像。
startpoints (python:ints 的列表的列表) – 包含四個包含兩個整數的列表的列表,對應於原始圖像的四個角
[左上, 右上, 右下, 左下]
。endpoints (python:ints 的列表的列表) – 包含四個包含兩個整數的列表的列表,對應於變換後圖像的四個角
[左上, 右上, 右下, 左下]
。interpolation (InterpolationMode) – 由
torchvision.transforms.InterpolationMode
定義的所需插值枚舉。預設為InterpolationMode.BILINEAR
。如果輸入是 Tensor,則僅支援InterpolationMode.NEAREST
和InterpolationMode.BILINEAR
。也接受相應的 Pillow 整數常數,例如PIL.Image.BILINEAR
。fill (序列 或 數字, 可選) –
變換後圖像外部區域的像素填充值。 如果給定一個數字,則該值分別用於所有通道。
注意
在 torchscript 模式下,不支援單個 int/float 值,請使用長度為 1 的序列:
[value, ]
。
- 返回:
變換後的圖像。
- 返回類型:
PIL 圖像或 Tensor
使用
perspective
的範例