Signal to noise ratio color image (code) for dB

I am trying to compute signal to noise ratio (dB) in color images as follows:
noisydata = imnoise(original,'gaussian',0.0,0.1); % mean = 0.0, variance = 0.1
[var_orgR, var_noiseR] = snr(noisydata(:,:,1),original(:,:,1));
[var_orgR, var_noiseR] = snr(noisydata(:,:,2),original(:,:,2));
[var_orgR, var_noiseR] = snr(noisydata(:,:,3),original(:,:,3));
SNR= 10*log10((var_orgR + var_orgG + var_orgB)/(var_noiseR + var_noiseG + var_noiseB));
function [var_original, var_noise] = snr(noisydata, original)
mean_original = mean(original(:));
tmp = original - mean_original;
var_original = sum(tmp(:).^2);
noise = noisydata - original;
mean_noise = mean(noise(:));
tmp = noise - mean_noise;
var_noise = sum(tmp(:).^2);
end
The problem is I get value of SNR = 0.0330, I would like to get SNR in dB like 1 dB, 5 dB, etc.
Could any one please guide/suggest how to obtain SNR in dB?
Thank you. Dbs

Respuestas (2)

Image Analyst
Image Analyst el 3 de Feb. de 2013

0 votos

Where did you get these formulas? I'm not sure I agree with them. In fact I don't, unless you can show me some reference that say otherwise.

5 comentarios

Dadhichi
Dadhichi el 3 de Feb. de 2013
The final SNR is from paper: Subpixel edge detection of color images by principal axis analysis and moment-preserving principle, by Shyi-Chyi Cheng∗, Tian-LuuWu.
Image Analyst
Image Analyst el 3 de Feb. de 2013
Well it's not the formula I'm familiar with, and not the one in Wikipedia either. For example, the signal is the signal minus the mean of the signal, instead of just the original signal like most people use. Then, you're not doing it on a pixel by pixel basis. Then, the mean of logs, is not mathematically the same as the log of means. But whatever, if that formula is used for something in a paper you want to replicate, then go ahead and use it. 10log10() does give units in decibels, so you're okay there. Though you may not be getting the numbers you think you should because that's not the regular formula for SNR.
Dadhichi
Dadhichi el 3 de Feb. de 2013
Hello, I understand your concern, its not the conventional way of computing SNR but its the formula used when three channels are to be considered. Anyways I got the solution :), I just had to change the datatype to 'uint8'. Hope this is helpful to other people.
Image Analyst
Image Analyst el 3 de Feb. de 2013
I don't think that would fix it. I would need proof. Anyway, I don't know what a "fix" is. Like I said, you asked how to get the number in decibels and I told you that it's already in decibels.
Dadhichi
Dadhichi el 4 de Feb. de 2013
What proof do you need? If you have access to papers you'll agree. The code is correct, uint8 was programming error, it is not required. Anyways, 'noisydata' and 'original' should have values in same range i.e. between 0 to 1 (was another programming error) :D .

Iniciar sesión para comentar.

Toqeer Mahmood
Toqeer Mahmood el 9 de Oct. de 2015

0 votos

Dear Dadhichi
I am also confused in the same problem, I also want to find SNR with the whole number as 5dB, 10db, 15dB etc. Please send me the working code to find it, if possible for you (my email is toqeer.mahmood@yahoo.com).
Thanks in advance, waiting for your kind reply.

Categorías

Etiquetas

Preguntada:

el 3 de Feb. de 2013

Respondida:

el 9 de Oct. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by