hi guys greetings
I am doing a research, where I should apply a Wiener filter on a number of images that are affected by several types of noises like speckle and salt&paper noise, then I will calculate the PSNR values of each filtered image to find the effectiveness of filtering these types of noises using the wiener filter, from what I understand about wiener filter that I need to deconvolve the blurring kernel that's being applied on an image, and luckily I found this code on the web that shows how to apply a wiener filter, and here how its look :
first: setting up the blurring kernel
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
second: define the wiener filter
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
finally: apply the filter
kernel = gaussian_kernel(3)
filtered_img = wiener_filter(noisy_img, kernel, K = 10)
The issue that I faced, is that I don't know how to apply the same filter on images being affected by noises like Speckle or Salt&Pepper, so I don't know what to do, should I keep the blurring kernel as it is here and apply the wiener filter function on my noised images, or should I approximate a kernel for the Speckle/Salt&Pepper noise, and if so, how to do it?
thanks in regard, and I want to mention :
- I know you may find the same question being published on StackOverflow, but it's for Matlab, not python.
- I really tried hard and did a lot of research before publishing my question here, but I still can't figure out just this problem in wiener filters.
and I really appreciate every reader's time, and sorry if I took long.