crop¶ torchvision.transforms.functional.crop(img: Tensor, top: int, left: int, height: int, width: int) → Tensor[原始碼]¶ 在指定位置和輸出大小裁剪給定的影像。如果影像為 torch Tensor,則預期其形狀為 […, H, W],其中 … 表示任意數量的領先維度。如果影像大小沿任何邊緣小於輸出大小,則影像會先以 0 填充,然後再裁剪。 參數: img (PIL Image 或 Tensor) – 要裁剪的影像。(0,0) 表示影像的左上角。 top (int) – 裁剪框左上角的垂直分量。 left (int) – 裁剪框左上角的水平分量。 height (int) – 裁剪框的高度。 width (int) – 裁剪框的寬度。 傳回: 裁剪後的影像。 傳回類型: PIL Image 或 Tensor 使用 crop 的範例 轉換的圖解 轉換的圖解