I have been using the function mentioned here to add different types of noise (Gauss, salt and pepper, etc) to an image.
However, I am trying to build an input pipeline using tf.data.Dataset. I think I have figured out how to add Gaussian and Poisson noise:
@tf.function
def load_images(imagePath):
label = tf.io.read_file(base_path + "/clean/" + imagePath)
label = tf.image.decode_jpeg(label, channels=3)
label = tf.image.convert_image_dtype(label, dtype=tf.float32)
image=label+tf.random.normal(shape=tf.shape(label),mean=0,stddev=0.1**0.5) #Add Gauss noise
#image=label+tf.random.poisson(shape=tf.shape(label),lam=0.3) #Add Poisson noise
return (image, label)
How could I add salt & pepper and speckle noise, as well?