Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gamma_augmentation(x):
- z_value = np.random.uniform(-0.25, 0.25)
- nominator = np.log(0.5 + 2 ** (-0.5) * z_value)
- denominator = np.log(0.5 - 2 ** (-0.5) * z_value)
- gamma_value = nominator / (denominator + EPSILON)
- return x ** gamma_value
- def poisson_noise(x):
- peak = np.random.uniform(0.95, 1.0)
- noisy = np.random.poisson(x * 255.0 * peak) / peak / 255.0
- noisy = np.clip(noisy, 0.0, 1.0)
- return noisy
- def brightness_change(x):
- x = cv2.cvtColor((x * 255).astype(np.float32), cv2.COLOR_RGB2HSV)
- random_bright = .5 + np.random.random()
- x[:, :, 2] *= random_bright
- x[:, :, 2] = np.clip(x[:, :, 2], 0, 255)
- x = cv2.cvtColor(x, cv2.COLOR_HSV2BGR)
- return x / 255.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement