Module: ApplyThreshold

Apply Threshold sets pixel intensities below or above a certain threshold to zero
ApplyThreshold produces either a grayscale or binary image based on a threshold which can be pre-selected or calculated automatically using one of many methods.


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:

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.

Threshold strategy

The thresholding strategy determines the type of input that is used to calculate the threshold. The image thresholds can be based on: 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:

Thresholding method

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 value.

There are a number of methods for finding thresholds automatically:


Select binary image

(Used only if Binary image selected for thresholding method)
Select the binary image to be used for thresholding.

Manual threshold

(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)
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:

Size of adaptive window

(Used only if an adaptive thresholding method with a Custom window size are selected)
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 Binary image)
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 ClassifyPixels module.
The choices are:

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)