cropΒΆ
- torchvision.transforms.functional.crop(img: Tensor, top: int, left: int, height: int, width: int) Tensor [source]ΒΆ
Crop the given image at specified location and output size. If the image is torch Tensor, it is expected to have [β¦, H, W] shape, where β¦ means an arbitrary number of leading dimensions. If image size is smaller than output size along any edge, image is padded with 0 and then cropped.
- Parameters:
img (PIL Image or Tensor) β Image to be cropped. (0,0) denotes the top left corner of the image.
top (int) β Vertical component of the top left corner of the crop box.
left (int) β Horizontal component of the top left corner of the crop box.
height (int) β Height of the crop box.
width (int) β Width of the crop box.
- Returns:
Cropped image.
- Return type:
PIL Image or Tensor
Examples using
crop
: