comparison count_objects.py @ 0:895a29ebd0c7 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/count_objects/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
author imgteam
date Sat, 09 Feb 2019 14:34:18 -0500
parents
children 664232d2a3f7
comparison
equal deleted inserted replaced
-1:000000000000 0:895a29ebd0c7
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()