comparison binary2label.py @ 3:9bb446db4a1e draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/binary2labelimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author imgteam
date Mon, 13 Nov 2023 22:10:33 +0000
parents 6e65fd971e13
children
comparison
equal deleted inserted replaced
2:6e65fd971e13 3:9bb446db4a1e
1 import argparse 1 import argparse
2 import sys 2 import sys
3
3 import skimage.io 4 import skimage.io
5 import skimage.util
6 from PIL import Image
4 from skimage.measure import label 7 from skimage.measure import label
5 import numpy as np
6 import warnings
7 from PIL import Image
8 import skimage.util
9 8
10 parser = argparse.ArgumentParser() 9 parser = argparse.ArgumentParser()
11 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') 10 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file')
12 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') 11 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)')
13 args = parser.parse_args() 12 args = parser.parse_args()
14 13
15 img_in = skimage.io.imread(args.input_file.name) > 0 14 img_in = skimage.io.imread(args.input_file.name) > 0
16 res = label(img_in) 15 res = label(img_in)
17 res = skimage.util.img_as_uint(res) 16 res = skimage.util.img_as_uint(res)
18 17
19 res = Image.fromarray(res) 18 res = Image.fromarray(res)