Binarization<T>
Models & Types · AiDotNet.Preprocessing.Document
Binarization - Document binarization with multiple algorithms.
Implements: IDisposable
For Beginners
Binarization separates text from background by converting each pixel to either black or white:
- Otsu: Global threshold, works well for uniform lighting
- Sauvola: Local adaptive, handles varying illumination
- Niblack: Local adaptive, good for degraded documents
- Fixed: Simple fixed threshold value
Key features:
- Multiple binarization algorithms
- Handles varying lighting conditions
- Works with degraded documents
- Configurable parameters
Example usage:
How It Works
Binarization converts grayscale document images to binary (black and white), which is essential for many OCR and document analysis tasks.
Constructors
| Constructor | Summary |
|---|---|
Binarization() |
Creates a new Binarization instance. |
Methods
| Method | Summary |
|---|---|
Tensor<T> FixedThreshold(Tensor<T> gray, double threshold) |
Applies a fixed threshold. |
Tensor<T> NiblackBinarization(Tensor<T> gray, int windowSize, double k) |
Applies Niblack’s local adaptive thresholding. |
Tensor<T> OtsuBinarization(Tensor<T> gray) |
Applies Otsu’s method for global thresholding. |
Tensor<T> Process(Tensor<T> image, BinarizationMethod method) |
Applies binarization to a document image. |
Tensor<T> SauvolaBinarization(Tensor<T> gray, int windowSize, double k, double r) |
Applies Sauvola’s local adaptive thresholding. |
void Dispose() |