Select the input image
Choose the image to be thresholded.
Name the output image
Enter a name for the thresholded image.
Select the output image type
Two types of output images can be produced:
- Grayscale: The pixels that are retained after some pixels
are set to zero or shifted (based on your selections for thresholding
options) will have their original
- Binary (black and white): The pixels that are retained after some pixels are
set to zero (based on your selections for thresholding options) will be
white and all other pixels will be black (zeroes).
Set pixels below or above the threshold to zero?
(Used only when "Grayscale" thresholding is selected)
For grayscale output, the dim pixels below
the threshold can be set to zero or the bright pixels above
the threshold can be set to zero.
Choose Below threshold to threshold dim pixels and
Above threshold to threshold bright pixels.
Subtract the threshold value from the remaining pixel intensities?
(Used only if the output image is Grayscale and pixels below a given intensity are to be set to zero)
Select Yes to shift the value of the dim pixels by the threshold value.
Number of pixels by which to expand the thresholding around those excluded bright pixels
(Used only if the output image is grayscale and pixels above a given intensity are to be set to zero)
This setting is useful when attempting to exclude bright artifactual objects:
first, set the threshold to exclude these bright objects; it may also be desirable to expand the
thresholded region around those bright objects by a certain distance so as to avoid a "halo" effect.
The thresholding strategy determines the type of input that is used
to calculate the threshold. The image thresholds can be based on:
- The pixel intensities of the input image (this is the most common).
- A single value manually provided by the user.
- A single value produced by a prior module measurement.
- A binary image (called a mask) where some of the pixel intensity
values are set to 0, and others are set to 1.
These options allow you to calculate a threshold based on the whole
image or based on image sub-regions such as user-defined masks or
objects supplied by a prior module.
The choices for the threshold strategy are:
- Automatic: Use the default settings for
thresholding. This strategy calculates the threshold using the MCT method
on the whole image (see below for details on this method) and applies the
threshold to the image, smoothed with a Gaussian with sigma of 1.
This approach is fairly robust, but does not allow you to select the threshold
algorithm and does not allow you to apply additional corrections to the
- Global: Calculate a single threshold value based on
the unmasked pixels of the input image and use that value
to classify pixels above the threshold as foreground and below
This strategy is fast and robust, especially if
the background is uniformly illuminated.
- Adaptive: Partition the input image into tiles
and calculate thresholds for each tile. For each tile, the calculated
threshold is applied only to the pixels within that tile.
This method is slower but can produce better results for non-uniform backgrounds.
However, for signifcant illumination variation, using the CorrectIllumination
modules is preferable.
- Per object: Use objects from a prior module
such as IdentifyPrimaryObjects to define the region of interest
to be thresholded. Calculate a separate threshold for each object and
then apply that threshold to pixels within the object. The pixels outside
the objects are classified as background.
This method can be useful for identifying sub-cellular particles or
single-molecule probes if the background intensity varies from cell to cell
(e.g., autofluorescence or other mechanisms).
- Manual: Enter a single value between zero and
one that applies to all cycles and is independent of the input
This approach is useful if the input image has a stable or
negligible background, or if the input image is the probability
map output of the ClassifyPixels module (in which case, a value
of 0.5 should be chosen). If the input image is already binary (i.e.,
where the foreground is 1 and the background is 0), a manual value
of 0.5 will identify the objects.
- Binary image: Use a binary image to classify
pixels as foreground or background. Pixel values other than zero
will be foreground and pixel values that are zero will be
background. This method can be used to import a ground-truth segmentation created
by CellProfiler or another program.
The most typical approach to produce a
binary image is to use the ApplyThreshold module (image as input,
image as output) or the ConvertObjectsToImage module (objects as input,
image as output); both have options to produce a binary image. It can also be
used to create objects from an image mask produced by other CellProfiler
modules, such as Morph. Note that even though no algorithm is actually
used to find the threshold in this case, the final threshold value is reported
as the Otsu threshold calculated for the foreground region.
- Measurement: Use a prior image measurement as the
threshold. The measurement should have values between zero and one.
This strategy can be used to apply a pre-calculated threshold imported
as per-image metadata via the Metadata module.
Like manual thresholding, this approach can be useful when you are certain what
the cutoff should be. The difference in this case is that the desired threshold does
vary from image to image in the experiment but can be measured using another module,
such as one of the Measure modules, ApplyThreshold or
an Identify module.
The intensity threshold affects the decision of whether each pixel
will be considered foreground (region(s) of interest) or background.
A higher threshold value will result in only the brightest regions being identified,
whereas a lower threshold value will include dim regions. You can have the threshold
automatically calculated from a choice of several methods,
or you can enter a number manually between 0 and 1 for the threshold.
Both the automatic and manual options have advantages and disadvantages.
An automatically-calculated threshold adapts to changes in
lighting/staining conditions between images and is usually more
robust/accurate. In the vast majority of cases, an automatic method
is sufficient to achieve the desired thresholding, once the proper
method is selected.
- In contrast, an advantage of a manually-entered number is that it treats every image identically,
so use this option when you have a good sense for what the threshold should be
across all images. To help determine the choice of threshold manually, you
can inspect the pixel intensities in an image of your choice.
To view pixel intensities in an open image, use the
pixel intensity tool which is available in any open display window. When you move
your mouse over the image, the pixel intensities will appear in the bottom bar of the display window..
The manual method is not robust with regard to slight changes in lighting/staining
conditions between images.
- The automatic methods may ocasionally produce a poor
threshold for unusual or artifactual images. It also takes a small amount of time to
calculate, which can add to processing time for analysis runs on a large
number of images.
The threshold that is used for each image is recorded as a per-image
measurement, so if you are surprised by unusual measurements from
one of your images, you might check whether the automatically calculated
threshold was unusually high or low compared to the other images. See the
FlagImage module if you would like to flag an image based on the threshold
There are a number of methods for finding thresholds automatically:
- Otsu: This approach calculates the threshold separating the
two classes of pixels (foreground and background) by minimizing the variance within the
This method is a good initial approach if you do not know much about
the image characteristics of all the images in your experiment,
especially if the percentage of the image covered by foreground varies
substantially from image to image.
Our implementation of Otsu's method allows for assigning the threhsold value based on
splitting the image into either two classes (foreground and background) or three classes
(foreground, mid-level, and background). See the help below for more details.
- Mixture of Gaussian (MoG):This function assumes that the
pixels in the image belong to either a background class or a foreground
class, using an initial guess of the fraction of the image that is
covered by foreground.
If you know that the percentage of each image that is foreground does not
vary much from image to image, the MoG method can be better, especially if the
foreground percentage is not near 50%.
This method is our own version of a Mixture of Gaussians
algorithm (O. Friman, unpublished). Essentially, there are two steps:
- First, a number of Gaussian distributions are estimated to
match the distribution of pixel intensities in the image. Currently
three Gaussian distributions are fitted, one corresponding to a
background class, one corresponding to a foreground class, and one
distribution for an intermediate class. The distributions are fitted
using the Expectation-Maximization algorithm, a procedure referred
to as Mixture of Gaussians modeling.
- When the three Gaussian distributions have been fitted, a decision
is made whether the intermediate class more closely models the background pixels
or foreground pixels, based on the estimated fraction provided by the user.
- Background: This method simply finds the mode of the
histogram of the image, which is assumed to be the background of the
image, and chooses a threshold at twice that value (which you can
adjust with a Threshold Correction Factor; see below). The calculation
includes those pixels between 2% and 98% of the intensity range.
This thresholding method is appropriate for images in which most of the image is background.
It can also be helpful if your images vary in overall brightness, but the objects of
interest are consistently N times brighter than the background level of the image.
- RobustBackground: Much like the Background: method, this method is
also simple and assumes that the background distribution
approximates a Gaussian by trimming the brightest and dimmest 5% of pixel
intensities. It then calculates the mean and standard deviation of the
remaining pixels and calculates the threshold as the mean + 2 times
the standard deviation.
This thresholding method can be helpful if the majority
of the image is background, and the results are often comparable or better than the
- RidlerCalvard: This method is simple and its results are
often very similar to Otsu.
RidlerCalvard chooses an initial threshold and then iteratively
calculates the next one by taking the mean of the average intensities of
the background and foreground pixels determined by the first threshold.
The algorithm then repeats this process until the threshold converges to a single value.
This is an implementation of the method described in Ridler and Calvard, 1978.
According to Sezgin and Sankur 2004, Otsu's
overall quality on testing 40 nondestructive testing images is slightly
better than Ridler's (average error: Otsu, 0.318; Ridler, 0.401).
- Kapur: This method computes the threshold of an image by
searching for the threshold that maximizes the sum of entropies of the foreground
and background pixel values, when treated as separate distributions.
This is an implementation of the method described in Kapur et al, 1985.
- Maximum correlation thresholding (MCT): This method computes
the maximum correlation between the binary mask created by thresholding and
the thresholded image and is somewhat similar mathematically to Otsu.
The authors of this method claim superior results when thresholding images
of neurites and other images that have sparse foreground densities.
This is an implementation of the method described in Padmanabhan et al, 2010.
- Sezgin M, Sankur B (2004) "Survey over image thresholding techniques and quantitative
performance evaluation." Journal of Electronic Imaging, 13(1), 146-165.
- Padmanabhan K, Eddy WF, Crowley JC (2010) "A novel algorithm for
optimal image thresholding of biological data" Journal of
Neuroscience Methods 193, 380-384.
- Ridler T, Calvard S (1978) "Picture thresholding using an iterative selection method",
IEEE Transactions on Systems, Man and Cybernetics, 8(8), 630-632.
- Kapur JN, Sahoo PK, Wong AKC (1985) "A new method of gray level picture thresholding
using the entropy of the histogram." Computer Vision, Graphics and Image Processing,
Select binary image
(Used only if Binary image selected for thresholding method)
Select the binary image to be used for thresholding.
(Used only if Manual selected for thresholding method)
Enter the value that will act as an absolute threshold for the images, a value from 0 to 1.
Select the measurement to threshold with
(Used only if Measurement is selected for thresholding method)
Choose the image measurement that will act as an absolute threshold for the images.
Two-class or three-class thresholding?
(Used only for the Otsu thresholding method)
- Two classes: Select this option if the grayscale levels are readily
distinguishable into only two classes: foreground (i.e., regions of interest)
- Three classes: Choose this option if the grayscale
levels fall instead into three classes: foreground, background and a middle intensity
between the two. You will then be asked whether
the middle intensity class should be added to the foreground or background
class in order to generate the final two-class output.
Note that whether
two- or three-class thresholding is chosen, the image pixels are always
finally assigned two classes: foreground and background.
Three-class thresholding may be useful for images in which you have nuclear staining along with
low-intensity non-specific cell staining. Where two-class thresholding
might incorrectly assign this intermediate staining to the nuclei
objects for some cells, three-class thresholding allows you to assign it to the
foreground or background as desired.
However, in extreme cases where either
there are almost no objects or the entire field of view is covered with
objects, three-class thresholding may perform worse than two-class.
Assign pixels in the middle intensity class to the foreground or the background?
(Used only for three-class thresholding)
Choose whether you want the pixels with middle grayscale intensities to be assigned
to the foreground class or the background class.
Approximate fraction of image covered by objects?
(Used only when applying the MoG thresholding method)
Enter an estimate of how much of the image is covered with objects, which
is used to estimate the distribution of pixel intensities.
Method to calculate adaptive window size
(Used only if an adaptive thresholding method is used)
The adaptive method breaks the image into blocks, computing the threshold
for each block. There are two ways to compute the block size:
- Image size: The block size is one-tenth of the image dimensions,
or 50 × 50 pixels, whichever is bigger.
- Custom: The block size is specified by the user.
Size of adaptive window
(Used only if an adaptive thresholding method with a Custom window size
Enter the window for the adaptive method. For example,
you may want to use a multiple of the largest expected object size.
Threshold correction factor
This setting allows you to adjust the threshold as calculated by the
above method. The value entered here adjusts the threshold either
upwards or downwards, by multiplying it by this value.
A value of 1 means no adjustment, 0 to 1 makes the threshold more
lenient and > 1 makes the threshold more stringent.
When the threshold is calculated automatically, you may find that
the value is consistently too stringent or too lenient across all
images. This setting
is helpful for adjusting the threshold to a value that you empirically
determine is more suitable. For example, the
Otsu automatic thresholding inherently assumes that 50% of the image is
covered by objects. If a larger percentage of the image is covered, the
Otsu method will give a slightly biased threshold that may have to be
corrected using this setting.
Lower and upper bounds on threshold
Enter the minimum and maximum allowable threshold, a value from 0 to 1.
This is helpful as a safety precaution when the threshold is calculated
automatically, by overriding the automatic threshold.
For example, if there are no objects in the field of view,
the automatic threshold might be calculated as unreasonably low; the algorithm will
still attempt to divide the foreground from background (even though there is no
foreground), and you may end up with spurious false positive foreground regions.
In such cases, you can estimate the background pixel intensity and set the lower
bound according to this empirically-determined value.
- To view pixel intensities in an open image, use the
pixel intensity tool which is available in any open display window. When you move
your mouse over the image, the pixel intensities will appear in the bottom bar of the display window.
Select the smoothing method for thresholding
(Only used for strategies other than Automatic and
The input image can be optionally smoothed before being thresholded.
Smoothing can improve the uniformity of the resulting objects, by
removing holes and jagged edges caused by noise in the acquired image.
Smoothing is most likely not
appropriate if the input image is
binary, if it has already been smoothed or if it is an output of the
The choices are:
- Automatic: Smooth the image with a Gaussian
with a sigma of one pixel before thresholding. This is suitable
for most analysis applications.
- Manual: Smooth the image with a Gaussian with
- No smoothing: Do not apply any smoothing prior to
Threshold smoothing scale
(Only used if smoothing for threshold is Manual)
This setting controls the scale used to smooth the input image
before the threshold is applied. The scale should be approximately
the size of the artifacts to be eliminated by smoothing. A Gaussian
is used with a sigma adjusted so that 1/2 of the Gaussian's
distribution falls within the diameter given by the scale
(sigma = scale / 0.674)