本文整理汇总了Python中torchvision.transforms.functional.adjust_gamma方法的典型用法代码示例。如果您正苦于以下问题:Python functional.adjust_gamma方法的具体用法?Python functional.adjust_gamma怎么用?Python functional.adjust_gamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torchvision.transforms.functional
的用法示例。
在下文中一共展示了functional.adjust_gamma方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cv_transform
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def cv_transform(img):
# img = resize(img, size=(100, 300))
# img = to_tensor(img)
# img = normalize(img, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
# img = pad(img, padding=(10, 10, 20, 20), fill=(255, 255, 255), padding_mode='constant')
# img = pad(img, padding=(100, 100, 100, 100), fill=5, padding_mode='symmetric')
# img = crop(img, -40, -20, 1000, 1000)
# img = center_crop(img, (310, 300))
# img = resized_crop(img, -10.3, -20, 330, 220, (500, 500))
# img = hflip(img)
# img = vflip(img)
# tl, tr, bl, br, center = five_crop(img, 100)
# img = adjust_brightness(img, 2.1)
# img = adjust_contrast(img, 1.5)
# img = adjust_saturation(img, 2.3)
# img = adjust_hue(img, 0.5)
# img = adjust_gamma(img, gamma=3, gain=0.1)
# img = rotate(img, 10, resample='BILINEAR', expand=True, center=None)
# img = to_grayscale(img, 3)
# img = affine(img, 10, (0, 0), 1, 0, resample='BICUBIC', fillcolor=(255,255,0))
# img = gaussion_noise(img)
# img = poisson_noise(img)
img = salt_and_pepper(img)
return to_tensor(img)
示例2: pil_transform
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def pil_transform(img):
# img = functional.resize(img, size=(100, 300))
# img = functional.to_tensor(img)
# img = functional.normalize(img, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
# img = functional.pad(img, padding=(10, 10, 20, 20), fill=(255, 255, 255), padding_mode='constant')
# img = functional.pad(img, padding=(100, 100, 100, 100), padding_mode='symmetric')
# img = functional.crop(img, -40, -20, 1000, 1000)
# img = functional.center_crop(img, (310, 300))
# img = functional.resized_crop(img, -10.3, -20, 330, 220, (500, 500))
# img = functional.hflip(img)
# img = functional.vflip(img)
# tl, tr, bl, br, center = functional.five_crop(img, 100)
# img = functional.adjust_brightness(img, 2.1)
# img = functional.adjust_contrast(img, 1.5)
# img = functional.adjust_saturation(img, 2.3)
# img = functional.adjust_hue(img, 0.5)
# img = functional.adjust_gamma(img, gamma=3, gain=0.1)
# img = functional.rotate(img, 10, resample=PIL.Image.BILINEAR, expand=True, center=None)
# img = functional.to_grayscale(img, 3)
# img = functional.affine(img, 10, (0, 0), 1, 0, resample=PIL.Image.BICUBIC, fillcolor=(255,255,0))
return functional.to_tensor(img)
示例3: adjust_gamma
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def adjust_gamma(img, gamma, gain=1):
"""Perform gamma correction on an image.
Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:
I_out = 255 * gain * ((I_in / 255) ** gamma)
See https://en.wikipedia.org/wiki/Gamma_correction for more details.
Args:
img (np.ndarray): CV Image to be adjusted.
gamma (float): Non negative real number. gamma larger than 1 make the
shadows darker, while gamma smaller than 1 make dark regions
lighter.
gain (float): The constant multiplier.
"""
if not _is_numpy_image(img):
raise TypeError('img should be CV Image. Got {}'.format(type(img)))
if gamma < 0:
raise ValueError('Gamma should be a non-negative real number')
im = img.astype(np.float32)
im = 255. * gain * np.power(im / 255., gamma)
im = im.clip(min=0., max=255.)
return im.astype(img.dtype)
示例4: gamma
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def gamma(self, gamma_ratio):
self.data = TF.adjust_gamma(self.data, gamma_ratio, gain=1)
示例5: __call__
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def __call__(self, img, mask):
assert img.size == mask.size
return tf.adjust_gamma(img, random.uniform(1, 1 + self.gamma)), mask
示例6: __call__
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def __call__(self, img):
if random.random() < 0.5:
gamma = random.uniform(self.gamma_range[0],self.gamma_range[1])
return TrF.adjust_gamma(img, gamma)
else:
return img
# ===============================label tranforms============================
示例7: torchvision_transform
# 需要导入模块: from torchvision.transforms import functional [as 别名]
# 或者: from torchvision.transforms.functional import adjust_gamma [as 别名]
def torchvision_transform(self, img):
return torchvision.adjust_gamma(img, gamma=0.5)