28 January 2010 0 Comments

Howto Estimate Noise Variance in Matlab

Welcome to Stone Studio!

Assuming that the deterministic function y has additive Gaussian noise, evar(y) returns an estimated variance of this noise. A thin-plate smoothing spline model is used to smooth y. It is assumed that the model whose generalized cross-validation score is minimum can provide the variance of the additive noise. A few tests showed that evar works very well with "not too irregular" functions.

Create a deterministic signal with 1000 data points and add Gaussian noise whose variance ranges from 0 to 0.5

n = 1e3;
x = linspace(0,25,n);
y = round(sin(x));
sig2 = linspace(0,0.5,50);

As an example, this figure shows the effect of an additive noise with a variance of 0.2 (original signal in black, noisy signal in red).

yn = y + sqrt(0.2)*randn(size(x));
plot(x,yn,'r',x,y,'k')

 evar

Estimate the variance of the additive noise by using evar

sig2_est = zeros(1,50);
for i = 1:50
    yn = y + sqrt(sig2(i))*randn(1,n);
    sig2_est(i) = evar(yn);
end

Compare the estimated variance (sig2_est) with the true variance (sig2)

plot(sig2_est,sig2,'o',[0 0.5],[0 0.5],'k')
axis([-0.05 0.55 -0.05 0.55])
axis square
xlabel('Estimated variance')
ylabel('True variance')

evar2

 

Reference:

Buckley MJ, Fast computation of a discretized thin-plate smoothing spline for image data, Biometrika, 81, 2, 1994, pp 247-258.

This paper describes a fast method of computation for a discretized version of the thin-plate spline for image data. This method uses the Discrete Cosine Transform and is contrasted with a similar approach based on the Discrete Fourier Transform. The two methods are similar from the point of view of speed, but the errors introduced near the edge of the image by use of the Discrete Fourier Transform are significantly reduced when the Discrete Cosine Transform is used. This is because, while the Discrete Fourier Transform implicitly assumes periodic boundary conditions, the Discrete Cosine Transform uses reflective boundary conditions. It is claimed that the Discrete Cosine Transform may profitably be used in place of the Discrete Fourier Transform in a variety of image processing applications besides spline smoothing.

This function can be downloaded Here, Thanks to Damien Garcia made it available.

Tags: