From 55a4916eff888e29446e7b551895cb458427d095 Mon Sep 17 00:00:00 2001 From: jacquelinelala Date: Mon, 19 Nov 2018 20:06:47 +0800 Subject: [PATCH] SSIM --- .DS_Store | Bin 12292 -> 10244 bytes evaluation/.DS_Store | Bin 8196 -> 8196 bytes evaluation/test_RGB.m | 9 +++++++-- evaluation/test_bicubic.m | 8 ++++++-- evaluation/utils/evaluate_SR.m | 6 +++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.DS_Store b/.DS_Store index 1f088fa8578b9fd94bba3d4c5b31029d9b8b7239..4bb725a29ddb07ecefbe9248d3150a7cddbbb493 100644 GIT binary patch delta 138 zcmZokXbDhYU|?W$DortDU;r^WfEYvza5FG4aWXJSaBoz2F20#vfrn*swLpugk+G$Y zf|03Ft&T#qp@EUPj)JL)(PR-p)5)KeMK^y}5oDHR1!@NZ1)vEGuE-{B7G!zPJegm{ UmxBpnk;dc%nVFmasjxEx0B>v+N!m$tMKm8Ru+%AsElJ*+XOxHvkiX7OMaN diff --git a/evaluation/test_RGB.m b/evaluation/test_RGB.m index 818f881..9693dd3 100755 --- a/evaluation/test_RGB.m +++ b/evaluation/test_RGB.m @@ -1,5 +1,5 @@ % Description: -% -testting RGB channels PSNR. +% -testting RGB channels PSNR and SSIM. % % Input: % - Validation/Results: some specific group images with limited endings. @@ -31,6 +31,7 @@ function test_RGB(folder) hr_dir = dir(fullfile(hr_path, '*.png')); count = length(hr_dir); PSNR = zeros(count, 1); +SSIM = zeros(count, 1); IFC = zeros(count, 1); ifc = 0; scale = 4; @@ -39,11 +40,15 @@ function test_RGB(folder) fprintf("Calculating %s\n", hr_dir(i).name); HR = imread(fullfile(hr_dir(i).folder, hr_dir(i).name)); Results = imread(fullfile(result_dir(i).folder, result_dir(i).name)); - [PSNR(i), IFC(i)] = evaluate_SR(HR, Results, scale, ifc); + [PSNR(i), SSIM(i), IFC(i)] = evaluate_SR(HR, Results, scale, ifc); end PSNR(count + 1) = mean(PSNR(:)); +SSIM(count + 1) = mean(SSIM(:)); fprintf("Average PSNR is %f\n", PSNR(count + 1)); +fprintf("Average SSIM is %f\n", SSIM(count + 1)); PSNR_path = fullfile(folder, 'Validation_4x', 'PSNR-GFN_4x_HR.txt'); +SSIM_path = fullfile(folder, 'Validation_4x', 'SSIM-GFN_4x_HR.txt'); save_matrix(PSNR, PSNR_path); +save_matrix(SSIM, SSIM_path); diff --git a/evaluation/test_bicubic.m b/evaluation/test_bicubic.m index 13cb738..8eca797 100755 --- a/evaluation/test_bicubic.m +++ b/evaluation/test_bicubic.m @@ -1,7 +1,7 @@ % ------------------------------------------------------------------------- % Description: % Use bicubic to upscale the input, and evaluate the results in terms -% of PSNR. +% of PSNR and SSIM. % % Input: % - Validation/LR_Blur : Blurry low-resolution input @@ -46,13 +46,17 @@ function test_bicubic(folder) LR_Blur = im2double(imread(fullfile(lr_blur_dir(i).folder, lr_blur_dir(i).name))); LR_Blur_Bic = imresize(LR_Blur, 4, 'bicubic'); imwrite(LR_Blur_Bic, fullfile(results_path, strcat(hr_dir(i).name(1:4), 'Bic.png')),'png'); - [PSNR(i), IFC(i)] = evaluate_SR(HR, LR_Blur_Bic, scale, ifc); + [PSNR(i),SSIM(i), IFC(i)] = evaluate_SR(HR, LR_Blur_Bic, scale, ifc); end PSNR(count + 1) = mean(PSNR(:)); +SSIM(count + 1) = mean(SSIM(:)); fprintf("Average PSNR is %f\n", PSNR(count + 1)); +fprintf("Average SSIM is %f\n", SSIM(count + 1)); PSNR_path = fullfile(folder, 'Validation_4x', 'PSNR-LRBlurBic_HR.txt'); +SSIM_path = fullfile(folder, 'Validation_4x', 'SSIM-LRBlurBic_HR.txt'); save_matrix(PSNR, PSNR_path); +save_matrix(SSIM, SSIM_path); diff --git a/evaluation/utils/evaluate_SR.m b/evaluation/utils/evaluate_SR.m index a0b58c3..fcd154d 100755 --- a/evaluation/utils/evaluate_SR.m +++ b/evaluation/utils/evaluate_SR.m @@ -1,7 +1,7 @@ -function [PSNR, IFC] = evaluate_SR(img_GT, img_HR, scale, compute_ifc) +function [PSNR, SSIM, IFC] = evaluate_SR(img_GT, img_HR, scale, compute_ifc) % ------------------------------------------------------------------------- % Description: -% Compute PSNR and IFC for SR +% Compute PSNR SSIM and IFC for SR % We convert RGB image to grayscale and crop boundaries for 'scale' % pixels % @@ -37,7 +37,7 @@ % evaluate PSNR = psnr(img_GT, img_HR); - %SSIM = ssim(img_GT, img_HR); + SSIM = ssim(img_GT, img_HR); %SSIM = 0; % comment IFC to speed up testing