Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 132f0c26 authored by DIB Elian's avatar DIB Elian Committed by Elian Dib
Browse files

Compute ssim depending on number of output arguments

parent 968d0297
Branches master
No related tags found
No related merge requests found
function [psnr_y,ssim_y,psnr_yuv,ssim_yuv,psnr_u,ssim_u,psnr_v,ssim_v] = ...
qualityMetrics(rec,ref,varargin)
function [psnr_y,psnr_yuv,psnr_u,psnr_v,ssim_y,ssim_yuv,ssim_u,ssim_v] = ...
qualityMetrics(rec,ref,n,varargin)
%QUALITYMETRICS Summary of this function goes here
% Detailed explanation goes here
if (nargin < 3)
if ~exist('n','var')
dr = diff(getrangefromclass(rec));
n = log2(double(dr)+1);
else
n = varargin{1};
dr = 2^n-1;
end
compute_ssim = nargout>4;
numchan = size(rec,3);
ssim_y = nan;
ssim_yuv = nan;
ssim_u = nan;
ssim_v = nan;
if numchan==1
psnr_y = psnr(rec(:,:,1),ref(:,:,1),dr);
psnr_u = nan;
......@@ -20,14 +26,12 @@ if numchan==1
psnr_yuv = nan;
ssim_y = ssim(rec(:,:,1),ref(:,:,1),'DynamicRange',dr);
ssim_u = nan;
ssim_v = nan;
ssim_yuv = nan;
if compute_ssim
ssim_y = ssim(rec(:,:,1),ref(:,:,1),'DynamicRange',dr);
end
elseif numchan==3
rec = utils.rgb2ycbcr(rec,n,varargin{2:end});
ref = utils.rgb2ycbcr(ref,n,varargin{2:end});
rec = utils.rgb2ycbcr(rec,n,varargin{:});
ref = utils.rgb2ycbcr(ref,n,varargin{:});
psnr_y = psnr(rec(:,:,1),ref(:,:,1),dr);
psnr_u = psnr(rec(:,:,2),ref(:,:,2),dr);
......@@ -35,11 +39,13 @@ elseif numchan==3
psnr_yuv = (6*psnr_y + psnr_u + psnr_v)/8;
ssim_y = ssim(rec(:,:,1),ref(:,:,1),'DynamicRange',dr);
ssim_u = ssim(rec(:,:,2),ref(:,:,2),'DynamicRange',dr);
ssim_v = ssim(rec(:,:,3),ref(:,:,3),'DynamicRange',dr);
ssim_yuv = ssim(rec,ref,'DynamicRange',dr);
if compute_ssim
ssim_y = ssim(rec(:,:,1),ref(:,:,1),'DynamicRange',dr);
ssim_u = ssim(rec(:,:,2),ref(:,:,2),'DynamicRange',dr);
ssim_v = ssim(rec(:,:,3),ref(:,:,3),'DynamicRange',dr);
ssim_yuv = ssim(rec,ref,'DynamicRange',dr);
end
else
error('Unexpected number of channels');
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment