Closed tischi closed 1 year ago
Hi!
best, David
OK, then I will use this solution: https://forum.image.sc/t/clij-dilate-binary/35231/24 I think it would be nice though to have this functionality also directly within MorpholibJ. Shall I leave the issue thus open?
Hi, well, I do not totally get the difference between the solution you mention and a "simple" dilation, or max-filter... Does it manages the case where two labels overlap after dilation? In that case, it is not planned to implement it within MorphoLibJ. so I think you can close.
Does it manages the case where two labels overlap after dilation?
Yes, because it only dilates into regions where the pixels were zero to start with.
ok, got it! so maybe that is more feasible than what I was thinking to! I'll add on the TODO list, but I won't have time before a while...
Just saw this issue here. Was hoping that expand labels would do exactly what @tischi wanted.
It would be nice to have something like that in Fiji, and I think it would fit into MorpholibJ. See also the related discussion here: https://forum.image.sc/t/equivalent-to-cellprofilers-identifysecondaryobjects-distance-n-in-fiji/39146/4
Pressure is rising ;-)
For me, this is mainly of interest if users want a workflow in Fiji.
Note that the Python implementation from Cellprofiler uses a particular implementation of the distance transform that keeps track of the coordinates for the pixels with the closest distance.
I think the feature would be useful to many, so it is of interest. Thanks for reporting the CellProfiler implementation, I will surely need to have a look. Keeping coordinates of closest pixels looks good also.
Yeah! Thanks for looking into this!!!
Yeah! Thanks for looking into this!!!
+1 some more reading (but this is based on the CellProfiler implementation, with the additional improvement that it works in nD, not just 2D): https://github.com/scikit-image/scikit-image/blob/master/skimage/segmentation/_expand_labels.py
@dlegland Just another poke from my side as we would love to have this feature soon-ish for running a course 😄
Hi @tischi and @VolkerH ! I just made a pre-release that contains a "Dilate Labels" plugins. Tested on 2D and 3D images, hopefully this corresponds to what was discussed!
Still compatible with java 1.6, by the way (I use it for old version of 3D viewer).
Best, David
@dlegland Tested with 2D images and it is beautiful:
Could you please cut a release to and ship it with the update site? I need it for a course soon! Thanks ❤️
ok, try to do it this week...
Missed the Github notification in March but saw this now. Thank you for implementing this missing feature. I had asked about this a whille ago on image.sc
. I just updated the thread there to point to your solution here https://forum.image.sc/t/equivalent-to-cellprofilers-identifysecondaryobjects-distance-n-in-fiji/39146/21?u=volkerh
Released!!!! I updated IJPB site as well. @VolkerH thanks for the link! It's hard to follow all the threads...
@dlegland Thanks again! I was hoping that putting a negative number into the Dilate Labels would shrink (erode) the labels but it does not do that. Could that be implemented? Or is there already some other way of shrinking them?
Hi @tischi ! No, the radius is expected to be positive. I think that the coding of erosion for labels (taking care of neighbors) should not be that complicated. Maybe it is time for some refactoring and cleaning up of the label morphological processing part....
OK! Should we re-open this issue then?
done! I'm on travel this week (in Heidelberg, BTW...), but hope to have a look soon!
Hello, I would also be tempted to have an "Erode Labels" command. A typical use case is to clean up the labels with an opening filter, so this would stop me from needing to go through ROIs.
Looking forward and thanks for MorphoLibJ
@lacan
For me: erode == shrink
For removing small labels based on their volume you can use Label Images > Label Size Filtering
Hi,
I also agree that erode is similar to shrink.
For the opening, the filtering by size is an option, indeed! Otherwise, morphological opening rely on erosion, and for this I was not totally sure which behaviour should be expected for touching labels. I was first thinking on erosion from either the background or another label, but finally it is maybe better to erode ONLY from background pixels. Example:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 1 0 0 0 0
0 1 1 1 1 2 2 2 0 => 0 0 1 1 1 2 2 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 1 2 2 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 1 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
prefered over:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 0 0 0 0 0
0 1 1 1 1 2 2 2 0 => 0 0 1 1 0 0 2 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 0 0 2 0 0
0 1 1 1 1 2 2 2 0 0 0 1 1 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
That way we have a consistent behavior with dilation: pixels/voxels are modified if they are close to background. If they are close to another label, there are not modified. Then, result of opening/closing will change only at boundary with background.
ok for this behaviour?
Hi @tischi and @lacan ; I have juste released the pre-version https://github.com/ijpb/MorphoLibJ/releases/tag/v1.5.1-LabelMorphologicalFilters : it contains a new plugin "Label Morphological Filter" that can apply dilation, erosion, closing and opening! can be 2D or 3D.
Need more refactoring than expected, but seems to work...
best, David
@dlegland @iarganda
I am 100% sure I asked this before but I cannot find it.
Expand Labels
command? I am getting a larger image with the labels more spread out. Looks interesting but what is the use case?