diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/binary2label.py	Sat Feb 09 14:30:31 2019 -0500
@@ -0,0 +1,18 @@
+import argparse
+import sys
+import skimage.io
+from skimage.measure import label
+import numpy as np
+import warnings
+from PIL import Image
+
+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).astype(np.int32)
+
+res = Image.fromarray(res)
+res.save(args.out_file.name, "tiff")
\ No newline at end of file