'can deconvolution wiener filter reduce noise without having blurred image at the first place?

Hi guys greetings

am trying to denoise many several noises with several filters for a research i have, i found a deconvolution wiener filter made by "mr.tranleanh" on Github, as you can see here .

what I did is that I canceled the blurring part in the code and only add Gaussian noise to my images, and I made a PSNR calculation each time I apply the filter, and for each time I was increasing the size of the Gaussian kernel the PSNR value is getting bigger, so that's mean that the noise is being reduced, and all that without adding blurring to the image.

so am wondering if I can use the wiener filter for reducing noise in this way (without blurring) i mean can a deconvolution wiener filter reduce noise without blurring?, and I also wonder why each time I apply the wiener filter the image is getting darker and darker???

shortly this is how i typed the code :

def add_gaussian_noise(img, sigma):
    gauss = np.random.normal(0, sigma, np.shape(img))
    noisy_img = img + gauss
    noisy_img[noisy_img < 0] = 0
    noisy_img[noisy_img > 255] = 255
    return noisy_img
def wiener_filter(img, kernel, K):
    kernel /= np.sum(kernel)
    dummy = np.copy(img)
    dummy = fft2(dummy)
    kernel = fft2(kernel, s = img.shape)
    kernel = np.conj(kernel) / (np.abs(kernel) ** 2 + K)
    dummy = dummy * kernel
    dummy = np.abs(ifft2(dummy))
    return dummy
def gaussian_kernel(kernel_size = 3):
    h = gaussian(kernel_size, kernel_size / 3).reshape(kernel_size, 1)
    h = np.dot(h, h.transpose())
    h /= np.sum(h)
    return h
def rgb2gray(rgb):
    return np.dot(rgb[...,:3], [0.2989, 0.5870, 0.1140])
if __name__ == '__main__':
    # Load image and convert it to gray scale
    file_name = os.path.join('/content/Hand.jpeg') 
    img = rgb2gray(plt.imread(file_name))
    # Add Gaussian noise
    noisy_img = add_gaussian_noise(blurred_img, sigma = 20)
    # Apply Wiener Filter
    kernel = gaussian_kernel(3)
    filtered_img = wiener_filter(noisy_img, kernel, K = 10)

thanks in advance



Solution 1:[1]

Can a deconvolution wiener filter reduce noise without blurring?

This doesn't work well. If you designed a Wiener deconvolution filter for some blur kernel, yet apply it to an image that actually hasn't been blurred, then the output typically has bad looking ringing artifacts.

But you can design a Wiener filter that's effective for doing just denoising, where it's assumed the input has added noise but hasn't been blurred.

Why each time I apply the wiener filter the image is getting darker and darker???

In the Wiener deconvolution filter np.conj(kernel) / (np.abs(kernel) ** 2 + K), the DC gain is 1 / (1 + K) (noting that kernel is normalized to sum to one). So the output image is darker by that factor. This can be avoided by replacing the scalar K with something frequency-dependent like constant * (frequency_x**2 + frequency_y**2).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pascal Getreuer