By G. Landini
This section explains methods to do background illumination correction in brightfield microscopy.
Background correction can be applied while acquiring images (a priori) or after acquisition (a posteriori). The difference between these is that a priori correction uses additional images obtained at the time of image capture while in a posteriori correction, the additional images are not available and therefore an ideal illumination model has to assumed. The a priori methods are therefore the preferred option.
When digitising images there are several sources of image degradation to consider:
Block the light path (do not switch the microscope light off!, most microscopes have a lever that lets the user block the light path to the extension tube, where the camera is) and capture a shot. This image will be nearly black everywhere, except for the “hot pixels” if any (sometimes hot pixels are not very noticeable but they can be checked in the histogram of the image). Save the image as “Darkfield” which will be used to compensate for hot pixels.
Now open the light path, remove the specimen (the image is all background) and capture a shot. Save it as “Brightfield”; it will be used to compensate the background illumination.
Put the specimen on the stage and capture one shot. Save it as “Specimen”.
The operation (in a 8 bit channel) consists of calculating the transmittance through the specimen:
Corrected_Image = (Specimen - Darkfield) / (Brightfield - Darkfield) * 255
First we will compensate the electronic bias (hot pixels) in the Brightfield and Specimen images.
Using the command Process>ImageCalculator, calculate (Brightfield - Darkfield), and call the result “Divisor”:
imageCalculator("Subtract create", "Brightfield","Darkfield"); selectWindow("Result of Brightfield"); rename("Divisor");
Do the same with the Specimen image: (Specimen - Darkfield) and call the result “Numerator”.
imageCalculator("Subtract create", "Specimen","Darkfield"); selectWindow("Result of Specimen"); rename("Numerator");
Next, we calculate the transmittance as the ratio of transmitted light through the specimen and the incident light to produce the corrected image. That is, the division of images: Numerator / Divisor.
The result of this division is a real number between 0 and 1 (0 if there is no light at all passing through the specimen, 1 if all the incident light passes through the specimen). This number cannot be stored in an 8 bit per channel image; instead the value is re-scaled to the range of 0-255 per channel by multiplying the division result by 255. This is achieved in a single step with the Calculator_Plus plugin which performs the division, followed by a multiplication (and a sum if needed) all in double precision before pasting the clipped result back into an image:
run("Calculator Plus", "i1=Numerator i2=Divisor operation=[Divide: i2 = (i1/i2) x k1 + k2] k1=255 k2=0 create"); selectWindow("Result"); rename("Corrected");
The result of this should have a flat (even) background that should appear white or neutral (unless the glass slide has a noticeable tint) as long as you did not change any of the settings of the camera between shots (time, exposure, white balance etc) or the microscope settings (light, condenser, magnification).
One can improve the signal/noise ratio by taking average shots instead of single ones. In this case the Darkfield, Brightfield and Specimen images can be created as the average of several shots. If the camera or the acquiring software do not allow for average capture, one can sequentially capture the images (the IJ_Robot plugin can be useful to automate this), then convert them to a stack and finally Z-project the stack using the Average Intensity option. For instance to average 16 shots, grab 16 images and then run:
run("Convert Images to Stack"); run("Z Project...", "start=1 stop=16 projection=[Average Intensity]");
The result “ZProjection of Stack” is the averaged image.
The Divisor image can be used for subsequent shots if the light source is very stable and no changes are made to the microscope or camera settings. The Darkfield image can also be re-used if no changes are made to any camera settings. If you change magnification or lighting settings you can still use the same Darkfield to correct the new Brightfield and Specimen images. To summarize:
Various methods have been suggested to extract from a single image the characteristics of the background. For example:
However one should be aware that all retrospective methods make assumptions about the image characteristics that are unlikely to be strictly satisfied in any arbitrary image. For example, it is not possible to differentiate consistently a diffuse dark patch due to the presence of stain from one due to uneven background illumination. It is always better to correct the images with an a priori method.
With only 1 image, it is difficult to know what is noise and what is image texture. One can try image smoothing (for instance Gaussian convolution) but this also affects edge sharpness. Median filtering is better at preserving edges, but still affects the image with some loss of detail.
With only 1 image available, a possible solution is to replace only the hot pixels with the average of its neighbours without averaging the rest of the pixels.
Below is a macro that implements this idea. Note that the pixels should not be clustered and they should be saturated [value=255 in 8-bit greyscale images or in all 8 bit channels of RGB images]. If the hot pixels are not saturated you can threshold them (making the hot pixels =255 and the remaining pixels=0 and adding this thresholded image to the original (this will saturate the hot pixels).If there are white areas that do not need denoising, one can first subtract 1 to the whole image and then saturate the pixels (so the hot pixels have a value of 255 and the white areas 254).
// SaturatedSinglePixelDenoising.txt // G. Landini 16/July/2005 // This macro detects saturated *single* pixels (8 connected) in the // image (grey=255) and replaces them with the pixel value of // either the mean or the median of the neighbours (choose which // method one by un-commenting the lines indicated below. // Works with 8bit and 24 bit images only. // Needs the Particles8 plugin available at: // http://www.mecourse.com/landinig/software/software.html run("Colors...", "foreground=white background=black selection=yellow"); run("Options...", "iterations=1 black count=1"); run("Duplicate...", "title=Denoised"); setBatchMode(true); run("Duplicate...", "title=pixels"); if (bitDepth==24) run("8-bit"); setThreshold(255, 255); run("Threshold", "thresholded remaining"); //--- // if you want to denoise small clusters of pixels, rather than single pixels, // then comment the following 5 lines, but be aware that the average // or median will not be correct as other pixels in the cluster may // contribute to the corrected value: run("Duplicate...", "title=non-single"); run("Particles8 ", "white show=Particles filter minimum=2 maximum=999999 overwrite"); imageCalculator("Subtract", "pixels","non-single"); selectWindow("non-single"); close(); //--- selectWindow("Denoised"); run("Duplicate...", "title=median"); // use average of the 8 neighbours run("Convolve...", "text1=[1 1 1 1 0 1 1 1 1] normalize"); // use median of the 3x3 neighbourhood instead of the average (the line above). // run("Median...", "radius=1"); if (bitDepth==24) { selectWindow("pixels"); run("RGB Color"); } imageCalculator("AND create", "pixels","median"); imageCalculator("Subtract", "Denoised","pixels"); imageCalculator("Add", "Denoised","Result of pixels"); //selectWindow("median"); close(); selectWindow("Result of pixels"); close(); selectWindow("pixels"); close(); setBatchMode(false);
If you have any comments or queries about this document, please email me at G. Landini at bham. ac. uk
To reference this document:
Landini G. (2006-2014) How to correct background illumination in brightfield microscopy. Available at:
http://imagejdocu.tudor.lu/doku.php?id=howto:working:how_to_correct_background_illumination_in_brightfield_microscopy