Tesseract page segmentation modes tell the engine what shape of text to expect: fully automatic segmentation is the default, but a single uniform block of text or a single column needs a different mode. The wrong mode scrambles the reading order, so match the mode to the layout and check the output order.
What you need
- Tesseract installed
- A scanned page image with a known layout
- The list of page segmentation modes from the Tesseract manual
Step 1: Identify the page layout
Look at the page and decide whether it is a single column of variable-size text, a single uniform block, or a multi-column layout.
Step 2: Run OCR with the matching mode
Run Tesseract with –psm and the mode number for that layout, for example mode 4 for a single column of text of variable sizes or mode 6 for a single uniform block of text.
Step 3: Check the reading order
Read the output text from top to bottom and confirm the paragraphs follow the page order. If lines are interleaved, try the next closest mode and compare.
Worked example: synthetic PSM check on a single-column letter
The table below is a synthetic example. It shows the expected result of comparing PSM modes; no OCR was run.
| Mode | Paragraphs in order | Lines interleaved |
|---|---|---|
| PSM 3, automatic | 2 of 5 | 3 paragraphs |
| PSM 4, single column | 5 of 5 | 0 paragraphs |
| PSM 6, uniform block | 4 of 5 | 1 paragraph |
Expected result (UNTESTED). automatic mode puts only 2 of 5 paragraphs in order, while mode 4 for a single column puts all 5 in order. Use mode 4 for this layout. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Mode 3, fully automatic page segmentation, is the default and suits mixed layouts.
- Mode 7 treats the image as a single text line and mode 8 as a single word; use them only for that shape of input.
- The mode must be set before any config file on the command line.
