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.
Discuss automated global background estimation methods, e.g.
mode
mean intensity outside objects
Show activity for:
ImageJ Macro & GUI
/**
* Global background correction
*/run("Close All");open("https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__nuclei_high_dynamic_range_with_offset.tif");// Image › Adjust › Brightness/Contrast...setMinAndMax(100,115);// Use the Rectangle tool from ImageJ's tool barmakeRectangle(4,8,20,42);// Analyze › Set Measurements...run("Set Measurements...","mean redirect=None decimal=3");// Analyze › Measurerun("Measure");// Edit › Selection › Select None (VERY IMPORTANT, otherwise everything you do later will only operate on this region)run("Select None");// Image › Duplicate...run("Duplicate...","title=float");// Image › Type › 32-bitrun("32-bit");// Process › Math › Subtract...run("Subtract...","value=104.399");// Image › Adjust › Brightness/Contrast...setMinAndMax(-5,10);// Use the Line tool from ImageJ's tool barmakeLine(17,7,69,94);// Analyze › Plot Profilerun("Plot Profile");
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.