@@ -342,13 +342,14 @@ def pad(img, padding, fill=0, padding_mode='constant'):
342
342
343
343
def crop (img , top , left , height , width ):
344
344
"""Crop the given PIL Image.
345
-
345
+
346
346
Args:
347
347
img (PIL Image): Image to be cropped. (0,0) denotes the top left corner of the image.
348
348
top (int): Vertical component of the top left corner of the crop box.
349
349
left (int): Horizontal component of the top left corner of the crop box.
350
350
height (int): Height of the crop box.
351
351
width (int): Width of the crop box.
352
+
352
353
Returns:
353
354
PIL Image: Cropped image.
354
355
"""
@@ -361,13 +362,13 @@ def crop(img, top, left, height, width):
361
362
def center_crop (img , output_size ):
362
363
"""Crop the given PIL Image and resize it to desired size.
363
364
364
- Args:
365
- img (PIL Image): Image to be cropped. (0,0) denotes the top left corner of the image.
366
- output_size (sequence or int): (height, width) of the crop box. If int,
367
- it is used for both directions
368
- Returns:
369
- PIL Image: Cropped image.
370
- """
365
+ Args:
366
+ img (PIL Image): Image to be cropped. (0,0) denotes the top left corner of the image.
367
+ output_size (sequence or int): (height, width) of the crop box. If int,
368
+ it is used for both directions
369
+ Returns:
370
+ PIL Image: Cropped image.
371
+ """
371
372
if isinstance (output_size , numbers .Number ):
372
373
output_size = (int (output_size ), int (output_size ))
373
374
image_width , image_height = img .size
@@ -554,23 +555,24 @@ def five_crop(img, size):
554
555
555
556
556
557
def ten_crop (img , size , vertical_flip = False ):
557
- r"""Crop the given PIL Image into four corners and the central crop plus the
558
- flipped version of these (horizontal flipping is used by default).
558
+ """Generate ten cropped images from the given PIL Image.
559
+ Crop the given PIL Image into four corners and the central crop plus the
560
+ flipped version of these (horizontal flipping is used by default).
559
561
560
562
.. Note::
561
563
This transform returns a tuple of images and there may be a
562
564
mismatch in the number of inputs and targets your ``Dataset`` returns.
563
565
564
566
Args:
565
- size (sequence or int): Desired output size of the crop. If size is an
567
+ size (sequence or int): Desired output size of the crop. If size is an
566
568
int instead of sequence like (h, w), a square crop (size, size) is
567
569
made.
568
- vertical_flip (bool): Use vertical flipping instead of horizontal
570
+ vertical_flip (bool): Use vertical flipping instead of horizontal
569
571
570
572
Returns:
571
- tuple: tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip, br_flip, center_flip)
572
- Corresponding top left, top right, bottom left, bottom right and center crop
573
- and same for the flipped image.
573
+ tuple: tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip, br_flip, center_flip)
574
+ Corresponding top left, top right, bottom left, bottom right and
575
+ center crop and same for the flipped image.
574
576
"""
575
577
if isinstance (size , numbers .Number ):
576
578
size = (int (size ), int (size ))
0 commit comments