Segmenting Overlapping Urine Spots

Hello. This is my first post on the ImageJ forum. I am an undergraduate in a urology laboratory and I am working on software to segment overlapping spots in a binary image. The overlapping spots are a problem because they prevent the accurate analysis of the total area covered by urine and the number of urine spots in an image. The images I am working with look like this:

In these images the urine spots are white and the background is black. I am looking for a way to separate the overlapping spots and find the amount of area that is overlapping for each spot in ImageJ/FIJI. This will allow me to get an accurate estimation of how much area is covered by urine and how many urine spots there are. Ideally, I would get something like this:

Where the spots are outlined in red and the overlapping area is pink.

I have tried using watershed to separate the spots. However, watershed does not tell me how much of the area is overlapping when it makes a split. In addition, there are some problems with over-segmentation in some images, i.e. watershed will make a cut where there is obviously one spot.

Any help is greatly appreciated. I have some experience with programming in Java, but I am a novice when it comes to image analysis/processing. Thus, any literature regarding my problem or image analysis you can point me towards will be helpful.

Thanks for reading.

It looks like a problem you can solve using the Ellipse split plugin.


can I ask you how do you know how to draw the red lines that define the overlapping regions?
Have a nice day,

I gave my plugin a try it works like a charm :slight_smile:



I split the overlapping spots using my own intuition. I just drew the spots in by hand where I saw overlapping spots. I did this to give an example of an output.

@iarganda @twagner

I used the ellipse split plugin. It worked great on the example that @twagner provided. However, on other images it did not work so well:

While some spots are approximated by an ellipse very well, other spots are not. This is because most urine spots are not perfectly elliptical and this plugin tries to fit an ellipse to a urine spot. The shape of the urine spots are important to the analysis that my lab does to the processed images, so I don’t think that the split ellipse plugin will work well for me.

Also, thank you all for responding to my post.

If you can’t assume any shape model (like ellipse) for your urine spots, it is not possible to reconstruct the shape and estimate the overlapping area.


I agree. @myrgth, if you want to do any more accurate analysis, you need to work on the original instead of the binarized images.


@twagner @imagejan
Yes I fully agree with you, and my first question was exactly about that.

Sure. If you look at the more difficult examples that @myrgth posted though, I think you can still assume ellipses for the shape model. The issue is more that ellipses which overlap “too much” are being detected as a single ellipse instead of two. In the above examples, there are obviously (to humans) more ellipses present than are being detected—we can tell because of the concavities in the structure.

@myrgth Does it get any better if you tweak the overlap threshold?

A second problem is partial ellipses which are cut off at the boundaries of the image. Not sure what to do about that…

The ellipse split plugin depends on the splitting capabilities of the watershed. The ellipse split plugin will fail if watershed will not split the spots:

1 Like


There isn’t a significant change if I tweak the overlap threshold.

In other news, I found a paper that looks like it may help my splitting spots problem: Decomposition of a Bunch of Objects in Digital Images.

I am in the process of creating a macro that implements a modified version of method described in the paper. Instead of drawing a line where the spots overlap, the overlapping area will be left alone. I will post the results as soon as I finish.


For me this (nice) method seems to be suited for objects which are only slightly overlapping. I do not believe it will work with highly overlapping objects. I’m very exited about your macro!