0

I have done this so far. After image enhancement in frequency domain for assessment, I have calculated PSNR. The value of PSNR and SNR is negative.

Further, the class of input and output image is double.

ref = imread('img.tif');
ref=im2double(ref);
%A = processing(ref);
%Calculate the PSNR.
[peaksnr, snr] = psnr(A, ref);

Can someone help me further?

Annapoornima Koppad
  • 1,376
  • 1
  • 17
  • 30
Mohammad
  • 161
  • 2
  • 10
  • https://dsp.stackexchange.com/questions/22741/is-it-possible-to-have-negative-psnr may be relevant. As far as I know, the MATLAB psnr function simply follows the equations and does not do anything fancy. – akamath May 16 '16 at 03:35

1 Answers1

2

I think you are converting ref into double, why are you converting it into double? psnr will never be negative as per the definition PSNR

Please try these code first and then into your problem:

ref = imread('pout.tif');
A = imnoise(ref,'salt & pepper', 0.02);
% Calculate the PSNR.
[peaksnr, snr] = psnr(A, ref);
fprintf('\n The Peak-SNR value is %0.4f', peaksnr);
fprintf('\n The SNR value is %0.4f \n', snr);

Out of the above code is:

The Peak-SNR value is 22.6437
The SNR value is 15.5524 

In your case, just try following:

ref = imread('img.tif');
A = processing(im2double(ref));% what does it do?
% Check the type of A, is it uint8 data type, if not then convert it to that 
%Calculate the PSNR.
[peaksnr, snr] = psnr(uint8(A), ref);

Hope this will help you.

  • " why are you converting it into double? " for frequency filtering. – Mohammad May 19 '16 at 07:34
  • if you not convert into double then its sum might be wrong because after some range depending upon MATLAB version i.e integer range is 2^32 or 2^64, so what happen after 2^32 sum values, it will loop and start from Zeros. – Veena Singh Aug 04 '16 at 10:21