module api.transforms.image.photometric
function Normalize
Normalize the image and convert BGR2RGB.
Args:
-
img
(np.ndarray): original image. -
mean
(sequence): Mean values of 3 channels. -
std
(sequence): Std values of 3 channels. -
to_rgb
(bool): Whether to convert the image from BGR to RGB, default is true.
Returns:
dict
: {'img': Normalized results, 'img_norm_cfg': {'mean': ..., 'std': ..., 'to_rgb':...}}
function ToTensor
Args:
img
(np.ndarray): (1) transpose (HWC->CHW), (2)to tensor
Returns:
a torch.Tensor
function PhotoMetricDistortion
PhotoMetricDistortion(
img,
brightness_delta=32,
contrast_range=(0.5, 1.5),
saturation_range=(0.5, 1.5),
hue_delta=18
)
Apply photometric distortion to image sequentially, every dictprocessation is applied with a probability of 0.5. The position of random contrast is in second or second to last.
-
random brightness
-
random contrast (mode 0)
-
convert color from BGR to HSV
-
random saturation
-
random hue
-
convert color from HSV to BGR
-
random contrast (mode 1)
Args:
-
img
(np.ndarray): imput image. -
brightness_delta
(int): delta of brightness. -
contrast_range
(tuple): range of contrast. -
saturation_range
(tuple): range of saturation. -
hue_delta
(int): delta of hue.
Returns:
dict
: distorted_image