Created
May 17, 2018 07:11
-
-
Save jiemojiemo/0f7768418d15aeb267ea457503d07611 to your computer and use it in GitHub Desktop.
Tensorflow Add Gaussian Noise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_gaussian_noise(image): | |
# image must be scaled in [0, 1] | |
with tf.name_scope('Add_gaussian_noise'): | |
noise = tf.random_normal(shape=tf.shape(image), mean=0.0, stddev=(50)/(255), dtype=tf.float32) | |
noise_img = image + noise | |
noise_img = tf.clip_by_value(noise_img, 0.0, 1.0) | |
return noise_img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You helped me a lot !