Image Analysis on uneven background and reflections


Hey everyone,

I have ome images, which I would like to analyse. Unfortunately, the images are not evenly illuminated and furthermore some reflections are present. An example image looks like this:

I want to measure at least the area of the objects (in this case bubbles). I started with some image calculcations, which turned out not that bad.
First, I applied a Gaussian filter with 2 px on the original image. Then I divided this new image by a background image I have and created a new 32 bit float image:

This resulted in this image:

But I stillhave problems by detecting the bubbles. Furthermore, the reflections (white spots) at some contours won’t letme detect a closed object, but an object with holes (which can’t be sufficiently filled with the open/close function).

Could anyone give me some advice on how to perform the automated analysis? Furthermore, bubbles touching the borderof the fieldof view should be ignored for analysis and overlaping bubbles should be ignored, too.

I would be very happy if someone could help me :slight_smile:

Kind regards,


Good day Bjoern,

as in many similar cases you are to optimize image acquisition.

  1. Choose a suitable substrate (background)
  2. Use a homogeneous illumination
  3. Use a highly diffuse illumination
  4. Avoid spatial distortions (use a carefully adjusted camera tripod etc.)

#3 is meant to avoid specular reflections.




Hey Herbie,

thanks for the fast reply. Unfortunatly, I have now over 100 images with the descibed problems and I have to analyse them. For future works, I will tak more care on image acqisition as mentioned by you.
However, do you think there is a chance to analyse the images nevertheless?

Kind regards,



one could try to analyze images of this kind but it will be costly.

In any case we’d need the original raw image in TIFF- or PNG-format.

Is there a lower bound for the drop-sizes or do you need the area of all of them.
Furthermore, what do you mean by:

[…] at least the area of the objects (in this case bubbles).

at least?
in this case?

Last and perhaps most important under the present circumstances:
Was the paper substrate parallel to the sensor plane of the camera?

If not, your image will suffer from geometric distortions that will make geometric measurements (area) worthless.



There is a pronounced raster on the sample image which makes analyses much more complicated. Any ideas where it comes from? Maybe a defective de-Bayering? (Is the original raw image a colour image?)


Hello Herbie,

unfortunately, we worked with .jpg images as raw material…
There is no lower bound. But I would bealready happy, if the large objects could be determined automatically, so that we would determine the small bubbles manually.
With my statement I meant that we would also tryto get other geometric features from the images, like roundness, major/minor diameterm etc. to compare them.

The paper substrate was parallel to the sensor plane of the camera, yes.

Weworked with configuration files from our camera supplier. But I see the problem of this raster. for future measurements I will have to take cae of this. The originial image is black&white.



I’m out.

The image material is not suited for reasonable scientific analyses.

I sincerely recommend to take new pictures under much improved conditions and with a suitable camera or preprocessing.




Hi, maybe the Variance filter will help you. Have you tried it?


Hey @VeroMicro,

thanks for the suggestion. I applied the variance filter, but the results are not promising:

From my point of view, the bubbles are clearly visible to the eye in the original images, so I can’t understand, why a detection should not be possible :-/


Hello again. That last image does not look like an output from the variance :thinking:
Saving your illumination corrected image and using a Variance filter with radius 5 I get this… Then you can apply a threshold, work a little bit with some binary operations such as Fill holes, and then use Analyze Particles to detect automatically the bubbles.VarianceR5



here is what I get from using a Variance filter with radius 5

and I can’t find a threshold that gives a reasonable binarization for the area estimation of the droplets.




Funny indeed, It makes no sense. I just downloaded the third of Bjoern’s posted images. Then opened it in Fiji, Process>Filters>Variance, radius 5 and you get a nice edge detection of the bubbles. After that, a default threshold will get the bright areas. Might be a problem when downloading the file?


I think you didn’t download the correct image:

The sample image provided by the original poster has a size of 2048x1088; could you please confirm?




Hi Herbie. You are right, thank you!. I have now the full resolution image. If you apply first a Gaussian Blur of radius 2, and then Variance of around 10 you will have a similar image to mine. Cheers!


Of course but then you don’t measure the correct area…


You can use binary operations to reduce the size of the detected objects. Anyway, that is what I would try to do with the images. Thanks for the feedback!:slightly_smiling_face:


Such an approach appears a bit like what is called “bricolage” in French. I wouldn’t recommend it for scientific puposes.

Good day




Though I may point out that this photo can not be used for scientific analysis purposes due to the technical issues that other people in this thread pointed out, the easiest way you could also try is to:
Threshold the hi and low pixels only (over/under function) and invert before you apply analyze particles.

In that way you will find easily the size and areas of the bubbles (with the help of dilate/erode/fill holes). Then you will have at least a binary mask and the desired ROIs to play with :slight_smile:

Hope that was helpful


Thank you all for your assitstance and advices. I will give it a try! :slight_smile: