-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomparison.py
More file actions
42 lines (32 loc) · 1.08 KB
/
comparison.py
File metadata and controls
42 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import tifffile as tif
import numpy as np
import json
def isIdentical(image_path1, image_path2):
"""
Compare two TIFF images to check if they are equal in every value.
Args:
image_path1 (str): Path to the first TIFF image
image_path2 (str): Path to the second TIFF image
Returns:
bool: True if images are identical, False otherwise
"""
with tif.TiffFile(image_path1) as tif1, tif.TiffFile(image_path2) as tif2:
# Read the image data
data1 = tif1.asarray()
data2 = tif2.asarray()
# Compare the arrays
return np.array_equal(data1, data2)
def sort_json(data):
if isinstance(data, dict):
return {k: sort_json(v) for k, v in sorted(data.items())}
elif isinstance(data, list):
return sorted(sort_json(x) for x in data)
else:
return data
def isJsonIdentical(json_path1, json_path2):
with open(json_path1) as f1, open(json_path2) as f2:
json_data1 = json.load(f1)
json_data2 = json.load(f2)
if json_data1 == json_data2:
return True
return False