Skip to content

Commit fb240f2

Browse files
committed
Updated
1 parent 7f59d1c commit fb240f2

2 files changed

Lines changed: 35 additions & 33 deletions

File tree

src/IOFunctions.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,43 +156,45 @@ def get_identical_element_indices(arr):
156156
new_image_path = os.path.join(
157157
temp_directory, f"image_{x_cor}_{y_cor}.tiff"
158158
)
159-
img_pil = Image.fromarray(img, mode="RGB")
160-
tags_tosave = copy(self.example_tags)
161-
tags_tosave[296] = 3
162-
tags_tosave[282] = 1e-3 / pixel_size
163-
tags_tosave[283] = 1e-3 / pixel_size
164-
tags_tosave[270] = "Python=3.10.12f\nunit=micron\n"
165-
tags_tosave[256] = img_pil.width
166-
tags_tosave[257] = img_pil.height
167-
tags_tosave[278] = img_pil.height
168-
tags_tosave[279] = img_pil.height * img_pil.width * 3
169-
img_pil.save(
170-
new_image_path, format="TIFF", tiffinfo=tags_tosave
171-
)
159+
if not os.path.isfile(new_image_path):
160+
img_pil = Image.fromarray(img, mode="RGB")
161+
tags_tosave = copy(self.example_tags)
162+
tags_tosave[296] = 3
163+
tags_tosave[282] = 1e-3 / pixel_size
164+
tags_tosave[283] = 1e-3 / pixel_size
165+
tags_tosave[270] = "Python=3.10.12f\nunit=micron\n"
166+
tags_tosave[256] = img_pil.width
167+
tags_tosave[257] = img_pil.height
168+
tags_tosave[278] = img_pil.height
169+
tags_tosave[279] = img_pil.height * img_pil.width * 3
170+
img_pil.save(
171+
new_image_path, format="TIFF", tiffinfo=tags_tosave
172+
)
172173

173174
mask_image_path = os.path.join(
174175
temp_directory, f"image_mask_{x_cor}_{y_cor}.tiff"
175176
)
176-
mask_pil = Image.fromarray(mask_total)
177-
masktags_tosave = copy(self.example_tags)
178-
masktags_tosave[296] = 3
179-
del masktags_tosave[258]
180-
masktags_tosave[259] = 1
181-
masktags_tosave[262] = 1
182-
del masktags_tosave[273]
183-
del masktags_tosave[50838]
184-
del masktags_tosave[50839]
185-
masktags_tosave[282] = 1e-3 / pixel_size
186-
masktags_tosave[283] = 1e-3 / pixel_size
187-
masktags_tosave[270] = "Python=3.10.12f\nunit=micron\n"
188-
masktags_tosave[277] = 1
189-
del masktags_tosave[256]
190-
del masktags_tosave[257]
191-
del masktags_tosave[278]
192-
del masktags_tosave[279]
193-
mask_pil.save(
194-
mask_image_path, format="TIFF", tiffinfo=masktags_tosave
195-
)
177+
if not os.path.isfile(mask_image_path):
178+
mask_pil = Image.fromarray(mask_total)
179+
masktags_tosave = copy(self.example_tags)
180+
masktags_tosave[296] = 3
181+
del masktags_tosave[258]
182+
masktags_tosave[259] = 1
183+
masktags_tosave[262] = 1
184+
del masktags_tosave[273]
185+
del masktags_tosave[50838]
186+
del masktags_tosave[50839]
187+
masktags_tosave[282] = 1e-3 / pixel_size
188+
masktags_tosave[283] = 1e-3 / pixel_size
189+
masktags_tosave[270] = "Python=3.10.12f\nunit=micron\n"
190+
masktags_tosave[277] = 1
191+
del masktags_tosave[256]
192+
del masktags_tosave[257]
193+
del masktags_tosave[278]
194+
del masktags_tosave[279]
195+
mask_pil.save(
196+
mask_image_path, format="TIFF", tiffinfo=masktags_tosave
197+
)
196198
l += 1
197199
print(
198200
"Chopping DAB into tiff sections; subsection {}/{} Time elapsed: {:.2f} seconds".format(
4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)