透視變換¶
- 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示例