Pure Classic CV for PDF Table Recognition: An Analysis of the Open-Source Project Spartan

Spartan uses classic CV for interpretable PDF table extraction, but lacks benchmark evaluation.
Spartan is an open-source PDF table extraction project using only classic computer vision techniques such as morphology and LSD, with no deep learning. It separates table lines via morphological opening for bordered tables and generates pseudo-borders via text alignment for borderless ones. Digital PDFs are read directly from the text layer to avoid OCR errors, with OCR as fallback for scans. It runs on CPU at about 0.3-1.5s/page and is fully inspectable, but skew handling is weak and formal benchmarks are missing.
Introduction
PDF table extraction has long been a challenge in the field of document intelligence, and most existing solutions rely on deep learning models. But recently, an open-source project called Spartan has taken a different approach, achieving table detection and structure recognition using only classic computer vision techniques (morphological operations and LSD line segment detection), sparking discussion on Reddit. This article provides an in-depth analysis of the project's technical approach, strengths, and limitations.

Technical Approach: From Morphology to Pseudo-Borders
Spartan's pipeline adopts different strategies for bordered and borderless tables. For bordered tables, morphological opening with long horizontal/vertical kernels is used to separate the table lines, and then contour analysis is performed on the line mask to locate the table region. For borderless tables, it starts from text alignment: grouping words into phrases, checking left, center, and right alignment between consecutive rows, and when enough rows and columns are aligned, drawing "pseudo-borders" on the image so that the subsequent pipeline treats it as a bordered table.
Structure Recognition: LSD and Union-Find
In the structure recognition stage, the text is first masked out, then line segments are detected using LSD (Line Segment Detector) and clustered and merged into a grid. Cells spanning rows/columns are recovered through missing line segments: if a separator line is missing in some part of the grid, those cells are merged (using the union-find algorithm). This approach cleverly transforms structure recognition into a problem of missing line segments.
Morphological opening is a basic operation in mathematical morphology, referring to first eroding an image and then dilating it, commonly used to remove small noise, separate objects, or extract lines in a specific direction. In table detection, opening with a long horizontal kernel preserves horizontal lines while filtering out text and vertical lines, and vice versa, thereby effectively separating the table framework. LSD (Line Segment Detector) is a line segment detection algorithm based on gradient information that can quickly detect straight line segments in an image and provide endpoints, length, and width without parameter tuning, and is robust to local contrast changes. In table structure recognition, LSD is used to detect separator lines between cells, merging short line segments through clustering to form a grid, and missing line segments indicate cells spanning rows or columns.
Text Extraction: Digital PDFs First, OCR as Fallback
For digital PDFs, characters are obtained directly from the PDF text layer and mapped to the cell grid, avoiding OCR errors—which is especially important for critical information such as part numbers. OCR (Tesseract or a plugin engine) is used only for scanned pages. Post-processing includes nested header detection, classification of key-value tables versus regular tables, and merging of tables across pages (by matching column widths and headers). The entire pipeline runs on the CPU, at about 0.3–1.5 seconds per page on a laptop, and all decisions can be traced back to inspectable thresholds.
Strengths: Interpretable, Lightweight, MIT Licensed
Spartan's biggest advantage is interpretability: every pixel threshold is defined at 300 DPI and scales with resolution, so developers can inspect every decision. No GPU is required, it runs fast, and it is MIT licensed, keeping the barrier to contribution low. The project author explicitly welcomes contributions and lists several directions: skew correction (Hough/projection methods), evaluation on ICDAR 2013/PubTables-1M/FinTabNet using GriTS or TEDS (the current lack of formal benchmarks is the biggest weakness), improving reconstruction of wrapped text lines in borderless tables, and integrating other OCR engines (a plugin interface and an EasyOCR example already exist).
Limitations and Areas for Improvement
The project author candidly acknowledges current shortcomings: skewed scans are handled poorly (line segment detection tolerates only about 2 pixels of drift, and there is no deskewing yet); small borderless blocks may misclassify headers as key-value pairs; and wrapped text in borderless cells is sometimes split into extra rows. These are edge cases to watch for in real deployments.
Commentary and Outlook
In an era when deep learning prevails, Spartan proves that classic CV remains competitive in specific scenarios, especially those sensitive to interpretability and deployment cost. However, the lack of standard benchmark evaluation is its biggest weakness—without quantitative metrics, it is difficult to compare fairly with existing solutions. If the community can fill in evaluation and deskewing, the project has the potential to become a practical choice for lightweight PDF table extraction.
Repository address: https://github.com/shlok-n/spartan · Installation: pip install spartan-tables
One-line Summary
Spartan uses classic CV techniques to achieve interpretable PDF table extraction, but lacks benchmark evaluation.
Paragraph Summary
Spartan is an open-source PDF table extraction project that uses only classic computer vision techniques such as morphological operations and LSD line segment detection, without deep learning models. For bordered tables, it uses morphological opening to separate table lines; for borderless tables, it generates pseudo-borders through text alignment, and then performs unified structure recognition. For digital PDFs, characters are extracted directly from the text layer to avoid OCR errors; scanned pages fall back to OCR. The project runs on the CPU at about 0.3-1.5 seconds per page, and all thresholds are inspectable; its greatest strengths are interpretability and lightness. However, the author candidly admits that skewed scans are handled poorly and borderless tables suffer from misclassification, and the lack of standard benchmark evaluation is the biggest weakness.
Related articles

Amphibious Transforming Drone: Beyond 100x Power Savings, What Are the Real Needs?
Is the amphibious transforming drone just a gimmick? Starting from the 100x power difference of the M4 Morphobot, explore real application scenarios and thesis topic ideas, analyzing boundary conditions where pure drones and pure ground robots both fail.

Warhound Raises $200 Million: Genetically Engineered "War Dogs" Paired with Anduril Gear
Warhound raises $200M, backed by Ben Lamm and Palmer Luckey, to genetically engineer dogs for military and law enforcement use and equip them with Anduril gear. This article analyzes its technology direction, funding logic, and ethical controversy.

Claude API Comes to Google Cloud: IAM Integration and SDK Access Guide
Anthropic hosts the full Claude API on Google Cloud with IAM-controlled permissions and unified billing. This guide covers the Vertex AI and Anthropic-hosted entry points, IAM role configuration, and SDK access.