comparison binary2label.py @ 0:b97a362ff321 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/binary2labelimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
author imgteam
date Sat, 09 Feb 2019 14:30:31 -0500
parents
children 6c92ac9ce868
comparison
equal deleted inserted replaced
-1:000000000000 0:b97a362ff321
1 import argparse
2 import sys
3 import skimage.io
4 from skimage.measure import label
5 import numpy as np
6 import warnings
7 from PIL import Image
8
9 parser = argparse.ArgumentParser()
10 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 args = parser.parse_args()
13
14 img_in = skimage.io.imread(args.input_file.name) > 0
15 res = label(img_in).astype(np.int32)
16
17 res = Image.fromarray(res)
18 res.save(args.out_file.name, "tiff")