Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. def gamma_augmentation(x):
  2.     z_value = np.random.uniform(-0.25, 0.25)
  3.     nominator = np.log(0.5 + 2 ** (-0.5) * z_value)
  4.     denominator = np.log(0.5 - 2 ** (-0.5) * z_value)
  5.     gamma_value = nominator / (denominator + EPSILON)
  6.     return x ** gamma_value
  7.  
  8.  
  9. def poisson_noise(x):
  10.     peak = np.random.uniform(0.95, 1.0)
  11.     noisy = np.random.poisson(x * 255.0 * peak) / peak / 255.0
  12.     noisy = np.clip(noisy, 0.0, 1.0)
  13.     return noisy
  14.  
  15.  
  16. def brightness_change(x):
  17.     x = cv2.cvtColor((x * 255).astype(np.float32), cv2.COLOR_RGB2HSV)
  18.     random_bright = .5 + np.random.random()
  19.     x[:, :, 2] *= random_bright
  20.     x[:, :, 2] = np.clip(x[:, :, 2], 0, 255)
  21.     x = cv2.cvtColor(x, cv2.COLOR_HSV2BGR)
  22.     return x / 255.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement