-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
voronoi_tessellation
tool (#108)
Squashed commit of the following: commit 3cf5e31 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 19:04:19 2024 +0100 Fix test results commit c7c193a Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 18:29:04 2024 +0100 Fix bugs commit e67e183 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 17:19:02 2024 +0000 Fix bug commit 91c0f8b Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 17:15:47 2024 +0000 Fix citation commit 6d96123 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 17:05:34 2024 +0000 Add tests commit c2531b3 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 17:54:11 2024 +0100 Fix XML commit a0a9b16 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 16:20:50 2024 +0000 Implement `voronoi_tessellation` tool commit 05b5849 Author: Leonid Kostrykin <[email protected]> Date: Sat Mar 9 16:02:43 2024 +0000 Add `voronoi_tesselation` tool
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
categories: | ||
- Imaging | ||
description: Compute Voronoi tesselation | ||
long_description: Compute Voronoi tesselation for labeled images. | ||
name: voronoi_tesselation | ||
owner: imgteam | ||
homepage_url: https://github.com/bmcv | ||
remote_repository_url: https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/voronoi_tesselation |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import argparse | ||
|
||
import numpy as np | ||
import scipy.ndimage as ndi | ||
import skimage.io | ||
from skimage.segmentation import watershed | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('input') | ||
parser.add_argument('output') | ||
args = parser.parse_args() | ||
|
||
im = skimage.io.imread(args.input) | ||
im = im.squeeze() | ||
assert im.ndim == 2 | ||
|
||
distances = np.full(im.shape, np.inf) | ||
for label in np.unique(im): | ||
if label == 0: | ||
continue | ||
|
||
label_distances = ndi.distance_transform_edt(im != label) | ||
distances = np.min((distances, label_distances), axis=0) | ||
|
||
result = watershed( | ||
image=distances, | ||
markers=im, | ||
) | ||
|
||
skimage.io.imsave(args.output, result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<tool id="voronoi_tessellation" name="Compute Voronoi tessellation" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0"> | ||
<description>with scikit-image</description> | ||
<macros> | ||
<token name="@TOOL_VERSION@">0.22.0</token> | ||
<token name="@VERSION_SUFFIX@">0</token> | ||
</macros> | ||
<edam_operations> | ||
<edam_operation>operation_3443</edam_operation> | ||
</edam_operations> | ||
<xrefs> | ||
<xref type="bio.tools">scikit-image</xref> | ||
<xref type="biii">scikit-image</xref> | ||
</xrefs> | ||
<requirements> | ||
<requirement type="package" version="1.26.4">numpy</requirement> | ||
<requirement type="package" version="1.12.0">scipy</requirement> | ||
<requirement type="package" version="0.22.0">scikit-image</requirement> | ||
</requirements> | ||
<command><![CDATA[ | ||
## Inputs | ||
python '$__tool_directory__/voronoi_tessellation.py' '$input' | ||
## Outputs | ||
./result.tiff | ||
]]> | ||
</command> | ||
<inputs> | ||
<param name="input" type="data" format="png,tiff" label="Labeled image" /> | ||
</inputs> | ||
<outputs> | ||
<data format="tiff" name="result" from_work_dir="result.tiff" /> | ||
</outputs> | ||
<tests> | ||
<test> | ||
<param name="input" value="input1.tiff" /> | ||
<output name="result" value="input1_result.tiff" ftype="tiff" compare="sim_size" delta="0" /> | ||
</test> | ||
</tests> | ||
<help> | ||
|
||
This tool computes Voronoi tessellations for labeled images. | ||
Voronoi tessellations are also known as Vornoi diagrams, or Dirichlet tessellations. | ||
Zero labels are treated as image background. | ||
|
||
</help> | ||
<citations> | ||
<citation type="doi">10.7717/peerj.453</citation> | ||
</citations> | ||
</tool> |