MorphoLibJ: keep largest region with 8 connectivity

morphology
morpholibj

#1

Hi all,

I am having troubles with MorphoLibJ library, in order to keep the largest connected component. It should be straightforward, and indeed it is… if I want 4 connectivity in 2D.

Algorithms work for both 2D or 3D images. Default connectivity 4 (resp. 6) is used for 2D (resp. 3D) images.
https://imagej.net/MorphoLibJ#Connected_components_operators

However, I cannot find a way to do it with 8-conn. The documentation does not seem to reflect if other values aside from the default can be used:
https://javadoc.scijava.org/MorphoLibJ/inra/ijpb/binary/BinaryImages.html

I need 8-conn because I’m handling skeletons.
Ideas? Thank you very much in advance, hints are greatly appreciated.


#2

OK. Got it myself!

It’s a two-step solution:
a) Create a labels image, setting 8-conn
b) Keep largest label