preprocessImage

fun preprocessImage(inputFile: File, enabled: Boolean, useAdaptive: Boolean = false, logSignature: String = DEFAULT_LOG_SIGNATURE): BufferedImage

Preprocesses an image file to improve OCR accuracy. Applies: Grayscale conversion, adaptive binarization, noise reduction. All processing is in-memory; no temp files are written.

Return

The preprocessed image as a BufferedImage, or the original if preprocessing is disabled or fails.

Parameters

inputFile

The original image file.

enabled

Whether preprocessing is enabled.

useAdaptive

Whether to use adaptive thresholding.

logSignature

Signature prefix shown in logs to identify the caller context.


fun preprocessImage(image: BufferedImage, enabled: Boolean, useAdaptive: Boolean = false, logSignature: String = DEFAULT_LOG_SIGNATURE): BufferedImage

Preprocesses an image in-memory to improve OCR accuracy.

Return

The preprocessed image or the original if preprocessing is disabled or fails.

Parameters

image

The original image.

enabled

Whether preprocessing is enabled.

logSignature

Signature prefix shown in logs to identify the caller context.