Uneven Lighting in Intensity Measurements


I am trying to measure the integrated densities of these large dark objects, but I have very uneven lighting. I am wondering if a bandpass filter would help to make the image more evenly-lit so that my intensities would not be impacted non-uniformly.

Part of the issue is also that the lines created by the light cast are not totally horizontal or vertical, but are instead more of a curve.

Would a bandpass filter work here or is there another option I should look at?

Just out of curiosity, have you played around with the built in background subtraction - Process->Subtract background…

Hi there, thanks for the response!

I have tried subtracting the background, but I think that the problem is that I need for it to be subtracted in a way that matches the uneven light.

For example, the left-most spot is coming out darker than it should due to the light cast not being as bright in that area. If I do background subtraction, it subtracts evenly across all of the spots.

Maybe if there was a way to subtract the background only in a small section around each spot individually?

Not that I know of. Lighting like that is usually dealt with by taking a blank image to subtract from each data image.

You can use Gaussian blur for illumination correction.

  1. Blur image with very big Gaussian kernel ~400.
  2. Divide image on the blurred image.

This works best if your images are normalized from 0 to 1 in float32.

If you want this black spots to have unaltered intensities, you will have to segment them out, or at least do thresholding and create a mask, which is easier to do on the corrected image.

1 Like

Hi Vasyl,

Thanks for the response!

Yes, I would want to have unaltered intensities on the black spots. I have been able to threshold these before and make a mask without any issues.

So, before I do the thresholding, I would use a big gaussian blur filter of sigma 400? Then I would divide the original image by the blurred image, correct?

I’m not sure how to normalize the images though. Could you list the menu process to make these adjustments?

Thank you!

You need to crop out dark borders because they influence estimated illumination too much, or use smaller Gaussian kernel.
So to correct illumination you need to:

Read image 
Image-> Type -> 32bit
You can go even without normalization. 
Image -> Duplicate -> name 'illumination'

To get blurred image

Process -> Filters -> Gaussian Blur
(optional) Image -> Rename -> 'illumination'

To divide images

Process -> Image Calculator -> 

    Image 1 - input image
    Image 2 - illumination image
    Operation Divide
    check (optional) Create new Window
    check 32 bit result

I haven’t found how to normalize properly in the imagej.
The tedious way would go like this:

First we need to create completely white image of the same datatype

File -> New -> Image
    name 'white'
    fill Black
    Datatype of your input image
    Size of your input image

Then convert it to float32

Edit -> Invert -> Image -> Type 32 bit

Then divide input image on white image

Process -> Image Calculator -> 

    Image 1 - input image
    Image 2 - white image
    Operation Divide
    check Create new Window
    check 32 bit result

If you have lots of such images it is better to make a script in python.

As an alternative you can quickly train ilastik on several different images (5-10) and it will segment out those spots even with uneven illumination