This is an archive of the old MediaWiki-based ImageJ wiki. The current website can be found at imagej.net.

RATS: Robust Automatic Threshold Selection

RATS
Project Fiji
URL https://imagej.net/RATS
Source on GitHub
License GPLv3
Release 2.0.1
Date Sat Apr 29 23:00:06 CDT 2017
Development status Stable
Support status None
Team
Founders Ben Tupper
Leads -
Developers -
Debuggers -
Reviewers -
Support -
Maintainers Curtis Rueden
Contributors Ben Tupper, Johannes Schindelin, Mark Hiner

Robust Automatic Threshold Selection (RATS) computes a threshold map for a 2d image based upon the value of pixels and their gradients.

Background

The RATS algorithm is applied across regions of the image making it suitable for thresholding noisy images with variable background. The plugin is based upon the description in

  • Wilkinson MHF (1998) Segmentation techniques in image analysis of microbes. Chapter 6 in: Wilkinson MHF, Schut F (eds.) Digital Image Analysis of Microbes: Imaging, Morphometry, Fluorometry and Motility Techniques and Applications, Vol. John Wiley & Sons, New York.

In this implementation the input gradient of the input image is computed using the Sobel kernels. Traditionally the Sobel gradient is computed using

Error creating thumbnail: Unable to save thumbnail to destination

The kernel operators are detailed in many sources including here. However, Wilkinson shows that eliminating the square root yields suitable results with out the added cost of a final scan across the image to compute the root. In the plugin the gradient is left simply as the sum of the squares of the kernel operations.

Error creating thumbnail: Unable to save thumbnail to destination
Pixels with gradients that fall below a user specified threshold,
Error creating thumbnail: Unable to save thumbnail to destination
, are rejected. The threshold is defined by an estimate of the noise (
Error creating thumbnail: Unable to save thumbnail to destination
,the standard deviation of the expected background is a good starting point) and a scaling factor (
Error creating thumbnail: Unable to save thumbnail to destination
, 3 is a good starting point). Estimate the noise by selecting a "background" portion of the image and using ImageJ to determine the standard deviation of gray values. The input image is then subdivided into a quadtree architecture (for more info see Wikipedia:Quadtree). Within each of the smallest subregions, a regional threshold,
Error creating thumbnail: Unable to save thumbnail to destination
, is computed as the gradient weighted sum of the pixels, P.
Error creating thumbnail: Unable to save thumbnail to destination

Occasionally, the regional threshold fails if the sum of the weights (the denominator) falls to the level of background containing only noise. In such cases, the regional threshold is replaced by the threshold of its parent quadtree (if the parent's threshold doesn't fail). It is possible that thresholds fail all the way up the quadtree heirarchy, in which case a same threshold is applied to all regions which is identical to applying a global threshold. In our experience, regional threshold failures are rare. Once the regional thresholds are computed, they are interpolated (bilinear interpolation) across the entire image yielding a threshold map.

The user also controls the size of the smallest quadtree region (aka leaflet). As with the noise estimate and scaling factor, determining the appropriate minimum quadtree leaflet size is best done with experiment. However, a good guide is to match the size of the smallest leaflet to something just larger than the size of the smallest object expected. There is little performance loss by decreasing the size of the smallest leaflet.


Plugin Usage

Error creating thumbnail: Unable to save thumbnail to destination

Load an single channel image (8-bit, 16-bit or 32-bit). Note that the plugin expects bright objects on dark background, so you might want to call Edit  › Invert if your input image has dark objects. Select the RATS plugin from the Plugins menu. The following dialog will appear:

1. NOISE THRESHOLD: An estimate of the noise. Estimate the noise by selecting a "background" portion of the image and using ImageJ to determine the standard deviation of gray values. Oddly, lower values yield smaller particles in general. (see reference, defaults to 25).

2. LAMBDA FACTOR: A scaling factor. Higher values yield larger particles. (see reference, defaults to 3)

3. MIN LEAF SIZE (pixels): The smallest allowed leaflet (defaults to attempts to create up to 5 levels of quadtrees that fit in the input image dimensions)

4. VERBOSE If set then output informational messages in the log window (default is false).


That's it! A bilevel image is produced with the name "-mask" appended to the original image name.

Error creating thumbnail: Unable to save thumbnail to destination

Macro Usage

The plugin is recordable and can be called from a macro ....

run("RATS ", "noise=25 lambda=3 min=81 verbose")