Mercurial > repos > imgteam > binary2labelimage
view binary2label.py @ 4:984358e43242 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/binary2labelimage/ commit 00199464fa2aa1928a49e2379edf199c3db91533
author | imgteam |
---|---|
date | Tue, 14 Nov 2023 08:27:27 +0000 |
parents | 9bb446db4a1e |
children |
line wrap: on
line source
import argparse import sys import skimage.io import skimage.util from PIL import Image from skimage.measure import label 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")