Global background correction
Prerequisites
Before starting this lesson, you should be familiar with:
Learning Objectives
After completing this lesson, learners should be able to:
Measure the background in an image
Apply image math to subtract a background intensity value from all pixels and understand that the output image should have a floating point data type
Motivation
Most biological images have non-zero intensity values in regions outside of the objects of interest. In order to properly quantify the intensities of objects such background must be taken into account. For example, most cameras on microscopes have a read noise with can be many hundred gray values (for 12-bit or 16-bit detection). As such read noise is typically constant across the whole image, subtracting a constant background value for each pixel is possible.
Concept map
Figure
Activities
- Open image xy_16bit__nuclei_high_dynamic_range_with_offset
- Measure the background using a manually defined region
- Measure the mean intensities inside of two nuclei using manually defined regions
- Choose rather dim nuclei of different intensities
- Measure the intensity ratio with and without background correction
- Subtract the background value from the image
- Appreciate that this yields a non-zero background for unsigned integer data types and that a floating point data type is thus necessary
- Open image xy_16bit__scanR_datatype_issue
- Discuss automated global background estimation methods, e.g.
- mode
- mean intensity outside objects
- Discuss automated global background estimation methods, e.g.
Show activity for:
ImageJ Macro & GUI
Exercises
Show exercise/solution for:ImageJ Macro & GUI
Open image xy_16bit__nuclei_with_background.tif
- Measure the background
- Subtract the background from the image
- Is the mean intensity in the background region close to 0 («1)? If not, which image data type conversion have you forgotten?
- Verify that the histogram has not been clipped by the background subtraction operation.
Solution
In order to obtain a correct result, the background subtraction should be performed with an image that has been converted to a float (in ImageJ 32-bit). This avoid clipping of the data for the low values.
run("Close All"); roiManager("reset"); run("Clear Results"); open("https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__nuclei_with_background.tif"); rename("intenisty") // 1. Measure the background // Draw a rectangle makeRectangle(19, 16, 70, 52); //Add to RoiManager using key t roiManager("Add"); // Measure intensity run("Measure"); // Disable current ROI (select the whole image or click on it) run("Select All"); // 2. Subtract the background without conversion and check mean in background region // Process › Math › Subtract... run("Subtract...", "value=104.182"); rename("bg subtracted 16bit") setMinAndMax("0.00", "100"); run("Enhance Contrast", "saturated=0.35"); // Measure the intensity in background region roiManager("Select", 0); run("Measure"); run("Histogram"); // 3. Subtract the background with prior conversion // Open the image again open("https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__nuclei_with_background.tif"); // Subtract the background with prior conversion to float (32-bit) // Image > Type > 32-bit run("32-bit"); // Process › Math › Subtract... run("Subtract...", "value=104.182"); run("Enhance Contrast", "saturated=0.35"); rename("bg subtracted 32bit") // Measure the intensity in background region roiManager("Select", 0); run("Measure"); setMinAndMax("0.00", "100"); run("Histogram", "bins=256 use x_min=-10 x_max=100.0 y_max=Auto");
Can you think of a way of automatically computing a global background?
Solution
For this exercise we just compute the mean intensity in the space that is not the nuclei. We can use thresholding but with different low and upper values.
/** * Required update sites: * - IJPB-Plugins (MorpholibJ) **/ //File> Open... open("https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__nuclei_with_background.tif") // Image > Duplicate... run("Duplicate...", "binary"); // Image > Adjust > Threshold ... setThreshold(0, 117); setOption("BlackBackground", true); run("Convert to Mask"); // Plugins › MorphoLibJ › Binary Images › Connected Components Labeling run("Connected Components Labeling", "connectivity=4 type=[16 bits]"); rename("labels"); // Plugins › MorphoLibJ › Analyze › Intensity Measurements 2D/3D run("Intensity Measurements 2D/3D", "input=intensity labels=labels mean max numberofvoxels");
Assessment
True or false?
- The datatype is irrelevant for background subtraction.
- Background subtraction using a unsigned integer image will always lead to a positive valued background.
- Global background subtraction is important for ratiometric computations.
- Global background subtraction affects differences in intensities.
Solution
- The datatype is irrelevant for background subtraction. FALSE
- Background subtraction using a unsigned integer image will always lead to a positive valued background. TRUE
- Global background subtraction is important for ratiometric computations. TRUE
- Global background subtraction affects differences in intensities. FALSE
Follow-up material
Recommended follow-up modules:
Learn more: