% Copyright (C) 2016 by Deanna Needell, Rayan Saab, and Tina Woolf

% This file is part of ''Weighted L1-Minimization for Sparse Recovery under
%                        Arbitrary Prior Information''

% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.

% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.

% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.

% psnr2.m

function psnr = psnr2(Xhat, X)
% Inputs:
% Xhat = estimated signal
% X    = true signal
%
% Output:
% psnr = Peak-SNR between Xhat and X

N = size(Xhat,1) * size(Xhat,2);
psnr = 10 * log10( (N * 255^2) / norm(X(:) - Xhat(:),2)^2 );