Search code examples
imagematlabnoise

Calculate SNR in single image in MATLAB


I have this image:

noisy image

I want to calculate SNR in it. For this i used code:

img=imread('noicy.JPG');
img=double(img(:));
ima=max(img(:));
imi=min(img(:));
ims=std(img(:));
snr=20*log10((ima-imi)./ims)

Is that correct code to calculate SNR?


Solution

  • The definition of SNR can be found here or here:

    Both the standard and the industry definition can be used (10log(x) and 20log(x)). check this

    now, the signal is equal to the mean of the pixel values (mean(img(:))) and the noise is the standard deviation or error value of the pixel values (std(img(:))).

    You may use either the ratio or the SNR=10*log10(signal/noise) to express the result in decibel.