Mercurial > repos > imgteam > binary2labelimage
view 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 |
line wrap: on
line source
import argparse import sys import skimage.io from skimage.measure import label import numpy as np import warnings from PIL import Image import skimage.util parser = argparse.ArgumentParser() parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') args = parser.parse_args() img_in = skimage.io.imread(args.input_file.name) > 0 res = label(img_in) res = skimage.util.img_as_uint(res) res = Image.fromarray(res) res.save(args.out_file.name, "tiff")