Background removal and rolling ball algorithm

Hi! I’m having some problems in trying to find the correct procedure for background removal. Mine it’s a general question so I’m not going to upload any pipeline, as this problem could fit to every image in which one have to remove the background. I see that Cellprofiler has powerful modules to correct for uneven background illumination. I also know that ImageJ has a strong tool for this purpose based on the “rolling ball” algorithm. I found this algorithm very powerful and it often makes any other background operation redundant. In CellProfiler 2.1.1 I could use the RunImageJ module to integrate this operation into CellProfiler, even if I had to manually select the command for every single image in my pipeline. With version 2.2., the ImageJ command (which should be under Process>remove Backround) seems to be disappeared…

Can you tell me if there’s a way to somehow find this command or if there’s another module which does the same thing? Or, is not possible to restore the remove background procedure in the RunimageJ module?

Thank you very much

1 Like

Now I’ve seen what is the problem…It’s a shame that the RunImageJ plugin is no longer supported…a freeware battle, isn’t it?

Automated background subtraction algorithms only work for spatially spares samples, where each object is surrounded by a lot of background. In such cases you can for instance use the tophat filter in the morph module for background subtraction; this gives very similar results to the rolling ball algorithm in ImageJ.


Thank you very much Christian, this was very helpful and I confirm that the risult is very similar to the one coming form the rolling ball approach. And…yes this only works for spatially spared samples (which is not the situation for everybody). I hope that this could be also helpful for anybody approaching to background subtraction procedures.

Thank you again for the useful information

Indeed, clever reply, Christian. I would not have known the results are pretty similar to top hat.

Note also the rolling ball algorithm is in EnhanceOrSuppressFeatures, as “Dark holes” (so you could invert your image prior to the module). Top hat is there too, as a matter of fact, but with a biologist-friendly name of “speckles”!

A tip: when you click + to add a module to the pipeline, there is a search bar at the top. If you’re looking for a function you can try putting a keyword there, that’s how I searched “rolling” and came across this.

1 Like

If you want some more information you could look at my Fiji-based teaching material, where I present three ways of [local background subtraction]

  • Subtraction of median filtered image
  • Tophat filter
  • IJ’s rolling ball algorithm (from looking at their source code I frankly could not yet figure out what they exactly do in terms of mathematics; there are links in my presentation to possible explanations)

I also have a little discussion about the pros and cons.

In general, I highly recommend to look at the background image that you are subtracting; this is the best way to check whether you are doing the right thing. In CellProfiler this would mean to first compute the opening, look at it, and then subtract the opening from the original image; tophat = im - open(im)