Document layout analysis is the computer vision task of detecting, classifying and ordering the physical regions of a document image, such as paragraphs, headings, tables, figures, captions and footnotes. It turns a flat grid of pixels into a structured map of the page that later stages, including OCR and information extraction, can process region by region.
Within computer vision, layout analysis sits between image preprocessing and text recognition. It answers where content is and what role it plays, while OCR answers what the characters say. A correct layout is the difference between a usable digital document and a jumble of text in the wrong order.
How document layout analysis processes a page
A layout analysis pipeline takes a scanned or rendered page image and produces a list of regions, each with a bounding box or polygon, a class label and a position in the reading order. Most systems work in four stages, though modern end-to-end models merge several of them.
- Preprocessing corrects skew, removes noise and often applies image thresholding to separate ink from background.
- Region detection finds candidate blocks, either with classical segmentation or with an object detection or instance segmentation network.
- Region classification assigns each block a role such as title, body text, list, table, figure or page header.
- Reading order recovery sorts regions into the sequence a human would read, which matters greatly for multi-column pages.
The distinction between physical layout and logical structure is central. Physical layout describes geometric blocks on the page; logical structure describes their meaning, such as which heading owns which paragraph. Many practical systems output both, often as a hierarchical tree or in formats such as PAGE XML or hOCR.
Classical and deep learning approaches
Layout analysis evolved from rule-based geometric methods to learned detectors and multimodal transformers. The table below compares the main families by mechanism, strengths and typical weaknesses.
| Approach | Mechanism | Strength | Weakness |
|---|---|---|---|
| Top-down (XY-cut) | Recursively splits the page along whitespace gaps | Fast and transparent | Fails on irregular or skewed layouts |
| Bottom-up (Docstrum, RLSA) | Groups connected components into lines and blocks | Handles varied fonts and spacing | Sensitive to noise and touching characters |
| Object detection models | Detects regions as bounding boxes with classes | Robust on diverse modern documents | Needs large annotated datasets |
| Multimodal transformers | Combine image patches, text tokens and 2D positions | Best accuracy on complex forms | Higher compute and OCR dependence |
| OCR-free vision-language models | Generate structured output directly from pixels | Single end-to-end model | Can hallucinate text or structure |
Classical methods still appear in lightweight or embedded pipelines, particularly for clean, single-column material. Deep detectors such as Mask R-CNN or YOLO variants dominate production systems, and multimodal models that use both visual and textual features lead public benchmarks for forms, invoices and scientific papers.
Region classes, datasets and evaluation metrics
Layout models are trained on annotated page collections whose class sets differ, so a model trained on one dataset rarely transfers its labels cleanly to another. The table lists widely used public datasets and the kind of documents they cover.
| Dataset | Document type | Typical classes |
|---|---|---|
| PubLayNet | Scientific articles | Text, title, list, table, figure |
| DocLayNet | Reports, manuals, patents, finance | Eleven classes including footnote and formula |
| PRImA layout dataset | Magazines and technical pages | Text regions, images, graphics, separators |
| TableBank | Office and LaTeX documents | Table regions |
Evaluation borrows object detection metrics. Intersection over union decides whether a predicted region matches the ground truth, and mean average precision summarizes performance across classes and IoU thresholds. Strong models reach mAP above 0.9 on PubLayNet, yet scores on the more diverse DocLayNet are noticeably lower, which shows how much domain variety affects difficulty. Reading order is evaluated separately, often with edit-distance or ranking measures.
Document layout analysis compared with related tasks
Layout analysis is often confused with OCR or with generic segmentation, but it has a distinct output and purpose. The comparison clarifies where each neighboring task begins and ends.
| Task | Main output | Relation to layout analysis |
|---|---|---|
| OCR | Recognized characters and words | Consumes layout regions; layout supplies order |
| Instance segmentation | Pixel masks for each object | A common technique used to find layout regions |
| Table structure recognition | Rows, columns and cells inside a table | Runs after layout analysis finds the table |
| Scene text recognition | Text in natural photographs | Targets street scenes, not structured pages |
| Handwriting recognition | Transcribed handwritten text | Benefits from line and block segmentation first |
In practice these tasks form a document understanding pipeline: preprocessing, layout analysis, OCR, table structure recognition and finally key-value or entity extraction. Errors propagate downstream, so a missed table boundary can corrupt every value extracted from it.
Common failure modes and how to address them
Most layout errors come from documents that differ from the training distribution. The table maps typical symptoms to their usual cause and a practical fix.
| Symptom | Likely cause | Practical fix |
|---|---|---|
| Columns read across instead of down | Weak reading order model | Add column-aware ordering or a learned order head |
| Tables split into many text blocks | Borderless tables with wide spacing | Fine-tune on borderless table examples |
| Headers merged with body text | Similar font size and spacing | Use text features alongside image features |
| Regions missed on phone photos | Perspective distortion and shadows | Apply dewarping and illumination correction |
A practical rule is to fine-tune on a few hundred annotated pages from the target domain before trusting accuracy figures from public benchmarks. Teams should also track per-class precision, because a model with high overall mAP can still miss rare but critical classes such as footnotes or signatures.
In simple terms
When a person looks at a newspaper page, they instantly see the headline, the columns, the photo and its caption, and they know which order to read them in. Document layout analysis teaches a computer to do the same thing with a picture of a page.
It does not read the words itself. It draws boxes around each part, names what each box is and puts the boxes in order. Then text recognition software can read every box correctly, so the result keeps the meaning and order of the original page.
A practical example
An insurance company receives about 40,000 scanned claim documents each month, including forms, medical reports and repair invoices in many formats. Its earlier pipeline sent whole pages straight to OCR, and invoices with two-column layouts and embedded tables came out with totals mixed into item descriptions.
The team adds a layout analysis model fine-tuned on 1,500 annotated pages from its own archive. The model labels each page into headers, text blocks, tables, stamps and signatures and sets the reading order before OCR runs. Table regions go to a dedicated table structure recognizer. After the change, manual correction of extracted invoice totals falls by roughly two thirds, and the review team spends its time on genuinely unclear claims instead of fixing scrambled text.