-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconvert.py
More file actions
28 lines (22 loc) · 1005 Bytes
/
convert.py
File metadata and controls
28 lines (22 loc) · 1005 Bytes
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
import glob
import os
import numpy as np
from tifffile import imread
from tifffile import imwrite
# input_seg_path = "C:/Users/Cyril/Desktop/Proj_bachelor/code/pytorch-test3dunet/cropped_visual/train/lab"
# output_seg_path = "C:/Users/Cyril/Desktop/Proj_bachelor/code/pytorch-test3dunet/cropped_visual/train/lab_sem"
input_seg_path = "C:/Users/Cyril/Desktop/Proj_bachelor/code/cellseg-annotator-test/napari_cellseg3d/models/dataset/labels"
output_seg_path = "C:/Users/Cyril/Desktop/Proj_bachelor/code/cellseg-annotator-test/napari_cellseg3d/models/dataset/lab_sem"
filenames = []
paths = []
filetype = ".tif"
for filename in glob.glob(os.path.join(input_seg_path, "*" + filetype)):
paths.append(filename)
filenames.append(os.path.basename(filename))
# print(os.path.basename(filename))
for file in paths:
image = imread(file)
# image = img.compute()
image[image >= 1] = 1
image = image.astype(np.uint16)
imwrite(output_seg_path + "/" + os.path.basename(file), image)