Skip to content

Commit

Permalink
updates "Merge neighbors in label map" tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrykin committed Nov 1, 2023
1 parent bb6952a commit 3929102
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 10 additions & 7 deletions tools/mergeneighboursinlabelimage/mergeneighboursinlabelimage.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
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)
found = False
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'))
Expand All @@ -26,6 +28,7 @@ def merge_n(img, dist=50):
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')
Expand All @@ -43,6 +46,6 @@ def merge_n(img, dist=50):
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")
Original file line number Diff line number Diff line change
@@ -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>
Expand Down

0 comments on commit 3929102

Please sign in to comment.