Thresholding
Thresholding transforms an image by classifying the pixel values using these methods:
- Automatic thresholding (BW8 and BW16 images only)
- AutoThreshold (BW8 and BW16 images only)
- Manual thresholding using one or two threshold values
- Histogram based (computed before using the thresholding function)
These functions also return the average gray levels of each pixel below and above the threshold.

- Object and background areas should be of uniform color and illumination. Image uniformization may be required prior to thresholding.
- The gray level range of the object and background must be sufficiently different (all background pixels should be darker than the darkest object pixel).
- You must decide if the threshold value should be:
- constant: absolute threshold
- adapted to ambient light intensity: relative or automatic threshold

The threshold is calculated automatically if you use one of these arguments with the EasyImage::.Threshold function.
Min Residue: Minimizes the quadratic difference between the source and the resulting image (default if the Threshold function is invoked without an argument).
Max Entropy: Maximizes the entropy (that is, the amount of information) between object and background of the resulting image.
Isodata: Calculates a threshold value that is an average of the gray levels: halfway between the average gray level of pixels below the threshold, and the average gray level of pixels above the threshold.

Manual thresholds require that the user supplies one or two threshold values:
- one value to the Threshold function to classify source image pixels (BW8/BW16/C24) into two classes and create a bi-level image. This can be:
- relativeThreshold is the percentage of pixels below the threshold. The Threshold function then computes the appropriate threshold value, or
- absoluteThreshold. This value must be within the range of pixel values in the source image.
- two values to the DoubleThreshold function to classify source image pixels (BW8/BW16) into three classes and create a tri-level image.
- LowThreshold is the lower limit of the threshold
- HighThreshold is the upper limit of the threshold

When a histogram of the source image is available, you can speed up the automatic thresholding operation by computing the threshold value from the histogram (using HistogramThreshold or HistogramThresholdBW16) and using that value in a manual thresholding operation.
These functions also return the average gray levels of each pixel below and above the threshold.

When no source image histogram is available, AutoThreshold can still calculate a threshold value using these threshold modes: EThresholdMode_Relative, _MinResidue, _MaxEntropy and _Isodata.
This function supports flexible masks.