ImageEn, unit IEVision

TIEVisionImage.normalizeBackground

TIEVisionImage.normalizeBackground

Declaration

function normalizeBackground(tileSize: int32_t = 16; backgroundValue: int32_t = 200): TIEVisionImage; safecall;

Description

Flattens uneven lighting (via Leptonica). The background brightness is estimated across the image (using a grayscale closing, which removes the text) and every pixel is rescaled so the background becomes a uniform value, while text keeps its contrast. This also works where the background itself is dark, such as the unlit side of a photographed page.
Useful for photos of documents, vignetting, yellowed paper and shadows. After normalization even a simple global threshold often works well.
Returns a new image: 8-bit gray for gray or 1-bit images, otherwise 24-bit color (any alpha channel is discarded). The current image is not changed. Images smaller than 8 x 8 pixels are returned unchanged.
Parameter Description
tileSize Size of the area used to estimate the background, in pixels (at least 4). It must be larger than the characters, about 2x the text height, otherwise text is treated as background
backgroundValue Value the background is mapped to (128 to 255)

Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Example

img := ImageEnView1.IEBitmap.GetIEVisionImage().normalizeBackground();
ImageEnView1.IEBitmap.AssignIEVisionImage( img );
ImageEnView1.Update();

See Also

◼prepareForOCR
◼clahe