私はref
をダブルに変換していると思います。なぜそれをダブルに変換していますか? psnr
が定義PSNR
あたりとして負になることはありません、あなたの問題に最初にしてこれらのコードを試してください:
上記のコードのうち
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);
がある:あなたのケースで
The Peak-SNR value is 22.6437
The SNR value is 15.5524
、次のようにお試しください:
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);
希望はこのwiですあなたを助けるでしょう。
https://dsp.stackexchange.com/questions/22741/is-it-possible-to-have-negative-psnrが適切かもしれません。私が知る限り、MATLABのpsnr関数は方程式に従っているだけで、何も気にしません。 – akamath