-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp_psnr.m
More file actions
31 lines (31 loc) · 705 Bytes
/
comp_psnr.m
File metadata and controls
31 lines (31 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% INPUTS:
% im: orginal image
% imf: reconstructed image
% imn: noisy image (OPTIONAL)
%
% Usage:
% addpath('E:\THESIS\Implements\Pedagogical');
% PSNR=comp_psnr(im,imf)
% [PSNR,SSIM]=comp_psnr(im,imf)
% [PSNR,SSIM,ISNR]=comp_psnr(im,imf,imn)
%
% Ashkan
function [PSNR,SSIM,ISNR]=comp_psnr(im,imf,imn)
MSE=mean(mean((im(:)-imf(:)).^2));
if max(im(:))<2
MaxI=1;
else
MaxI=255;
end
PSNR=10*log10((MaxI^2)/MSE);
%
if nargout>1
if MaxI == 1
SSIM=ssim_index(im*255,imf*255); % or "ssim(imf,im)"
else
SSIM=ssim_index(im,imf); % or "ssim(imf,im)"
end
end
if nargout>2 && (exist('imn','var') || ~ieempty(imn))
ISNR=10*log10((mean(mean((im(:)-imn(:)).^2))/MSE));
end