crop¶ torchvision.transforms.functional.crop(img: Tensor, top: int, left: int, height: int, width: int) → Tensor[源代码]¶ 在指定位置和输出大小裁剪给定图像。如果图像是 torch Tensor,则应具有 […, H, W] 形状,其中 … 表示任意数量的前导维度。如果图像大小在任何边缘都小于输出大小,则图像将用 0 填充,然后再裁剪。 参数: img (PIL 图像 或 Tensor) – 要裁剪的图像。(0,0) 表示图像的左上角。 top (int) – 裁剪框左上角的垂直分量。 left (int) – 裁剪框左上角的水平分量。 height (int) – 裁剪框的高度。 width (int) – 裁剪框的宽度。 返回: 裁剪后的图像。 返回类型: PIL 图像或 Tensor 使用 crop 的示例 转换的图示 转换的图示