ijpb / MorphoLibJ

Collection of mathematical morphology methods and plugins for ImageJ
http://imagej.net/MorphoLibJ
GNU Lesser General Public License v3.0
101 stars 48 forks source link

Label Morphological Filter: Erosion Operation for touching labels #76

Closed maulakhan closed 11 months ago

maulakhan commented 1 year ago

Dear all,

I am trying to erode a label mask in such a way that I have non-touching labels using MorpholibJ Label Morphological Filter options. I get the following result:

image

Left: original label mask, Right: label mask after erosion with radius = 9

I used radius = 9 but was not able to separate them. Can you please help to get the non-touching labels, maybe I am doing something wrong or is it supposed to work that way?

Attaching one example C2-Composite

Thanks a lot!

tischi commented 1 year ago

ping @dlegland @iarganda

dlegland commented 1 year ago

Hi,

Well, for the moment this is the expected kind of result, so nothing wrong a priori.

The aim to this plugin was to generalize erosion and dilation to label maps. Of course, one has to decide what to do when several labels are found in the neighborhood of current pixel! For erosion, I have made the decision to apply erosion only if a background pixel or voxel (label 0) is found in the neighborhood. Therefore, a the boundary of two regions, no erosion occur as there is no background.

I was thinking about this, and it could be possible to add an additionnal option, to erode if a different label (either 0 or another one) is present in the neighborhood. This would have some side effects on other kind of images, but if the option can be chosen by the user, this should be fine. I will try to add it in a future release. Stay tuned...

tischi commented 1 year ago

I was thinking about this, and it could be possible to add an additionnal option, to erode if a different label (either 0 or another one) is present in the neighborhood.

this is what I would have expected it to do....essentially erode each label as if it was a lonely binary mask.

it would be great if that could be added.

I would make it the default behaviour, as I don't know a use-case right now for the current implementation, do you have a use-case?

iarganda commented 1 year ago

Hey guys! What about imposing label (zero) boundaries and then eroding?

dlegland commented 1 year ago

I would make it the default behaviour, as I don't know a use-case right now for the current implementation, do you have a use-case?

Actually, in case of "dense" label maps (like a watershed result without dams), applying erosion would create new background pixels within groups of regions. The apparition of background may be questionable... But If the option to use background instead of other label is more natural, maybe I can change default option.

Hey guys! What about imposing label (zero) boundaries and then eroding?

This is a solution as well! But then it is necessary to iterate over labels, create new image for each label, and then concatenating the results.

dlegland commented 1 year ago

Hi,

I have updated the plugin, and drafted a new release (https://github.com/ijpb/MorphoLibJ/releases/tag/v1.6.0-LabelMapFiltering)

You can play with the new jar, and tell me if this is better now!

dlegland commented 11 months ago

fixed in release 1.6.2