Function File: J = wiener2 (I)
Function File: J = wiener2 (I, nhood)
Function File: J = wiener2 (I, noise)
Function File: J = wiener2 (I, nhood, noise)
Function File: [J, noise] = wiener2 (…)

Apply an adaptive noise reduction filter.

The wiener2 function locally applies a linear averaging filter to the input image I. The averaging operation will be performed using a neighbourhood of each pixel of size nhood. The strength of the averaging depends on the local variance in this neighborhood and on the given variance of the noise (of mean zero). As a result, pixels in a region with higher contrast will be smoothed less, and pixels in a region with lower contrast will be smoothed more.

This operation is useful to remove noise from the image, while blurring edges much less compared to a global linear averaging filter.

nhood defaults to repmat (3, [1 ndims(I)]) which in the most common case of 2D images would be [3 3]. The noise variance will be estimated by the mean variance in the neighborhoods, if not given.

Despite the function name, I may have any number of dimensions. However, beware of singleton dimensions and border effects because nhood defaults to a vector of 3’s for all dimensions. It may be adequate to manually set nhood to length 1 for singleton dimensions. Also, in the specific case of RGB images where I is an array of size MxNx3, nhood will default to [3 3 3] while [3 3] may be more useful.

See also: imfilter, medfilt2.

Demonstration 1

The following code

 I = phantom ();
 J = imnoise (I, "gaussian", 0, 0.02);
 figure, imshow (J);
 title ("Image with added Gaussian noise");
 K = wiener2 (J, [5 5]);
 figure, imshow (K);
 title ("Image with noise reduced by wiener2 filtering");

Produces the following figures

Figure 1 Figure 2

Package: image