使用 Matlab 估计图像中噪声的方差
在 Matlab 中,我向具有已知方差的图像添加噪声。我知道我可以通过以下方式做到这一点:
var = 0.01;
i = im2double(imread('lena.bmp'));
i_n = imnoise(i, 'gaussian',0,var);
显然,生成的图像有噪声。但是,如果我尝试通过计算高通滤波器的中值来估计噪声方差,我真的看不到任何相关性,
k = [1 4 6 4 1]'*[1 4 6 4 1];
kk = k ./sum(sum(k));
var_est = median(median(abs(i_n - imfilter(i_n,kk))))
var_est(:,:,1) =
0.0631
var_est(:,:,2) =
0.0620
var_est(:,:,3) =
0.0625
我很欣赏估计方差是一个困难的问题,但我只想得到一个相当接近的结果,例如 50 % 误差是可以容忍的。我做错了什么?
Within Matlab I'm adding noise to an image with a known variance. I know that I can do that with the following:
var = 0.01;
i = im2double(imread('lena.bmp'));
i_n = imnoise(i, 'gaussian',0,var);
Clearly the resulting image has noise. However if I try to estimate the noise variance by calculating the median of a high pass filter, I'm really not seeing any correlation
k = [1 4 6 4 1]'*[1 4 6 4 1];
kk = k ./sum(sum(k));
var_est = median(median(abs(i_n - imfilter(i_n,kk))))
var_est(:,:,1) =
0.0631
var_est(:,:,2) =
0.0620
var_est(:,:,3) =
0.0625
I appreciate estimating the variance is a difficult problem, but I just want to get a reasonably close result, e.g. 50% error is tolerable. What am I doing incorrect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,您的方法结果不足,因为在使用 imnoise 时,您实际上是添加了白噪声的近似版本,它在所有频率上都表现出分量。使用高通滤波器时,您会剪切噪声的频率分量,从而降低估计的准确性。
事实上,正如您所提到的,仅从一张图像进行噪声估计并不是一个简单的问题。但是,有一些方法,例如您可以使用中值绝对偏差,它可以让您获得近似值数据的分散度(在本例中为内核下的像素强度)
Your approach results inadequate in this case, since when using imnoise you're really adding an approximated version of white noise, which exhibits components at all frequencies. When using a high-pass filter you're clipping frequency components of the noise, thus reducing the accuracy of your estimation.
Indeed noise estimation from only one image, as you mentioned, is not a simple problem. However there are some approaches, for example you can use median absolute deviation that lets you obtain and approximation for the dispersion on your data (in this case for the pixel intensities under your kernel)
您可以计算高通滤波图像的方差。不要使用
var
作为变量名称,因为它是计算方差的 Matlab 函数的名称。You can take calculate variance of the high pass filtered image. Don't use
var
for your variable name because it's the name of the Matlab function which calculates variance.