Problem with setting Connectivity for Morphological Segmentation in a macro

morpholibj
Tags: #<Tag:0x00007fd542d5b5f0>

#1

Hi,

I’m using MorphoLibJ=>Morphological Segmentation from a macro (IJ1 macro) and encounter unstable behavior:
I try to get dams with 8-connectivity, using the following piece of code:

run("Morphological Segmentation");
wait(1000); 
selectWindow("Morphological Segmentation");
call("inra.ijpb.plugins.MorphologicalSegmentation.segment", "tolerance=50", "calculateDams=true", "connectivity=26");
wait(5000); 
call("inra.ijpb.plugins.MorphologicalSegmentation.setDisplayFormat", "Catchment basins");
call("inra.ijpb.plugins.MorphologicalSegmentation.createResultImage");

but I sometimes 8-connectivity as requested and sometimes I get 4-connectivity dams.
Is there anything else I should set in Fiji to get stable results ?

Thanks
Ofra


#2

That is odd. Usually for 8-connected foreground, you need 4-connected background and I would assume all dams to be 4-connected.
Why do you want 8 connected dams? You won’t be able to get the basins as 8-connected regions.
If you must have 8 connected dams, you could get the 4-connected ones invert the image and then skeletonize them.


#3

I want to add the segmented cells to the RoiManager for further processing.
It seems that Analyze particles uses 8-connectivity, thus if I have 4-connected dams, the segmented objects cannot be separated by Analyze particles.
Is there any other workaround: eg. a way to add objects directed from MorphoLibJ to RoiManager ? a way to control the connectivity used by Analyze particles ?


#4

I am still intrigued by the claim that it sometimes returns one or another type of connectivity.
Please post an image where this happens and one where it works as expected.


#5

Hello @Ofra_Golani,

Can you please change the “segment” call to

call("inra.ijpb.plugins.MorphologicalSegmentation.segment", "tolerance=50", "calculateDams=true", "connectivity=8");

to make sure you use 8-connectivity? This works for me.


#6

Thanks Ignacio

I used the recorded command. Applying the change helped. It works now !
and thanks for the great MorphoLibJ plugin !

Ofra