We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac5e315 commit fc79770Copy full SHA for fc79770
create_train_val_label.py
@@ -1,7 +1,7 @@
1
import json,os
2
import numpy as np
3
import tifffile as tiff
4
-
+from PIL import Image
5
6
7
def get_label_from_palette(label_img, palette_file='Palette.json'):
@@ -22,7 +22,13 @@ def main(path):
22
for pic in os.listdir(path):
23
if 'label' in pic:
24
print(pic)
25
- label = tiff.imread(path + '/' +pic)
+
26
+ # ---- read RGB label
27
+ label = Image.open(path + '/' +pic)
28
+ label = np.asarray(label)
29
+ # ----- another way
30
+ # label = tiff.imread(path + '/' +pic) # the code of this line can be run in windows system, which in ubuntu will get a error !!
31
32
label = get_label_from_palette(label)
33
tiff.imsave(path + '/' +pic[:-9] + 'new-L.tif',label)
34
0 commit comments