Image Processing Toolbox User's Guide |

**Using Adaptive Filtering**

The `wiener2`

function applies a Wiener filter (a type of linear filter) to an image *adaptively,* tailoring itself to the local image variance. Where the variance is large, `wiener2`

performs little smoothing. Where the variance is small, `wiener2`

performs more smoothing.

This approach often produces better results than linear filtering. The adaptive filter is more selective than a comparable linear filter, preserving edges and other high-frequency parts of an image. In addition, there are no design tasks; the `wiener2`

function handles all preliminary computations and implements the filter for an input image. `wiener2`

, however, does require more computation time than linear filtering.

`wiener2`

works best when the noise is constant-power ("white") additive noise, such as Gaussian noise. The example below applies `wiener2`

to an image of Saturn that has had Gaussian noise added. For an interactive demonstration of filtering to remove noise, try running `nrfiltdemo`

.

RGB = imread('saturn.png'); I = rgb2gray(RGB); J = imnoise(I,'gaussian',0,0.005); K = wiener2(J,[5 5]); imshow(J) figure, imshow(K)

**Noisy Version (left) and Filtered Version (right)
**

Using Median Filtering | Region-Based Processing |

© 1994-2005 The MathWorks, Inc.