Connecting a cluster of particles in a binary image

Hello everyone,

I have a quick question (hopefully). I am analyzing binary images of blood vessels obtained from CT images of a mouse cochlea. There are times in my images where the canals are disconnected and become a cluster of particles instead of one particle and I was wondering if there was a way to automatically re-connect the cluster? To see an example of what some of the canals that have been affected by the noise or whatnot, please see the attached image. I will also attach an image of what I would like the final image to look like. Any help or suggestions you might be able to give would be greatly appreciated. Thanks!

Uneditted image:

Editted image:

Off the top of my head the simplest solution that comes to mind would be a morphological close operation.

The basic ideas is to link nearby but not touching objects by growing them larger (dilate) and then shrinking them back down (erode) without separating any now touching objects.

I am linking to Matlab’s documentation here because Wikipedia talks about more general morphological operators and Matlab has a very nice explanation of morphological operations as applied to binary images.

The morphological close operation is a morphological dilate followed by a morphological erode. All of these operations require that you define a structure element to control how large of an effect you want. This structure elements defines which pixels are included in the morphological operation and which are not. More detailed structure element explanation: Matlab or Wikipedia.

The Fiji tool to perform this type of image processing is called Gray Morphology and can be found under the menu “Process > Morphology > Gray Morphology”

I would start by using a circle structure element and a radius of 5 pixels (just a guess looking at the image).

For different images you might need different structure elements.



Give this a try:

  1. Edit>Invert
  2. Process>Binary>Fill Holes
  3. Process>Binary>Close-

You will need to play around with Steps 2 and 3 to get best result for your image.

1 Like

You may be able to do this with a few iterations of 3D Erode and 3D Dilate, which may give you more mileage than the 2D versions. By ‘a few iterations’ I mean dilate by a few steps then erode by a few steps.

1 Like

Have a look at the morphological filters available in MorphoLibJ. You can select the operation and the structuring element while previewing the result:


How does the 3D erode and dilate differ from the 2D variant when operating on 2D images? Unless the input is a 3D volumetric image I feel they should produce the same result.


That’s probably true. But, I’m pretty sure that the OP’s images are 3D tomographic datasets, even though he didn’t say so (I helped to collect them at Diamond).