center_crop¶
- torchvision.transforms.functional.center_crop(img: Tensor, output_size: List[int]) Tensor[source]¶
將給定的影像從中心位置裁剪。如果影像是 torch Tensor,它應具有 […, H, W] 的形狀,其中 … 表示任意數量的前導維度。如果影像沿任一邊緣的大小小於輸出大小,影像將用 0 填充,然後進行中心裁剪。
- 引數:
img (PIL Image 或 Tensor) – 要裁剪的影像。
output_size (sequence 或 int) – 裁剪框的 (高度, 寬度)。如果為 int 或只包含一個 int 的序列,則對兩個方向使用相同的值。
- 返回:
裁剪後的影像。
- 返回型別:
PIL Image or Tensor
使用
center_crop的示例