Pre-processing
Image filters applied to the document before extraction in an IDP template: grayscale, sharpen, brightness/saturation and threshold, with ranges and defaults.
Pre-processing
Pre-processing applies image filters to the document before extraction, to make the text easier for OCR to read. It is a list of filters run top to bottom: each filter receives the image as the previous filter left it.
With no filters, the document goes to extraction as it was sent. Filters are added, reordered, turned off and removed with the layer cards. See Pipeline.
Filters
| Filter | What it does | Setting | Range | Default |
|---|---|---|---|---|
| Grayscale | Converts the image to shades of gray. | — | — | — |
| Sharpen | Brings out edges and text detail. | Sigma | 0.3 to 5 (step 0.1) | 1 |
| M1 — sharpening on flat areas | 0 to 10 (step 0.5) | 1 | ||
| M2 — sharpening on jagged areas | 0 to 10 (step 0.5) | 2 | ||
| Brightness/saturation | Adjusts brightness, saturation and hue. | Brightness — multiplier | 0 to 3 (step 0.05) | 1 |
| Saturation — multiplier | 0 to 3 (step 0.05) | 1 | ||
| Hue — rotation in degrees | 0 to 360 | 0 | ||
| Lightness | −100 to 100 | 0 | ||
| Threshold | Turns the image black and white at a cutoff: anything below it becomes black and anything above it becomes white. | Cutoff | 0 to 255 | 128 |
| Apply on grayscale — converts to grayscale before thresholding | On or off | On |
For the multipliers, 1 leaves the image as it is; lower values reduce and higher values increase.
Order of application
The order of the filters changes the result. For example, with Grayscale → Sharpen → Threshold you remove the color, then bring out the letters and, finally, separate text from background.
Filters only affect the image handed to extraction. Identification compares the incoming document as it arrived, before the filters.
Preview
To see what the filters do, run the draft in the Playground. The result's Pre-processing stage shows the image after each filter and the final image that goes on to extraction; a filter that is off shows as "image unchanged". See Playground and Simulate API.
When to use each filter
| Document condition | Filters to try |
|---|---|
| Color photos and scans where color doesn't matter for reading | Grayscale |
| Blurry text or faint outlines | Sharpen |
| Dark, faded or low-contrast image | Brightness/saturation |
| Stained or shaded background, or marks that get in the way of the text | Threshold, adjusting the Cutoff |
Filters are not required: clean documents, such as system-generated PDFs, may not need any. Compare the extracted text in the Playground with and without each filter before publishing.