Wiener Filter

  • It is an adaptive low pass filtering technique.
  • It filters the image pixel-wise.
  • It is a type of linear filter.

Syntax: 

J = wiener2(I,[m n],noise)

I = grayscale input image
[m n] = neighbouring window size

The wiener2 function applies a Wiener filter to an image adaptively. The Wiener filter sticks itself to the variance of the local image. Wiener2 performs little smoothing, wherever the variance is large. Wiener2 performs more smoothing, wherever the variance is small.

Syntax:

 k=imread(“einstein_colored); // To read the image:

 denoised=wiener2(noisy_image, [5 5]);

//To get the filtered image using Wiener filter

 imshowpair(P{noisy, denoised}); title(noisy vs denoised’);

//To display the noisy and denoised image side by side in single frame

here, weiner2( ) is an inbuilt function, it takes 2 parameters here. 1. Noisy image to be filtered2. Size of the neighboring window.

Example:

Matlab




% MATLAB code for Wiener2 filter
k=imread("einstein_colored.png");
k=rgb2gray(k);
  
% different noise with their parameters
gaussian_noise=imnoise(k,'gaussian',0,0.025);
poisson_noise=imnoise(k,'poisson');
salt_noise=imnoise(k,'salt & pepper', 0.05);
speckle_noise=imnoise(k,'speckle', 0.05);
  
% wiener filter with different noise
gaussian_denoised=wiener2(gaussian_noise, [5 5]);
poisson_denoised=wiener2(gaussian_noise, [5 5]);
salt_denoised=wiener2(salt_noise, [5 5]);
speckle_denoised=wiener2(speckle_noise, [5 5]);
   
imshowpair(gaussian_noise, gaussian_denoised, 'montage');
imshowpair(poisson_noise, poisson_denoised, 'montage');
imshowpair(salt_noise, salt_denoised, 'montage');
imshowpair(speckle_noise, speckle_denoised, 'montage');


Output:

 Figure: Gaussian noise

 

Figure: Poisson noise

 

Figure: Salt and pepper noise

 

Figure: Speckle noise

Code Explanation:

  • k=imread(“einstein_colored); This line reads the image.
  • k=rgb2gray(k); this line converts into grayscale.
  • gaussian_noise = imnoise(k, ‘gaussian’, 0, 0.01); this line creates the image corrupted with gaussian noise.
  • poisson_noise = imnoise(k, ‘poisson’); this line creates the image corrupted with poisson noise.
  • salt_noise = imnoise(k, ‘salt & pepper’, 0.05); this line creates the image corrupted with salt and pepper noise with 5 % of total pixels.
  • speckle_noise = imnoise(k, ‘speckle’, 0.05); this line corrupts the image with speckle noise of 0.05 variance.
  • gaussian_denoised=wiener2(gaussian_noise, [5 5]); this line applies the filter on gaussian noised image using window size [5 5]
  • poisson_denoised=wiener2(gaussian_noise, [5 5]); this line applies the filter on poisson noised image using window size [5 5]
  • salt_denoised=wiener2(salt_noise, [5 5]); this line applies the filter on gaussian salt and pepper image using window size [5 5]
  • speckle_denoised=wiener2(speckle_noise, [5 5]); this line applies the filter on speckle noised image using window size [5 5]
  • imshowpair(gaussian_noise, gaussian_denoised, ‘montage’); this line displays the gaussian noised image and denoised image side by side in the same frame.
  • imshowpair(poisson_noise, poisson_denoised, ‘montage’); this line displays the poisson noised image and denoised image side by side in same frame.
  • imshowpair(salt_noise, salt_denoised, ‘montage’); this line displays the salt and pepper noised image and denoised image side by side in same frame.
  • imshowpair(speckle_noise, speckle_denoised, ‘montage’); this line displays the speckle noised image and denoised image side by side in same frame.

The adaptive approach often produces satisfactory results than linear filtering. The property of an adaptive filter is that it is more selective than a comparable linear filter because it preserves the edges and other high-frequency parts of an image.  There is one drawback of this, Wiener2 does require more computation time than another linear filtering.

When the noise is constant-power additive noise, such as Gaussian white noise; wiener2 gives the best results. 



What are different types of denoising filters in MATLAB?

Digital images are prone to various types of noise that make the quality of the images worst. Image noise is a random variation of brightness or color information in the captured image. Noise is basically the degradation in image signal caused by external sources such as cameras. Images containing multiplicative noise have the characteristic that the brighter the area the noisier it. We shall discuss various denoising filters in order to remove these noises from the digital images. 

Types of filters discussed in this article are listed as:

  • Mean filter
  • Median filter
  • Gaussian filter  
  • Wiener filter

Similar Reads

Mean Filter

It is also called as Box Averaging filtering technique.  It uses a kernel and is based on convolution. It calculates the average of all a pixel and its surrounding pixels and the result is assigned to the central pixel. It is a very effective technique for the removal of Poisson noise....

Median Filter

...

Gaussian Filter

A Median filter is a non-linear filter. It sorts the pixels covered by the window and sorts them in ascending order then returns the median of them....

Wiener Filter

...

Contact Us