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?