LayoutNormalization<T>
Models & Types · AiDotNet.Preprocessing.Document
LayoutNormalization - Document layout normalization utilities.
Implements: IDisposable
For Beginners
Different documents have different sizes and proportions. This tool standardizes them for AI models:
- Resize to target dimensions
- Preserve aspect ratio options
- Handle padding and cropping
- Normalize orientation
Key features:
- Multiple normalization strategies
- Aspect ratio preservation
- Smart padding and cropping
- Batch processing support
Example usage:
How It Works
LayoutNormalization provides utilities for normalizing document layouts to standard sizes and aspect ratios for consistent model input.
Constructors
| Constructor | Summary |
|---|---|
LayoutNormalization() |
Creates a new LayoutNormalization instance. |
Methods
| Method | Summary |
|---|---|
Tensor<T> CenterCrop(Tensor<T> image, int targetWidth, int targetHeight) |
Crops the center of the image to target dimensions. |
Tensor<T> Flip(Tensor<T> image, bool horizontal) |
Flips the image horizontally or vertically. |
Tensor<T> NormalizeOrientation(Tensor<T> image, bool preferPortrait) |
Detects and corrects document orientation (portrait vs landscape). |
Tensor<T> Process(Tensor<T> image, int targetWidth, int targetHeight, NormalizationStrategy strategy) |
Normalizes a document image to the specified dimensions. |
Tensor<T> ResizeAndCrop(Tensor<T> image, int targetWidth, int targetHeight) |
Resizes to cover target dimensions then crops to exact size. |
Tensor<T> ResizeWithPadding(Tensor<T> image, int targetWidth, int targetHeight, T paddingValue) |
Resizes the image preserving aspect ratio and adds padding. |
Tensor<T> Rotate90(Tensor<T> image, bool clockwise) |
Rotates the image 90 degrees. |
Tensor<T> Stretch(Tensor<T> image, int targetWidth, int targetHeight) |
Stretches the image to target dimensions (may distort aspect ratio). |
double GetAspectRatio(Tensor<T> image) |
Computes aspect ratio of the image. |
void Dispose() |