ijpb / MorphoLibJ

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

DilateLabels on 32-bit label images doesn't work #54

Closed haesleinhuepf closed 3 years ago

haesleinhuepf commented 3 years ago

Hey @dlegland ,

I just saw the announcement / related issue #41 about the new dilateLabels function and gave it a try. While testing, I discovered that it doesn't do anything when retrieving a 32-bit float image. Is this intentional? If so, could the user be warned that this image type is not supported?

You can use this macro to reproduce the issue:

run("Blobs (25K)");
setAutoThreshold("Default");
setOption("BlackBackground", true);
run("Convert to Mask");

// CCA
run("Analyze Particles...", "  show=[Count Masks]");
run("glasbey on dark");

// dilate labels in 16-bit image
run("Dilate Labels", "radius=5");

// apply to 8-bit image
selectWindow("Count Masks of blobs.gif");
setOption("ScaleConversions", true);
run("8-bit");
run("Dilate Labels", "radius=5");

// apply to 32-bit image
selectWindow("Count Masks of blobs.gif");
run("32-bit");
run("Dilate Labels", "radius=5");

Best, Robert

haesleinhuepf commented 3 years ago

Oh and one more thing. When comparing dilateLabels to its clij counterpart, I noticed that dilateLabels with distance=1 doesn't do anything. I guess internally the distance map should be increased by 1?

You can use this macro to reproduce the issue:

run("Blobs (25K)");
setAutoThreshold("Default");
setOption("BlackBackground", true);
run("Convert to Mask");

// CCA
run("Analyze Particles...", "  show=[Count Masks]");
run("glasbey on dark");

// dilate labels in 16-bit image
run("Dilate Labels", "radius=1");

// determine difference
imageCalculator("Difference create 32-bit", "Count Masks of blobs.gif","CountMasksofblobsdilated");
dlegland commented 3 years ago

hmm... no, this was not intentional. Should be fixed easily. For distance equal ot 1, I have to check. not very free this month, but stay tuned...

dlegland commented 3 years ago

Hi, I found the bug (was using the method "get" instead of "getf", which is more versatile). Commited in cb82217129d6877b4292ab2e33ba1b0310a55eb9!

David

dlegland commented 3 years ago

oh, and I updated management of distances to have a dilation also for radisu = 1. committed in 40b71aa808b05d71b59ae7f3b04204217eded219.