Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade skimage #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"""
import numpy as np
from scipy.signal import convolve2d
from skimage.measure import compare_psnr, compare_ssim
from skimage.metrics import peak_signal_noise_ratio, structural_similarity


def compare_ergas(x_true, x_pred, ratio):
"""
Expand Down Expand Up @@ -103,7 +104,7 @@ def compare_mpsnr(x_true, x_pred, data_range):
"""
x_true, x_pred = x_true.astype(np.float32), x_pred.astype(np.float32)
channels = x_true.shape[2]
total_psnr = [compare_psnr(im_true=x_true[:, :, k], im_test=x_pred[:, :, k], data_range=data_range)
total_psnr = [peak_signal_noise_ratio(image_true=x_true[:, :, k], image_test=x_pred[:, :, k], data_range=data_range)
for k in range(channels)]

return np.mean(total_psnr)
Expand All @@ -118,7 +119,7 @@ def compare_mssim(x_true, x_pred, data_range, multidimension):
:param multidimension:
:return:
"""
mssim = [compare_ssim(X=x_true[:, :, i], Y=x_pred[:, :, i], data_range=data_range, multidimension=multidimension)
mssim = [structural_similarity(X=x_true[:, :, i], Y=x_pred[:, :, i], data_range=data_range, multidimension=multidimension)
for i in range(x_true.shape[2])]

return np.mean(mssim)
Expand Down