Mercurial > repos > thomaswollmann > binary2labelimage
comparison binary2label.py @ 0:4f07ac917459 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/\binary2labelimage commit 77f1ea5beca40d8b5851fe366e84c32d5df5d6f8
| author | thomaswollmann |
|---|---|
| date | Sat, 11 Feb 2017 17:28:38 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4f07ac917459 |
|---|---|
| 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") |
