Skip to content

Commit

Permalink
Merge pull request #12 from up42/metrics_improvements
Browse files Browse the repository at this point in the history
Metrics improvements
  • Loading branch information
markusuwe committed Sep 16, 2020
2 parents 03febbd + d14ea5e commit 051e127
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions image_similarity_measures/quality_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def rmse(org_img: np.ndarray, pred_img: np.ndarray, data_range=4096):
_assert_image_shapes_equal(org_img, pred_img, "RMSE")
rmse_final = []
for i in range(org_img.shape[2]):
m = np.mean(((org_img[:, :, i] - pred_img[:, :, i]) / data_range) ** 2)
m = np.mean(np.square((org_img[:, :, i] - pred_img[:, :, i]) / data_range))
s = np.sqrt(m)
rmse_final.append(s)
return np.mean(rmse_final)
Expand Down Expand Up @@ -226,7 +226,7 @@ def sam(org_img: np.ndarray, pred_img: np.ndarray):
val = np.clip(np.dot(org_img[:, i], pred_img[:, i]) / (np.linalg.norm(org_img[:, i]) * np.linalg.norm(pred_img[:, i])), -1, 1)
sam_angles[i] = np.arccos(val)

return np.mean(sam_angles)
return np.mean(sam_angles * 180.0 / np.pi)


def sre(org_img: np.ndarray, pred_img: np.ndarray):
Expand All @@ -237,7 +237,7 @@ def sre(org_img: np.ndarray, pred_img: np.ndarray):

sre_final = []
for i in range(org_img.shape[2]):
numerator = (np.mean(org_img[:, :, i]))**2
numerator = np.square(np.mean(org_img[:, :, i]))
denominator = ((np.linalg.norm(org_img[:, :, i] - pred_img[:, :, i]))) /\
(org_img.shape[0] * org_img.shape[1])
sre_final.append(10 * np.log10(numerator/denominator))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="image-similarity-measures",
version="0.1.2",
version="0.2.2",
author="UP42",
author_email="support@up42.com",
description="Evaluation metrics to assess the similarity between two images.",
Expand Down

0 comments on commit 051e127

Please sign in to comment.