I have an image, I add some noise to it and try to denoise it using wiener filter:
Which in case of additive white noise and no blurring simplifies to:
Here is my code according to above formula, however, there is almost no difference with the input image.
import cv2
import numpy as np
img=cv2.imread('Images/P3.jpg',0)
freq2 = np.fft.fft2(img)
mean = 0
var = 100
sigma = var**0.5
gauss = np.random.normal(mean,sigma,np.shape(img))
courrupted=img+gauss
freq2h = np.fft.fft2(gauss)
courrupted[courrupted<0]=0
courrupted[courrupted>255]=255
courrupted=courrupted.astype(np.uint8)
crfre=np.fft.fftshift(np.fft.fft2(courrupted))
sf=np.abs(crfre)**2
wiener=sf/(sf+(100))
F_hat = crfre*wiener
f_hat = np.fft.ifft2( (F_hat))
restored = abs(f_hat)
normalizedImg=np.ones(img.shape)
normalizedImg = cv2.normalize(restored, normalizedImg, 0, 255, cv2.NORM_MINMAX)
cv2.imwrite('output.jpg',normalizedImg)
cv2.imwrite('input.jpg',courrupted)
This is ground truth image:
This is input:
And this is output:





The following works for me in Python/OpenCV/Numpy. As @Cris Luengo suggested, you need to test various values for the noise value, because the value you need may not be exactly your Gaussian variance input value.
Input:
Restored Result for Noise=100000000:
Restored Result for Noise=500000000:
Restored Result for Noise=1000000000:
Restored Result for Noise=5000000000: