# HG changeset patch # User imgteam # Date 1710341731 0 # Node ID 5da15c3bafedffc78398826ed3ace23447b4dba6 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/label_to_binary/ commit 0a64a49d4a0ac3438544244a8b871be2fc144766 diff -r 000000000000 -r 5da15c3bafed label_to_binary.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/label_to_binary.py Wed Mar 13 14:55:31 2024 +0000 @@ -0,0 +1,18 @@ +import argparse + +import numpy as np +import skimage.io + + +if __name__ == '__main__': + + parser = argparse.ArgumentParser() + parser.add_argument('input', type=str) + parser.add_argument('bg_label', type=int) + parser.add_argument('output', type=str) + args = parser.parse_args() + + im = skimage.io.imread(args.input) + im = (im != args.bg_label) + im = (im * 255).astype(np.uint8) + skimage.io.imsave(args.output, im) diff -r 000000000000 -r 5da15c3bafed label_to_binary.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/label_to_binary.xml Wed Mar 13 14:55:31 2024 +0000 @@ -0,0 +1,54 @@ + + with NumPy + + 1.26.4 + 0 + + + operation_3443 + + + galaxy_image_analysis + + + numpy + scikit-image + + + + + + + + + + + + + + + + + + + This tools converts a label map (objects labeled by different labels/values) to a binary image. + + The input image is converted by assigning white (pixel value 255) to image regions corresponding to labeled objects, + and black (pixel value 0) to image regions corresponding to image background (by default, this is label 0). + + + 10.1038/s41586-020-2649-2 + + diff -r 000000000000 -r 5da15c3bafed test-data/input1.tif Binary file test-data/input1.tif has changed diff -r 000000000000 -r 5da15c3bafed test-data/output1.tif Binary file test-data/output1.tif has changed