view count_objects.py @ 3:b58447a2eed2 draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/count_objects/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author imgteam
date Mon, 13 Nov 2023 22:10:56 +0000
parents 5bf8eb50b280
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()