Which tool should I use to complete lines?

Hi! Although I’m often browsing the forum, it is my first post in here.

I have a problem which might be a simple one, but I’m stuck at it.

I’m trying to segment an image in order to separate the particles and calculate the perimeter of each one of them. I’m using the Trainable Weka Segmentation to segment the image and the results are fine. My problem is after the segmentation. The borders of the particles are sometimes missing a part. There is an example of how it looks like (inside the red circles) [ https://www.dropbox.com/s/gvltfpfroeio9ce/exemplo.jpg?dl=0 ]. It happens because sometimes the border of the particle is almost exactly like it’s interior. Unfortunately I can’t get better images.

I’m trying to find a way to complete the borders automatically (just connect the ends of the lines by a straight line would be good). I tried to solve this problem by changing the segmentation parameters, but the results aren´t good (because of the quality of the image).

What do you all suggest?

Hi @Joao_Chagas,

I don’t have a solution but I tag my colleague @oburri, who was working on a script to cover this task a while ago. If I remember well, we had troubles with very long gaps or multiple branchs but in your case it might work.

Cheers,

Romain

1 Like

I selected the black pixels and performed a morphology closing (10px shrink and 9px grow). This operation fills the smaller gaps but contours are smoothed and small cells are lost. Making this operation in a loop with different closing sizes and tracking the cells centroids could identify all cases. True isolated cells will lose size until disappear and those that are connected by a small gap will eventually divided into two or more parts.

1 Like

I’m working on a similar issue. We have two different tools to try to accomplish this, the first one is purely in fiji where we use a distance transform, find maxim and a watershed. We also have a python script that finds broken ends, it fixes 1px separated ends and connects individual broken ends if they have a single neighbor within a specified radius. I think the fiji/distance transform/watershed is more successful.

What about the original images, it might be possible to improve the first guess?

1 Like

Thanks! Your solution works, but losing small and isolated cells isnt good for me. Im trying to get the most reliable results posible.

Watershed did the trick for me. Thanks!

I had to improve the results from weka, but now I can solve my problem with no issues.