Mercurial > repos > thomaswollmann > count_objects
view count_objects.py @ 0:f02a2d0f407c draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/count_objects/ commit d93e1dd276027cfc3fb518236110395a23d96f66
author | thomaswollmann |
---|---|
date | Wed, 16 Jan 2019 15:34:44 -0500 |
parents | |
children |
line wrap: on
line source
#!/usr/bin/python import argparse import numpy as np import os 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()