comparison binary2label.py @ 1:6c92ac9ce868 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/binary2labelimage/ commit b2acc1845a25828181597fe5b6982fe116a7796d
author imgteam
date Mon, 22 Jul 2019 05:01:35 -0400
parents b97a362ff321
children 6e65fd971e13
comparison
equal deleted inserted replaced
0:b97a362ff321 1:6c92ac9ce868
3 import skimage.io 3 import skimage.io
4 from skimage.measure import label 4 from skimage.measure import label
5 import numpy as np 5 import numpy as np
6 import warnings 6 import warnings
7 from PIL import Image 7 from PIL import Image
8 import skimage.util
8 9
9 parser = argparse.ArgumentParser() 10 parser = argparse.ArgumentParser()
10 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') 11 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file')
11 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') 12 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)')
12 args = parser.parse_args() 13 args = parser.parse_args()
13 14
14 img_in = skimage.io.imread(args.input_file.name) > 0 15 img_in = skimage.io.imread(args.input_file.name) > 0
15 res = label(img_in).astype(np.int32) 16 res = label(img_in)
17 res = skimage.util.img_as_uint(res)
16 18
17 res = Image.fromarray(res) 19 res = Image.fromarray(res)
18 res.save(args.out_file.name, "tiff") 20 res.save(args.out_file.name, "tiff")