Within Matlab I'm adding noise to an image with a known varian开发者_运维技巧ce. 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?
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)
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));
精彩评论