Problems with 3D object counter/Connected components labelling

Hello everyone,

I am trying to use connected components labelling for processing 3D images. However the result that I get is wrong, as it attributes the same value to objects that are not connected. In the link I have uploaded an example of a binary 3D image and the corresponding connected component resultant from using the plugin ‘Connected Components Labelling’.

Can someone help me with this?

Thank you

1 Like

Hi Diana @afonso,

I just downloaded your dataset and it looks like it’s connecting objects that aren’t connected, for example the four orange/red objects in the center:

However, when you draw a line through them


and use the tool Image > Stacks > Dynamic Reslice, you’ll see that these object are connected in the third dimension:

When using this tool, you can also move that line and browse through your volume.

As a potential way out, you can temporarily eliminate touching areas by calling a Minimum filter (Menu Process > Filter > Minimum, radius 10) on the binary image (also known as erosion in this context):

… then call Connected Components Labeling:

… followed by a Maximum filter (same radius):

You will also see that it cuts objects in places where it shouldn’t. Thus, it might make sense to play a bit with the radius parameter.

And last but not least: There might be no perfect method :wink:

Let us know if this helps!



Hi Robert,

Thank you very much for the detailed posted. It was highly useful! I played around with the radius and it seems to work for most of the objects :slight_smile:. Just for my understanding can you explain me why there are so many different values on the edge of the objects when doing the dynamic reslice?


1 Like

That’s because the Dynamic Reslice plugin does interpolation of pixel values. That doesn’t make much sense when reslicing label images. One could say that this is a minor bug in that plugin.


1 Like

Thank you for clarifying!


1 Like

I have an additional question that you might be able to help me with :slight_smile: Do you know what would be to best way to visualize a 3D rendering of the obtained segments? Thank you!

Hey Diana @afonso ,

That depends on what you would like to see and what you would like to export/analyse with the 3D projection/surface/… :wink:

I would try

  • ImageJ 3D Viewer
  • 3D Script
  • ClearVolume
  • SciView
  • Imaris

Btw by opening a new thread about 3D visualisation questions, you can attract other experts to take a look at your issue :slight_smile:

1 Like