diff --git a/DRPCA_Net/US_ADM_calc_PSNR.m b/DRPCA_Net/US_ADM_calc_PSNR.m new file mode 100644 index 0000000000000000000000000000000000000000..14710c43583f96e19966b6324d4e290914b03c67 --- /dev/null +++ b/DRPCA_Net/US_ADM_calc_PSNR.m @@ -0,0 +1,39 @@ +function [Metrics] = US_ADM_calc_PSNR(img1,img2) +%% US_ADM_calc_PSNR Calculates the Peak Signal-to-Noise Ratio. +% PSNR = US_ADM_calc_PSNR(img1,img2) +% +% img1: reference image +% img2: output image +% +% ---------------------- +% | Code: Renaud Morin | +% | Email: morin@irit.fr | +% | Date: July 2011 | +% ---------------------- + + +%% Initialization +if nargin~=2 + error('MATLAB:paramAmbiguous','There must be exactly 2 arguments.') +end +if size(img1)~=size(img2) + error('MATLAB:paramAmbiguous','Inputs must be of same size') +end + + +%% Process +d= max(abs([img1(:);img2(:)])); +MSE=sum( (img1(:)-img2(:)).^2 )/numel(img1); +MSE1 = MSE; +PSNR=10*log10(d^2/MSE); +RMSE = sqrt(MSE); +MSE = MSE/(sum((img1(:)).^2)); +NRMSE = sqrt(MSE*numel(img1)); +% assignement +Metrics.MSE=MSE1; +Metrics.PSNR = PSNR; +Metrics.RMSE = RMSE; +Metrics.NRMSE = NRMSE; + + +