# wiener2

## 语法

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

## 说明

``J = wiener2(I,[m n],noise)` 使用像素级自适应低通 Wiener 滤波器对灰度图像 `I` 进行滤波。`[m n]` 指定用于估计局部图像均值和标准差的邻域的大小（`m`×`n`）。加性噪声（高斯白噪声）功率假定为 `noise`。输入图像的质量已被恒定功率加性噪声降低。`wiener2` 基于从每个像素的局部邻域估计的统计量使用像素级自适应 Wiener 方法。`

``[J,noise_out] = wiener2(I,[m n])` 返回 `wiener2` 在进行滤波之前计算的加性噪声功率的估计值。`

## 示例

`RGB = imread('saturn.png');`

`I = im2gray(RGB);`

`J = imnoise(I,'gaussian',0,0.025);`

```imshow(J(600:1000,1:600)); title('Portion of the Image with Added Gaussian Noise');```

`K = wiener2(J,[5 5]);`

```figure imshow(K(600:1000,1:600)); title('Portion of the Image with Noise Removed by Wiener Filter');```

## 算法

`wiener2` 估计每个像素周围的局部均值和方差。

`$\mu =\frac{1}{NM}\sum _{{n}_{1},{n}_{2}\in \eta }a\left({n}_{1},{n}_{2}\right)$`

`${\sigma }^{2}=\frac{1}{NM}\sum _{{n}_{1},{n}_{2}\in \eta }{a}^{2}\left({n}_{1},{n}_{2}\right)-{\mu }^{2},$`

`$b\left({n}_{1},{n}_{2}\right)=\mu +\frac{{\sigma }^{2}-{\nu }^{2}}{{\sigma }^{2}}\left(a\left({n}_{1},{n}_{2}\right)-\mu \right),$`

## 参考

[1] Lim, Jae S. Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, p. 548, equations 9.44, 9.45, and 9.46.