improve condition filters
This commit is contained in:
+2
-18
@@ -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
|
||||
# ----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user