# Noise estimation SNR matrix

I have a signal matrix which is a $256\times 192$, and I want to calculate the SNR considering that my $259\times 192$ matrix is an average of a $256\times 192\times 330$ matrix, where $330$ is the number of frames, after a reshape I have obtained a $256\times 192$ matrix. So my code is:

signal = 256x192x256;

signal_average = mean(signal,3);
noise_estimation = signal_average - repmat(mean(signal_average,2),1);
signal_power = mean(abs(signal_average).^2);
noise_power = mean(abs(noise_estimation).^2,2);
SNR = 10*log10(signal_power./noise_power);


Is it correct to use this approach in order to obtain a matrix with different SNR for each frame?

In your case you probably want to calculate the SNR as mean over standard deviation.

signal=rand([256,192,330]); %demo data
SNR = mean(signal,3)./std(signal,[],3);
SNRdb = 10*log10(SNR);


this way you obtain different SNR values per pixel. 256x192 pixels in 330 frames.

To get the values for each of the 330 frames instead you must first reshape your matrix.

signal=reshape(signal,[],330);  %pixel values merged
SNR = mean(signal)./std(signal);
SNRdb = 10*log10(SNR);

• For me the noise is the subtraction of the mean of the signal (the image (i,j)) in each frame. So maybe is not the case of estimating the noise as std(signal), what do you think? And why don't you consider the power of the signal? – CirugiaoM Jul 27 '17 at 10:23
• Let's take this example data: [10,13,14,12,15] What is the noise, what is the signal? If it is intensity data it makes sens to take the mean as the actuall intensity: 12.8 . What is the noise? How far are they from the mean? [-2.8 0.2 1.2 -0.8 2.2] But the sum will be 0. So we square first. [7.84 0.04 1.44 0.64 4.84]. Then sum: 14.8. But the size of this value also depends on the number of values. So we divide by (N-1)=4 => 3.7. This is the variance. But it is based on the squared difference from the mean. Take the square root. 1.92. That is the standard deviation. So SNR=6.65 – Gelliant Jul 27 '17 at 11:11
• In other words: The standard deviation is a measure for how far values are deviating from the mean. It all starts with the subtraction of the mean. Your -power of the signal- is probably just the square of the devation from the mean. The second step. – Gelliant Jul 27 '17 at 11:16
• Maybe you want to use another noise estimator, like the average absolute deviation: https://en.wikipedia.org/wiki/Average_absolute_deviation, but this is not common for estimating the SNR as far as I know. – Gelliant Jul 27 '17 at 11:26
• Thank you @Gelliant, the problem here is that I expected a decaying signal, but it seems constant without decaying. ;) – CirugiaoM Jul 27 '17 at 11:36