快捷方式

透視

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 (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 (sequencenumber, optional) –

    變換後圖像區域的畫素填充值。如果提供數字,則該值將分別用於所有通道。

    注意

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

返回:

變換後的影像。

返回型別:

PIL 影像或張量

使用 perspective 的示例

轉換圖示

轉換圖示

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

為初學者和高階開發者提供深入的教程

檢視教程

資源

查詢開發資源並讓您的問題得到解答

檢視資源