[英]How do you add Gaussian Noise to a tif image file in python?
我正在嘗試將高斯噪聲添加到一組 tif 文件中。 我同時使用了 scikit-image 和 cv2。
Scikit-Image: noise_img = random_noise(np_img, mode='gaussian', seed=None, clip=True)
簡歷2:
gauss = gauss.reshape(np_img.shape[0], np_img.shape[1], np_img.shape[2]).astype('uint8')
noise_img = cv2.add(np_img, gauss)
我在傳統的 jpeg 和 png 圖像上使用了這兩種方法,它們都有效。 但是,它們似乎不適用於 tif 文件。 任何幫助,將不勝感激!
According to this documentation, https://www.tensorflow.org/io/api_docs/python/tfio/experimental/image/decode_tiff , you can decode a.tiff image in Tensorflow with the following function:
image = tf.io.read_file(filepath)
image = tfio.experimental.image.decode_tiff(image, index=0, name=None)
稍后您可以添加所需的操作。 請注意,在您的圖像上,您只能在這種情況下使用來自tf*
的函數,而不能使用來自其他庫(例如 PIL 或 OpenCV)的函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.