diff label_to_binary.py @ 0:5da15c3bafed draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/label_to_binary/ commit 0a64a49d4a0ac3438544244a8b871be2fc144766
author imgteam
date Wed, 13 Mar 2024 14:55:31 +0000
parents
children
line wrap: on
line diff
--- /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)