Mercurial > repos > imgteam > mergeneighboursinlabelimage
changeset 2:9cbddb13fb9e draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/\mergeneighboursinlabelimage commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:11:27 +0000 |
parents | c6a6ab7c9940 |
children | |
files | mergeneighboursinlabelimage.py mergeneighboursinlabelimage.xml |
diffstat | 2 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mergeneighboursinlabelimage.py Mon Jul 22 05:03:33 2019 -0400 +++ b/mergeneighboursinlabelimage.py Mon Nov 13 22:11:27 2023 +0000 @@ -1,11 +1,13 @@ import argparse import sys +import warnings + +import numpy as np +import scipy.spatial.distance import skimage.io import skimage.util from skimage.measure import regionprops -import scipy.spatial.distance -import numpy as np -import warnings + def merge_n(img, dist=50): props = regionprops(img) @@ -13,7 +15,7 @@ for i in range(0, len(props)): i_coords = props[i].coords for q in range(0, len(props)): - if i==q: + if i == q: continue q_coords = props[q].coords iq_dist = np.min(scipy.spatial.distance.cdist(i_coords, q_coords, 'euclidean')) @@ -26,6 +28,7 @@ merge_n(img, dist) return img + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') @@ -43,6 +46,6 @@ label_image = skimage.io.imread(args.input_file.name) label_image = merge_n(label_image, args.cluster_merge) with warnings.catch_warnings(): - warnings.simplefilter("ignore") - res = skimage.util.img_as_uint(label_image) - skimage.io.imsave(args.out_file.name, res, plugin="tifffile") + warnings.simplefilter("ignore") + res = skimage.util.img_as_uint(label_image) + skimage.io.imsave(args.out_file.name, res, plugin="tifffile")
--- a/mergeneighboursinlabelimage.xml Mon Jul 22 05:03:33 2019 -0400 +++ b/mergeneighboursinlabelimage.xml Mon Nov 13 22:11:27 2023 +0000 @@ -1,5 +1,11 @@ -<tool id="ip_merge_neighbours_in_label" name="Merge Neighbours in Label" version="0.3"> - <description>Merge Neighbours in Label Image</description> +<tool id="ip_merge_neighbours_in_label" name="Merge neighbors in label map" version="0.3-2"> + <description></description> + <edam_operations> + <edam_operation>operation_3443</edam_operation> + </edam_operations> + <xrefs> + <xref type="bio.tools">galaxy_image_analysis</xref> + </xrefs> <requirements> <requirement type="package" version="0.14.2">scikit-image</requirement> <requirement type="package" version="1.15.4">numpy</requirement>