# Enhancing OCR for Persian: Voting-Based Layout Analysis and Font-Size-Driven Text Line Detection

> Research notes on a Persian OCR pipeline that uses a multi-model voting ensemble for document layout analysis and a distance-transform-based optimum font size concept for text line detection, evaluated on a new 1,920-image newspaper dataset.

- Authors: Hunter Heidenreich
- Published: 2026-03-13
- Paper: Published (Engineering Reports 2024) <https://doi.org/10.1002/eng2.12832>
- Dataset: OIN Dataset <https://drive.google.com/file/d/1mW42XHwY2hM4Z-ouhkEtgq8HJJqIOib/view>
- Dataset: Synthetic Persian Dataset <https://drive.google.com/file/d/1jaDp7qI6480yNImRZQpkYaOJ807mv8J/view?usp=sharing>
- Source: Bevaya Labs, <https://labs.bevaya.ai/>

---


## TL;DR

Fateh et al. propose an OCR pipeline for Persian newspaper documents with two main components: (1) a DLA stage that ensembles four object detectors (YOLOv3, SSD, Faster R-CNN, Layout Parser) via a pixel-level voting system with 5$\times$5 dispute resolution, and (2) a TLD stage that uses distance-transform-based "optimum font size" estimation, projection-based angle correction, and a baseline-alignment algorithm for line curvature elimination. On their new Official Iranian Newspapers (OIN) dataset (1,920 images), the pipeline reduces Tesseract-OCR 5.1.0 error rate from 6.2% to 3.4%.

## What kind of paper is this?

**Dominant:** $\Psi\_{\text{Method}}$ The headline contribution is the two-stage pipeline: a voting-based DLA ensemble and a heuristic TLD method built around the "optimum font size" concept. The bulk of the paper describes algorithms (7 pseudocode listings), with tables comparing against Kraken and OCRopus.

**Secondary:** $\Psi\_{\text{Resource}}$ The authors introduce the OIN dataset (1,920 scanned newspaper images with 32,642 text lines), filling a gap in Persian-language DLA/TLD resources.

## What is the motivation?

Most DLA and TLD methods are developed for Latin scripts and do not transfer well to Persian and Arabic, which have connector/non-connector letters, extensive diacritics, and frequent dots that interfere with both layout segmentation and line detection. Deep-learning-based TLD methods (Kraken, OCRopus) require large labeled training sets that are unavailable for Persian. Existing TLD approaches also struggle with curved text lines and image skew, both common in newspaper scans. The authors aim to build a pipeline that works well for Persian without requiring large labeled Persian TLD training data.

## What is the novelty?

### 1. Multi-Model Voting for DLA

Four object detectors (YOLOv3, SSD, Faster R-CNN, Layout Parser) each produce pixel-level text/non-text predictions. A per-pixel voting system classifies each pixel by majority vote. For "disputed" pixels where text and non-text votes are tied, a 5$\times$5 window aggregates surrounding votes to break the tie. The result is a binary text/non-text segmentation map.

### 2. Optimum Font Size via Distance Transform

The TLD stage computes the Euclidean distance transform of the binarized image, then identifies the most frequently occurring diameter across all connected components (CCs). This "optimum font size" serves as an adaptive scale parameter throughout the pipeline:

- CCs with fewer than $10 \times \text{OptimumFontSize}$ pixels are classified as dots/diacritics and removed before line grouping
- The search length for connecting CCs into lines is $A \times \text{OptimumFontSize}$, where $A$ is an adaptive coefficient:

$$
A = \begin{cases} \frac{60 - \text{OptimumFontSize}}{10} & \text{if OptimumFontSize} < 50 \\\\ 1 & \text{otherwise} \end{cases}
$$

### 3. Angle Correction and Line Curvature Elimination

Angle correction uses a coarse-to-fine rotation search: the image is rotated in 1-degree steps over $[-10^\circ, 10^\circ]$, selecting the angle that maximizes near-zero rows in the horizontal projection. A second pass refines within $\pm 1^\circ$ at 0.1-degree resolution.

For curved lines, the method extracts a baseline from the middle 60% of columns (trimming 20% from each end to avoid edge curvature), then decomposes lines into subwords using vertical projection gaps. Subwords whose local baselines deviate from the main baseline are vertically shifted to align.

## What experiments were performed?

### Datasets

- **OIN (Official Iranian Newspapers):** 1,920 scanned images at 300 dpi; 32,642 lines, 2.35M CCs. Created by the authors.
- **PRImA:** 478 magazine/article images (used for DLA evaluation only).
- **Arabic OCR:** 50 images of Arabic text with slight rotation.
- **Synthetic:** 962 images generated from 6 Persian fonts (Tahoma, XB-Niloofar, Ziba, IranNastaliq, Arial, Nazanin) in 5 sizes and 3 styles.

### DLA Results

| Method | $\text{Acc}\_{\text{text}}$ (OIN) | $\text{Acc}\_{\text{nontext}}$ (OIN) | $\text{Acc}\_{\text{text}}$ (PRImA) | $\text{Acc}\_{\text{nontext}}$ (PRImA) |
| :--- | :---: | :---: | :---: | :---: |
| Layout Parser | 78.31% | 94.53% | 85.47% | 90.74% |
| SSD | 87.51% | 93.39% | 89.32% | 92.93% |
| YOLOv3 | 93.33% | 94.02% | 93.78% | 95.73% |
| Faster R-CNN | 93.67% | 94.36% | 93.53% | 95.23% |
| Voting ensemble | **94.77%** | **98.04%** | **96.11%** | **97.96%** |

### TLD Results (OIN)

