# HG changeset patch # User thomaswollmann # Date 1486852137 18000 # Node ID 668f8dabb3462152e1c0479eed25cc3c36e83216 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/\binary2labelimage commit 77f1ea5beca40d8b5851fe366e84c32d5df5d6f8 diff -r 000000000000 -r 668f8dabb346 binary2label.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/binary2label.py Sat Feb 11 17:28:57 2017 -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 diff -r 000000000000 -r 668f8dabb346 binary2label.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/binary2label.xml Sat Feb 11 17:28:57 2017 -0500 @@ -0,0 +1,29 @@ + + Converts Binary to Label Image + + scikit-image + pillow + numpy + + + + + + + + + + + + + + + + + This tool assigns every object an own grey value. + + 10.7717/peerj.453 + + diff -r 000000000000 -r 668f8dabb346 test-data/galaxyIcon_noText.tif Binary file test-data/galaxyIcon_noText.tif has changed diff -r 000000000000 -r 668f8dabb346 test-data/label.tif Binary file test-data/label.tif has changed