Skip to content

Commit

Permalink
SSIM
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquelinelala committed Nov 19, 2018
1 parent 3d90e4e commit 55a4916
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified evaluation/.DS_Store
Binary file not shown.
9 changes: 7 additions & 2 deletions evaluation/test_RGB.m
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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);

8 changes: 6 additions & 2 deletions evaluation/test_bicubic.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);

6 changes: 3 additions & 3 deletions evaluation/utils/evaluate_SR.m
Original file line number Diff line number Diff line change
@@ -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
%
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55a4916

Please sign in to comment.