1
votes

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?

2
I'm not sure that this formula is really what you need. Can you provide a source where you found it? Was it in a paper?Phonon
@Phonon - I'm looking for a reference now, I'm pretty certain I read it in a paper a while back. Intuitively I thought it makes sense, i.e. after the high pass filtering you're left with noise and edge detail, as noise dominates in quantity, the median should be a reasonable estimate of the noise variancetrican
aha I realised what the problem was... there should be an additional scaling factor of 1/0.675 - that then gives a very reasonable esimtate of 0.00926trican
So you got it working? You should post it as an answer if you did so that other people could come along and look at it.Phonon
@Phonon it doesn't always seem to give reasonable answers - so I'll wait to see if anyone else has commentstrican

2 Answers

2
votes

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)

1
votes

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));