BMCV / galaxy-image-analysis

Galaxy tools for image analysis
MIT License
14 stars 17 forks source link

Add `voronoi_tessellation` tool #108

Closed kostrykin closed 8 months ago

kostrykin commented 8 months ago

For the contributor:


The added tool takes an image with labels as input and yields an image with the corresponding Voronoi tessellation (aka Voronoi diagram, Dirichlet tessellation). This mimics the behavior of the ImageJ function Process ‣ Binary ‣ Voronoi: https://bioimagebook.github.io/chapters/2-processing/6-transforms/imagej.html#voronoi

xref #105

kostrykin commented 8 months ago

I don't understand much about images, but are both images included here supposed to be black and the same size?

Short answer: The images are fine, I just double-checked them.

Long answer: They are not really black :)

In [1]: import skimage.io

In [2]: skimage.io.imread('input1.tiff')
Out[2]: 
array([[0, 0, 0, 0, 0, 0, 3, 3, 3, 3],
       [0, 1, 1, 0, 0, 0, 3, 3, 3, 3],
       [0, 1, 1, 0, 0, 0, 3, 3, 3, 3],
       [0, 0, 0, 0, 0, 0, 3, 3, 3, 3],
       [0, 0, 0, 0, 0, 0, 3, 3, 3, 3],
       [0, 0, 0, 0, 0, 0, 3, 3, 3, 3],
       [0, 0, 0, 0, 0, 0, 0, 4, 4, 4],
       [0, 2, 2, 0, 0, 0, 0, 4, 4, 4],
       [0, 2, 2, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

In [3]: skimage.io.imread('input1_result.tiff')
Out[3]: 
array([[1, 1, 1, 1, 3, 3, 3, 3, 3, 3],
       [1, 1, 1, 1, 1, 3, 3, 3, 3, 3],
       [1, 1, 1, 1, 1, 3, 3, 3, 3, 3],
       [1, 1, 1, 1, 3, 3, 3, 3, 3, 3],
       [1, 1, 1, 1, 3, 3, 3, 3, 3, 3],
       [2, 2, 2, 2, 3, 3, 3, 3, 3, 3],
       [2, 2, 2, 2, 2, 3, 3, 4, 4, 4],
       [2, 2, 2, 2, 2, 4, 4, 4, 4, 4],
       [2, 2, 2, 2, 2, 4, 4, 4, 4, 4],
       [2, 2, 2, 2, 2, 2, 4, 4, 4, 4]], dtype=uint8)

The pixel values just all are very close to 0, which makes it look black, but in fact it's very dark gray. The exact values do not really matter, they are just arbitrary labels for distinct image regions.

bgruening commented 8 months ago

Ok, as I said, I have no clue about images ;)