Skip to content

Commit 051e127

Browse files
authored
Merge pull request #12 from up42/metrics_improvements
Metrics improvements
2 parents 03febbd + d14ea5e commit 051e127

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

image_similarity_measures/quality_metrics.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def rmse(org_img: np.ndarray, pred_img: np.ndarray, data_range=4096):
2525
_assert_image_shapes_equal(org_img, pred_img, "RMSE")
2626
rmse_final = []
2727
for i in range(org_img.shape[2]):
28-
m = np.mean(((org_img[:, :, i] - pred_img[:, :, i]) / data_range) ** 2)
28+
m = np.mean(np.square((org_img[:, :, i] - pred_img[:, :, i]) / data_range))
2929
s = np.sqrt(m)
3030
rmse_final.append(s)
3131
return np.mean(rmse_final)
@@ -226,7 +226,7 @@ def sam(org_img: np.ndarray, pred_img: np.ndarray):
226226
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)
227227
sam_angles[i] = np.arccos(val)
228228

229-
return np.mean(sam_angles)
229+
return np.mean(sam_angles * 180.0 / np.pi)
230230

231231

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

238238
sre_final = []
239239
for i in range(org_img.shape[2]):
240-
numerator = (np.mean(org_img[:, :, i]))**2
240+
numerator = np.square(np.mean(org_img[:, :, i]))
241241
denominator = ((np.linalg.norm(org_img[:, :, i] - pred_img[:, :, i]))) /\
242242
(org_img.shape[0] * org_img.shape[1])
243243
sre_final.append(10 * np.log10(numerator/denominator))

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="image-similarity-measures",
8-
version="0.1.2",
8+
version="0.2.2",
99
author="UP42",
1010
author_email="[email protected]",
1111
description="Evaluation metrics to assess the similarity between two images.",

0 commit comments

Comments
 (0)