使用 Matlab 估计图像中噪声的方差

发布于 2024-11-28 02:20:15 字数 521 浏览 1 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丑疤怪 2024-12-05 02:20:15

在这种情况下,您的方法结果不足,因为在使用 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)

无敌元气妹 2024-12-05 02:20:15

您可以计算高通滤波图像的方差。不要使用 var 作为变量名称,因为它是计算方差的 Matlab 函数的名称。

v = var; % use v instead of var for your variance variable
clear var; % clear your variable "var" so we can use the var function
est_variance = var(reshape(i_n - imfilter(i_n,kk), [], 1));

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.

v = var; % use v instead of var for your variance variable
clear var; % clear your variable "var" so we can use the var function
est_variance = var(reshape(i_n - imfilter(i_n,kk), [], 1));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文