view 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 source

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)