PreprocessScannedPage
Rendering and image preprocessing
Description
Rasterises a single page of the selected document, applies a configurable scan cleanup pipeline (border removal, illumination normalisation, median denoising, Sauvola adaptive binarisation, and despeckling), and replaces the page with the cleaned image
Syntax
Delphi
Function TPDFlib.PreprocessScannedPage(Page: Integer; DPI: Double= 150; Options: Integer= 15; SauvolaWindow: Integer= 15; SauvolaK: Double= 0.2): Integer;
Parameters
| Page | 1-based page number to preprocess |
|---|---|
| DPI | Target rasterisation resolution in dots per inch (clamped to 72..600) |
| Options | Bitmask of preprocessing stages: 1 = remove dark scan borders, 2 = normalise background illumination, 4 = 3x3 median denoise, 8 = Sauvola adaptive binarisation, 16 = remove isolated 2x2 speckles, 32 = deskew before cleanup |
| SauvolaWindow | Local window radius in pixels for Sauvola thresholding (default 15) |
| SauvolaK | Sauvola sensitivity factor (default 0.2) |
Return values
| 1 | The page was preprocessed and replaced with the cleaned image |
|---|---|
| 0 | The page index was out of range or rendering failed |
Remarks
When bit 8 (Sauvola adaptive binarisation) is enabled, the cleaned page is stored as a 1-bit monochrome image ready for high-accuracy OCR