RATS: Robust Automatic Threshold SelectionQR for this page
|RATS: Robust Automatic Threshold Selection (ImageJ)|
|Author||Ben Tupper and Mike Sieracki|
|Initial release||17 December 2009|
Robust Automatic Threshold Selection (RATS) computes a threshold map for a 2d image based upon the value of pixels and their gradients. The 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
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.
Pixels with gradients that fall below a user specified threshold, , are rejected. The threshold is defined by an estimate of the noise ( ,the standard deviation of the expected background is a good starting point) and a scaling factor (, 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, , is computed as the gradient weighted sum of the pixels, P.
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.
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.
The plugin is recordable and can be called from a macro ....
run("RATS ", "noise=25 lambda=3 min=81 verbose")