basicsr.data.transforms¶
- basicsr.data.transforms.augment(imgs, hflip=True, rotation=True, flows=None, return_status=False)[source]¶
Augment: horizontal flips OR rotate (0, 90, 180, 270 degrees).
We use vertical flip and transpose for rotation implementation. All the images in the list use the same augmentation.
- Parameters:
imgs (list[ndarray] | ndarray) – Images to be augmented. If the input is an ndarray, it will be transformed to a list.
hflip (bool) – Horizontal flip. Default: True.
rotation (bool) – Ratotation. Default: True.
(list[ndarray] (flows) – Flows to be augmented. If the input is an ndarray, it will be transformed to a list. Dimension is (h, w, 2). Default: None.
return_status (bool) – Return the status of flip and rotation. Default: False.
- Returns:
- Augmented images and flows. If returned
results only have one element, just return ndarray.
- Return type:
list[ndarray] | ndarray
- basicsr.data.transforms.img_rotate(img, angle, center=None, scale=1.0)[source]¶
Rotate image.
- Parameters:
img (ndarray) – Image to be rotated.
angle (float) – Rotation angle in degrees. Positive values mean counter-clockwise rotation.
center (tuple[int]) – Rotation center. If the center is None, initialize it as the center of the image. Default: None.
scale (float) – Isotropic scale factor. Default: 1.0.
- basicsr.data.transforms.mod_crop(img, scale)[source]¶
Mod crop images, used during testing.
- Parameters:
img (ndarray) – Input image.
scale (int) – Scale factor.
- Returns:
Result image.
- Return type:
ndarray
- basicsr.data.transforms.paired_random_crop(img_gts, img_lqs, gt_patch_size, scale, gt_path=None)[source]¶
Paired random crop. Support Numpy array and Tensor inputs.
It crops lists of lq and gt images with corresponding locations.
- Parameters:
img_gts (list[ndarray] | ndarray | list[Tensor] | Tensor) – GT images. Note that all images should have the same shape. If the input is an ndarray, it will be transformed to a list containing itself.
img_lqs (list[ndarray] | ndarray) – LQ images. Note that all images should have the same shape. If the input is an ndarray, it will be transformed to a list containing itself.
gt_patch_size (int) – GT patch size.
scale (int) – Scale factor.
gt_path (str) – Path to ground-truth. Default: None.
- Returns:
- GT images and LQ images. If returned results
only have one element, just return ndarray.
- Return type:
list[ndarray] | ndarray