Iterative threshold search and binarization.
Namespace:
AForge.Imaging.FiltersAssembly: AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.4.0 (2.2.4.0)
Syntax
| C# |
|---|
public class IterativeThreshold : Threshold |
Remarks
The algorithm works in the following way:
- select any start threshold;
- compute average value of Background (µB) and Object (µO) values: 1) all pixels with a value that is below threshold, belong to the Background values; 2) all pixels greater or equal threshold, belong to the Object values.
- calculate new thresghold: (µB + µO) / 2;
- if |oldThreshold - newThreshold| is less than a given manimum allowed error, then stop iteration process and create the binary image with the new threshold.
For additional information see Digital Image Processing, Gonzalez/Woods. Ch.10 page:599.
The filter accepts 8 and 16 bpp grayscale images for processing.
Sample usage:
// create filter IterativeThreshold filter = new IterativeThreshold( 2, 128 ); // apply the filter Bitmap newImage = filter.Apply( image );
Initial image:
Result image (calculated threshold is 102):
Inheritance Hierarchy
System..::.Object
AForge.Imaging.Filters..::.BaseInPlacePartialFilter
AForge.Imaging.Filters..::.Threshold
AForge.Imaging.Filters..::.IterativeThreshold
AForge.Imaging.Filters..::.BaseInPlacePartialFilter
AForge.Imaging.Filters..::.Threshold
AForge.Imaging.Filters..::.IterativeThreshold