Abstract: Data extraction from line-chart images is an essential component of the automated document understanding process, as line charts are a ubiquitous data visualization format. However, the amount of visual and structural variations in multi-line graphs makes them particularly challenging for automated parsing. Existing works, however, are not robust to all these variations, either taking an all-chart unified approach or relying on auxiliary information such as legends for line data extraction. In this work, we propose LineFormer, a robust approach to line data extraction using instance segmentation. We achieve state-of-the-art performance on several benchmark synthetic and real chart datasets.
TL;DR
LineFormer redefines line chart data extraction by treating each data series as a unique object to be segmented at the pixel level. By moving away from traditional keypoint detection—which often fails when lines cross or overlap—this transformer-based approach achieves state-of-the-art results on complex, real-world multi-line charts.
The Challenge of Multi-Line Charts
Automated document understanding requires converting visual data visualizations back into their raw tabular formats. While bar and pie charts are relatively straightforward to parse, multi-line charts present significant hurdles for computer vision.
The authors identify three primary structural obstacles:
- Crossings: Where lines intersect, making it difficult to track which path belongs to which series.
- Occlusions: Where markers or other lines hide segments of data.
- Crowding: High-density areas where lines are bundled so closely that local features become indistinguishable.
Existing methods typically rely on "keypoint detection" (finding dots and connecting them) or "bottom-up" grouping. These often fail because they lack the global context needed to track a line through a messy intersection.
The LineFormer Architecture
The core innovation of LineFormer is reformulating the problem as instance segmentation. Instead of looking for points, the model looks for the entire "body" of each line as a single object.
- Architecture: The system uses a transformer-based encoder-decoder architecture (inspired by Mask2Former). It employs a Swin-Transformer backbone to extract multi-level features from the chart image.
- Mask Prediction: A pixel decoder upsamples these features into embeddings. Simultaneously, a transformer decoder uses "object queries" to attend to these features and predict a binary pixel mask for every individual line in the chart.
- Data Series Extraction: Once the masks are generated, the system samples foreground points at regular intervals along the x-axis. If there are small gaps or breaks in the predicted mask, it uses linear interpolation to reconstruct a continuous data series.
- End-to-End Training: The model is trained using a combination of classification loss and mask prediction loss (a mix of Dice and cross-entropy losses).
Datasets and Evaluation
To ensure the model could handle both "perfect" synthetic data and "messy" real-world data, the authors used three key datasets:
- AdobeSynth19: A large-scale synthetic dataset (38,000 images) generated using matplotlib.
- LineEX: Another synthetic dataset featuring high variation in line styles, markers, and colors.
- UB-PMC22: The "gold standard" for this study—a dataset of real-world charts manually annotated from PubMed Central scientific papers. This is significantly more challenging due to the diversity of publishing styles.
Key Insights
- Global Context is King: Unlike keypoint detectors that get "confused" at intersections, the transformer-based segmentation approach looks at the entire trajectory of the line. This allows the model to gather contextual information from surrounding areas to "fill in the gaps" during occlusions.
- The "Line as an Object" Shift: By treating a line as a single instance (like a car or a person in standard CV tasks), the model bypasses the need for complex, error-prone grouping heuristics. If a pixel is in the mask, it belongs to that line.
- Robustness to Backbones: Performance remained stable across different backbones (Swin-T vs. ResNet), suggesting that the segmentation framework itself is the primary driver of success.
Results and Performance
LineFormer demonstrated a significant performance leap, particularly on real-world data:
- State-of-the-Art on UB-PMC22: On the challenging real-world dataset, LineFormer achieved a Data Extraction score of 88.25, vastly outperforming previous leaders like ChartOCR (72.9) and Lenovo (67.01).
- Precision Stability: Most existing models see a massive drop in performance when moving from "Visual Element Detection" (finding the lines) to "Data Extraction" (getting the actual numbers). LineFormer’s scores remained remarkably consistent, indicating a much higher precision rate.
- Qualitative Superiority: Visual comparisons show that while other models "break" or swap identities at line crossings, LineFormer successfully tracks individual lines through dense, crowded areas.
Limitations and Future Work
Despite its strengths, the authors noted areas for improvement:
- Duplicate Masks: Occasionally, the model predicts two masks for the same line. Future iterations could use Intersection Over Union (IoU) based suppression to filter these out.
- Legend Association: While LineFormer extracts the data, it doesn't inherently know which line corresponds to which label in the legend. The authors propose using a Siamese network in the future to match line embeddings with legend patches.
- X-Axis Mapping: The current extraction outputs image coordinates; mapping these back to original tabular units requires accurate axis parsing, which is currently treated as a separate auxiliary task.
Summary updated