快捷方式

透視變換

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

  • startpoints (list of list of python:ints) – 一個包含四個列表的列表,每個列表包含兩個整數,分別對應原始影像的四個角 [左上角, 右上角, 右下角, 左下角]

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

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

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

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

    注意

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

返回:

變換後的影像。

返回型別:

PIL Image 或 Tensor

使用 perspective 示例

變換示意圖

變換示意圖

文件

訪問 PyTorch 全面的開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源