improve condition filters

This commit is contained in:
Ross
2023-10-30 09:54:56 +00:00
parent c8ff740f2e
commit c9023917bd
4 changed files with 23 additions and 23 deletions
+2 -18
View File
@@ -159,6 +159,7 @@ def get_image_dicom_hash(img, dataset=None) -> (str, bool):
if dataset is None:
dataset = pydicom.dcmread(img)
# TODO: improve?
md5 = hashlib.md5()
first = True
for i in dataset.pixel_array.astype(str).flatten():
@@ -177,24 +178,7 @@ def get_image_hash(img) -> (str, bool):
hash = "1234"
try:
# and generate a hash from the pixel data
# TODO: improve?
dataset = pydicom.dcmread(img)
# flatten = dataset.pixel_array.astype(str).flatten()
# print("flatteded")
# pre_join = ",".join(flatten)
# print(pre_join)
# hash = hashlib.md5(pre_join.encode()).hexdigest()
# ----
md5 = hashlib.md5()
first = True
for i in dataset.pixel_array.astype(str).flatten():
if first:
first = False
md5.update(f"{i}".encode())
else:
md5.update(f",{i}".encode())
hash = md5.hexdigest()
hash = get_image_dicom_hash(img)
is_dicom = True
# ----