PreprocessScannedPage

Rendering and image preprocessing

Description

Rasterizes a single page of the selected document, applies a configurable scan cleanup pipeline (border removal, illumination normalization, median denoising, Sauvola adaptive binarization, 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

Page1-based page number to preprocess
DPITarget rasterization resolution in dots per inch (clamped to 72..600)
OptionsBitmask of preprocessing stages: 1 = remove dark scan borders, 2 = normalize background illumination, 4 = 3x3 median denoise, 8 = Sauvola adaptive binarization, 16 = remove isolated 2x2 speckles, 32 = deskew before cleanup
SauvolaWindowLocal window radius in pixels for Sauvola thresholding (default 15)
SauvolaKSauvola sensitivity factor (default 0.2)

Return values

1The page was preprocessed and replaced with the cleaned image
0The page index was out of range or rendering failed

Remarks

When bit 8 (Sauvola adaptive binarization) is enabled, the cleaned page is stored as a 1-bit monochrome image ready for high-accuracy OCR

See also

PreprocessScannedPageRange, DeskewPage, ApplyOCRTextLayer