center_crop¶
- torchvision.transforms.functional.center_crop(img: Tensor, output_size: List[int]) Tensor [原始碼]¶
在中心裁剪給定的影像。如果影像是 torch Tensor,則預期具有 […, H, W] 形狀,其中 … 表示任意數量的領先維度。如果影像大小小於沿任何邊緣的輸出大小,則影像會以 0 填充,然後在中心裁剪。
- 參數:
img (PIL Image 或 Tensor) – 要裁剪的影像。
output_size (序列 或 int) – 裁剪框的 (高度, 寬度)。如果為 int 或具有單一 int 的序列,則用於兩個方向。
- 傳回:
裁剪後的影像。
- 傳回類型:
PIL Image 或 Tensor
使用
center_crop
的範例