Mercurial > repos > thomaswollmann > count_objects
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f02a2d0f407c |
|---|---|
| 1 #!/usr/bin/python | |
| 2 | |
| 3 import argparse | |
| 4 import numpy as np | |
| 5 import os | |
| 6 import skimage.io | |
| 7 from skimage.measure import regionprops | |
| 8 | |
| 9 parser = argparse.ArgumentParser(description='Count Objects') | |
| 10 parser.add_argument('input_file', type=argparse.FileType('r'), | |
| 11 help='Label input file') | |
| 12 parser.add_argument('output_file', type=argparse.FileType('w'), | |
| 13 help='Tabular output file') | |
| 14 args = parser.parse_args() | |
| 15 | |
| 16 img_raw = skimage.io.imread(args.input_file.name) | |
| 17 res = len(regionprops(img_raw)) | |
| 18 | |
| 19 text_file = open(args.output_file.name, "w") | |
| 20 text_file.write("objects\n%s" % res) | |
| 21 text_file.close() |
