捷徑

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 ImageTensor) – 要轉換的影像。

  • startpoints (python:ints 的列表的列表) – 包含四個包含兩個整數的列表的列表,對應於原始圖像的四個角 [左上, 右上, 右下, 左下]

  • endpoints (python:ints 的列表的列表) – 包含四個包含兩個整數的列表的列表,對應於變換後圖像的四個角 [左上, 右上, 右下, 左下]

  • interpolation (InterpolationMode) – 由 torchvision.transforms.InterpolationMode 定義的所需插值枚舉。預設為 InterpolationMode.BILINEAR。如果輸入是 Tensor,則僅支援 InterpolationMode.NEARESTInterpolationMode.BILINEAR。也接受相應的 Pillow 整數常數,例如 PIL.Image.BILINEAR

  • fill (序列數字, 可選) –

    變換後圖像外部區域的像素填充值。 如果給定一個數字,則該值分別用於所有通道。

    注意

    在 torchscript 模式下,不支援單個 int/float 值,請使用長度為 1 的序列: [value, ]

返回:

變換後的圖像。

返回類型:

PIL 圖像或 Tensor

使用 perspective 的範例

變換的說明

變換的說明

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學課程

取得初學者和進階開發人員的深入教學課程

檢視教學課程

資源

尋找開發資源並取得問題的解答

檢視資源