Shashank Jerri
Shashank Jerri

Reputation: 119

Applying Wiener filter to remove noise using python

This is the what my input image looks like

And this is what my wiener filtered output should look like

The first image is my input image. The second image is a wiener filtered image, which is my output.

Below is the code to use wiener filter on my image. The input image is "img5" and the output image is "Wiener_filtered".

psf = np.ones((5,5)) / 25
img6 = convolve2d(img5,psf,'same')
img6 += 0.1 * img6.std() * np.random.standard_normal(img6.shape)
Wiener_filtered = restoration.wiener(img6,psf,1100) 

Below I have attached the input image "img5" and the outcomes of "img6" and "Wiener_filtered"

Input image img5

Input image "img5"

img6

Outcome of "img6"

Wiener_filtered

The final wiener filtered image

I need help in finding out where i went wrong. I am new to image processing. Can someone show me the correct method.

Upvotes: 4

Views: 24077

Answers (2)

AlpHa03
AlpHa03

Reputation: 25

Try to use : img_as_float from skimage.util. I think it should work :

from skimage.util import img_as_float

img5 = img_as_float(img5)
psf = np.ones((5,5)) / 25
img6 = convolve2d(img5,psf,'same')
img6 += 0.1 * img6.std() * np.random.standard_normal(img6.shape)
Wiener_filtered = restoration.wiener(img6,psf,1100)

Upvotes: 0

tfv
tfv

Reputation: 6259

You may want to check out similar questions at SOF to get a better practical understanding of you to use the algorithm, e.g:

Wiener Filter for image deblur

For improving your basic understanding of denoising, there are helpful tutorials availably for scipy and scikit-image, e.g.:

http://www.scipy-lectures.org/advanced/image_processing/#denoising

Upvotes: 3

Related Questions