| Method | CC Detection Error | CC Removal Error | Total Error | Runtime (s/image) |
| :--- | :---: | :---: | :---: | :---: |
| OCRopus | 0.66% | 8.60% | 9.26% | 19.25 |
| Kraken | 2.14% | 0.17% | 2.32% | 16.25 |
| Proposed | **0.19%** | 0.31% | **0.51%** | **12.25** |

The pattern is consistent across the synthetic dataset (0.11% vs 5.32% Kraken, 10.39% OCRopus) and Arabic dataset (0.18% vs 1.29% Kraken, 4.13% OCRopus).

### OCR Impact

Using the TLD step before Tesseract-OCR 5.1.0 reduced total error from 6.235% to 3.431% on OIN (a 2.8 percentage point improvement), and from 13.38% to 1.52% on the Arabic dataset.

## What are the outcomes/conclusions?

The voting ensemble consistently outperforms individual detectors for DLA on both OIN and PRImA. The font-size-based TLD method outperforms Kraken and OCRopus by a wide margin, particularly on images with curved lines and the IranNastaliq font (which resembles handwriting). The combined pipeline improves downstream OCR accuracy.

### Limitations

- **Non-standard DLA metrics.** The DLA evaluation uses pixel-level text/non-text accuracy (Equations 3-4), not standard mAP or IoU metrics. This makes comparison with the broader DLA literature difficult.
- **Non-standard TLD metrics.** TLD is evaluated by CC-level error rates (wrong-line assignment and undetected CCs). These are reasonable for measuring OCR impact but not directly comparable to standard segmentation metrics.
- **Hardcoded thresholds.** The $10\times$ factor for dot/diacritic removal, the adaptive coefficient formula, the 20% column trimming, and the $2\times$ median height threshold for detecting merged lines are all empirically tuned. No sensitivity analysis is provided.
- **DLA requires running four models.** The voting ensemble is inherently slow because it runs four object detectors. No runtime comparison is given for the DLA step itself (only TLD runtimes are reported).
- **Limited baselines.** TLD is compared only against Kraken and OCRopus. No comparison with projection-profiling, CC-based, or other heuristic methods from the related work section.
- **No code released.** The algorithms are described in pseudocode but no implementation is provided.
- **Dataset hosting.** OIN and synthetic datasets are hosted on Google Drive with no formal repository (e.g., Zenodo, HuggingFace), raising long-term availability concerns. No explicit license is stated for either dataset.
- **Narrow domain.** Results are demonstrated on Persian/Arabic newspaper scans. Generalization to multi-column layouts, tables, figures, or non-newspaper documents is not evaluated.
- **The 2.8% OCR improvement is modest.** The headline OCR improvement on OIN (6.2% to 3.4%) is meaningful but is measured end-to-end through Tesseract, making it hard to attribute gains specifically to DLA vs. TLD vs. preprocessing.

## Reproducibility

### Models

- DLA: YOLOv3, SSD, Faster R-CNN, Layout Parser (all pre-existing; no architecture modifications described).
- TLD: Entirely heuristic (no learned parameters beyond the DLA models).
- Preprocessing: Pre-trained denoising CNN (DnCNN, Zhang et al. 2017) for image denoising; Bradley's adaptive thresholding for binarization.
- No model weights or checkpoints released.

### Algorithms

- Seven algorithms described in pseudocode (Algorithms 1-7).
- Key hyperparameters: $10\times$ optimum font size threshold for dot/diacritic removal; adaptive coefficient formula for search length; 20% column trim for baseline extraction; coarse rotation range $[-10^\circ, 10^\circ]$ at 1-degree steps, refined to $\pm 1^\circ$ at 0.1-degree steps.
- No optimizer/training details for the DLA models (they appear to use default configurations).
- No code released.

### Data

- **OIN:** 1,920 newspaper images scanned at 300 dpi with HP Scanjet 4890. Available on [Google Drive](https://drive.google.com/file/d/1mW42XHwY2hM4Z-ouhkEtgq8HJJqIOib/view). No license specified. 70/10/20 train/val/test split.
- **PRImA:** 478 magazine/article images. Standard DLA benchmark. Available at [primaresearch.org](https://www.primaresearch.org/datasets/).
- **Arabic OCR:** 50 images from [Google Drive](https://drive.google.com/drive/folders/1-wsm4NIZB8Reu70jg-wBO56Pq89N6fs). No license specified.
- **Synthetic:** 962 images, 6 fonts, 5 sizes, 3 styles. Available on [Google Drive](https://drive.google.com/file/d/1jaDp7qI6480yNImRZQpkYaOJ807mv8J/view?usp=sharing). No license specified.

### Evaluation

- DLA: Pixel-level accuracy for text and non-text regions (Equations 3-4). Non-standard.
- TLD: CC-level error rates (Equations 5-7): CC detection error (wrong line), CC removal error (undetected), total error. Non-standard.
- OCR: Tesseract-OCR 5.1.0 error rate, broken down by dot/diacritic and main text CCs.
- No error bars, confidence intervals, or multi-run statistics reported.
- No cross-validation or statistical significance tests.

### Hardware

- No hardware specifications reported.
- No training time, GPU type, or compute requirements mentioned.

## BibTeX

```bibtex
@article{fateh2024enhancing,
  title={Enhancing optical character recognition: Efficient techniques for document layout analysis and text line detection},
  author={Fateh, Amirreza and Fateh, Mansoor and Abolghasemi, Vahid},
  journal={Engineering Reports},
  volume={6},
  number={9},
  pages={e12832},
  year={2024},
  publisher={Wiley},
  doi={10.1002/eng2.12832}
}
```


