Gaussian Noise won't apply all over the image

Viewed 52

I'm trying to apply gaussian noise to an image.

image = cv.imread("../../jap.png")
row,col,ch= image.shape
mean = 0
var = 200
sigma = var**0.5
gauss = np.random.normal(mean,sigma,(row,col,ch))
gauss = gauss.reshape(row,col,ch).astype('uint8')
gauss = (gauss - gauss.min())/(gauss.max()-gauss.min()).astype('uint8') *255
noisy = (image + gauss)

but in the output, I get the noise is only applied to the background.

Input Output

1 Answers

Error is because of its clipping values at 255. Remove astype('uint8') *255

row,col,ch= image.shape
mean = 0
var = 200
sigma = var**0.5
gauss = np.random.normal(mean,sigma,(row,col,ch))
gauss = gauss.reshape(row,col,ch).astype("uint8")
noisy = (noisy - noisy.min())/(noisy.max()-noisy.min())
noisy = (image + gauss)
Related