Skip to content

Commit 03febbd

Browse files
authored
Fix couple of bugs, bump the version. (#11)
1 parent 05ebc53 commit 03febbd

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ pip install image-similarity-measures
3535
#### Evaluation
3636
For doing the evaluation, you can easily run the following command:
3737
```bash
38-
imagery-similarity-measures --org_img_path=path_to_first_img --pred_img_path=path_to_second_img --mode=tif
38+
image-similarity-measures --org_img_path=path_to_first_img --pred_img_path=path_to_second_img --mode=tif
3939
```
4040
If you want to save the final result in a file you can add `--write_to_file` at then end of above command.
4141

42+
**Note** that images that are used for evaluation should be **channel last**.
43+
4244
#### Usage in python
4345
```bash
4446
import image_similarity_measures

image_similarity_measures/evaluate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def write_final_dict(metric, metric_dict):
5656
f.writelines('{}\n'.format(v) for _, v in metric_dict.items())
5757

5858

59-
def evaluation(org_img_path, pred_img_path, mode, write_to_file):
59+
def evaluation(org_img_path, pred_img_path, mode, metric, write_to_file):
6060
metric_dict = {}
6161

6262
if mode == "tif":
@@ -98,7 +98,7 @@ def main():
9898
mode = args.mode
9999
write_to_file = args.write_to_file
100100

101-
evaluation(orgpath, predpath, mode, write_to_file)
101+
evaluation(orgpath, predpath, mode, metric, write_to_file)
102102

103103
if __name__ == "__main__":
104104
main()

image_similarity_measures/quality_metrics.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def _assert_image_shapes_equal(org_img: np.ndarray, pred_img: np.ndarray, metric
1717
assert org_img.shape == pred_img.shape, msg
1818

1919

20-
def rmse(org_img: np.ndarray, pred_img: np.ndarray):
20+
def rmse(org_img: np.ndarray, pred_img: np.ndarray, data_range=4096):
2121
"""
2222
Root Mean Squared Error
2323
"""
2424

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]) ** 2)
28+
m = np.mean(((org_img[:, :, i] - pred_img[:, :, i]) / data_range) ** 2)
2929
s = np.sqrt(m)
3030
rmse_final.append(s)
3131
return np.mean(rmse_final)
@@ -188,6 +188,7 @@ def uiq(org_img: np.ndarray, pred_img: np.ndarray):
188188
"""
189189
Universal Image Quality index
190190
"""
191+
# TODO: Apply optimization, right now it is very slow
191192
_assert_image_shapes_equal(org_img, pred_img, "UIQ")
192193
q_all = []
193194
for (x, y, window_org), (x, y, window_pred) in zip(sliding_window(org_img, stepSize=1, windowSize=(8, 8)),

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.1",
8+
version="0.1.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)