view count_objects.py @ 2:803426d364aa draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/count_objects/ commit 3c2a4fed433e518fcd0bc8d4deffcc5c2346b2b5
author imgteam
date Sat, 08 Jul 2023 01:32:03 +0000
parents faa34f06aa6c
children
line wrap: on
line source

#!/usr/bin/python

import argparse

import skimage.io
from skimage.measure import regionprops

parser = argparse.ArgumentParser(description='Count Objects')
parser.add_argument('input_file', type=argparse.FileType('r'),
                    help='Label input file')
parser.add_argument('output_file', type=argparse.FileType('w'),
                    help='Tabular output file')
args = parser.parse_args()

img_raw = skimage.io.imread(args.input_file.name)
res = len(regionprops(img_raw))

text_file = open(args.output_file.name, "w")
text_file.write("objects\n%s" % res)
text_file.close()