Author: Peter Bugaj

Problem

When analyzing images taken under a microscope, it is important to have constant illumination captured throughout. Doing so allows each part of the image to appear the same, excluding the changing details that differ across the object of interest magnified. It also makes it easier for imaging software to detect and understand features. For example, uneven illumination within the image can confuse some software at falsely detecting object boundaries that are not there, due to a sudden and strong change in illumination within the image, making it appear as if there is an actual border between two separate colours.

However, unless one has direct access to an expensive microscope that is specialized at producing constant illumination, producing an image with constant illumination requires a lot of care and focus, and can prove to be challenging in both capture and microscopy itself. An example of a microscopic image with bad illumination is an iron surface shown below:

Correcting illumination in microscopy: bad image example

When attempting to select regions within this image using a brightness threshold, for applications such as phase fractions, only specific parts become highlighted. Due to the natural effect of light, the part of the image most selected is either the centre or near the boundary, with the outline similar to that of a circle or eclipse. The problem is shown below with the image from above used as example. Different brightness thresholds have been applied to show the varying effect:

Correcting illumination in microscopy: phase fraction selection one Correcting illumination in microscopy: phase fraction selection two

Solution

The solution we applied to fix this problem is by treating the the uneven illumination as a function for the Gaussian distribution. We make the assumption that the image with uneven illumination is the output of that Gaussian function, the parameters to the Gaussian function model the said light, and the input for which the function was applied on is the original image we want after applying the fix. For background purposes, we will first describe the Gaussian function below:

Correcting illumination in microscopy: Gaussian Function

For more information about this function, visit this article. For purposes here, we translate this function to get the normal distribution for two dimensions, mainly in the direction of the X and Y axis of the image. The function we get is:

Correcting illumination in microscopy: Normal Distribution 2D

We treat the input variables X and Y as the coordinates within our image. Therefore when applied to the entire image, we get the following equation:

Correcting illumination in microscopy: Gaussian function modelling an illuminated image

In the above, fG is the 2D normal Gaussian function described above, OI is the image we have with uneven illumination, and is II the image we want before the uneven illumination (fG) had been applied. Therefore to fix our microscopic image, we must discover the structure of the function fG, and then apply its inverse to our current image to get our fixed image. In other words, we want to solve the following equation:

Correcting illumination in microscopy: Inverse gaussian function for imaging

Computing the above equation is the easy part. What we do is apply the gaussian inverse fG -1to every pixel in the image OI to get each pixel value in the image II. The hard pard is figuring out what fG is. As seen above, the Gaussian function we want is of the form:

Correcting illumination in microscopy: Normal Distribution 2D

As explained before, the input variables X and Y are the coordinates belonging to the image. The rest of the variables are unknown and represent the parameters modelling the light we need to discover. Variables A and b mark the maximum amplitude of the illumination, and where the illumination is weakest. Variables XO and YO mark where the presumed light to be modelled is centred, and variables OmegaX and OmegaY represent the spread of that light. Solving for these variables can be done through optimized iterative approaches and many algorithms have been implemented to solve this problem. At the basis of this iteration, an equation is being optimized for these unknowns and it is presented below:

Correcting illumination in microscopy: Optimize model estimation by iteration

In brief, the equation above assumes that the image OI is equivalent to the output of fG(C), where C is a constant image with every pixel being identical in RGB value. When solving for the unknowns and applying it to our image, we get the following result:

Correcting illumination in microscopy: fixed image

As can be seen, the illumination is a lot more even. We can then select the regions by brightness as we did in our first examples above:

Correcting illumination in microscopy: fixed image with result