curved-text-alignment

A function that takes as input a cropped text line image, and outputs the dewarped image.

https://github.com/tomstog/curved-text-alignment

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.8%) to scientific vocabulary

Keywords

bresenham-algorithm curved-text dewarp dewarping generalized-additive-models greek-language greek-texts image-processing python rectification text-alignment text-rectification
Last synced: 9 months ago · JSON representation

Repository

A function that takes as input a cropped text line image, and outputs the dewarped image.

Basic Info
  • Host: GitHub
  • Owner: TomStog
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 1.34 MB
Statistics
  • Stars: 21
  • Watchers: 2
  • Forks: 4
  • Open Issues: 0
  • Releases: 0
Topics
bresenham-algorithm curved-text dewarp dewarping generalized-additive-models greek-language greek-texts image-processing python rectification text-alignment text-rectification
Created over 3 years ago · Last pushed 9 months ago
Metadata Files
Readme

README.md

Text Line Dewarping

Dependencies

shell pip3 install -r requirements.txt

NOTE: If you are using pyenv to install older versions of Python, you might need to install development versions of libsqlite3x, ncurses, readline, and tkinter. For example, on Fedora: dnf install libsq3-devel ncurses-devel readline-devel tk-devel.

Running

To process the entire image

Run the dewarp.py script :

shell python ./dewarp.py ./sample.png ./output.png

To process the image only where there's text

Run the tight_dewarp.py script :

shell python ./tight_dewarp.py ./sample.png ./output.png

Both functions exhibit comparable performance, with no discernible advantage in either. The primary distinction lies in their operational scope: dewarp.py operates across the entire image, whereas tight_dewarp.py specifically tracks the leftmost and rightmost black pixels within Otsu's threshold image, concentrating its efforts within that identified range.

Steps

1) Load Image :

Original image

2) Convert from RGB to Grayscale :

Output image

3) Apply Otsu's Thresholding Method, Erosion and then Dilation :

Original image

4) Calculate curve using Generalized Additive Model :

Output image

5) Final Image :

Output image

Greek Text Example

1) Input Image :

Output image

2) Output Image :

Output image

Rectification

1) Input Image :

Output image

2) Semi-processed Image :

Output image

3) Output Image :

Output image

The rectification dataset can be viewed and downloaded through this link.

Results and Performance

The number of splines used for the initial curve estimation is 8, and the number of splines used for the final alignment is 12.

| Warping Function | DW | Word Error Rate w/o Rectification | Character Error Rate w/o Rectification | Word Error Rate w/ Rectification | Character Error Rate w/ Rectification | |:------------------:|:--------:|:---------------------------------:|:-------------------------------------:|:---------------------------------:|:-------------------------------------:| | y = -x | 99.86% | 0.9440 | 0.5063 | 0.1552 | 0.0237 | | y = x2 | 99.86% | 1.3352 | 0.8339 | 0.3973 | 0.0620 | | y = -x3 | 99.88% | 1.1067 | 0.6613 | 0.1838 | 0.0318 | | y = x4 | 99.92% | 1.7962 | 0.7910 | 0.3772 | 0.0575 |

Suppose we aim to improve performance for the y = x2 scenario by identifying an optimal set of numbers. Below is the variation in CER and WER scores based on the number of splines used:

cer

wer

Citation

If you have found value in this repository, we kindly request that you consider citing it as a source of reference:

Stogiannopoulos, Thomas. “Curved Line Text Alignment: A Function That Takes as Input a Cropped Text Line Image, and Outputs the Dewarped Image.” GitHub, December 1, 2022. https://github.com/TomStog/curved-text-alignment.

For more information, you can also check my paper "Curved Text Line Rectification via Bresenham’s Algorithm and Generalized Additive Models" here.

@article{Stogiannopoulos2024CurvedTL, title={Curved Text Line Rectification via Bresenham’s Algorithm and Generalized Additive Models}, author={Thomas Stogiannopoulos and Ilias Theodorakopoulos}, journal={Signals}, year={2024}, url={https://api.semanticscholar.org/CorpusID:273595704} }

Owner

  • Name: Thomas Stogiannopoulos
  • Login: TomStog
  • Kind: user

PhD Candidate at Democritus University of Thrace (D.U.Th.)

GitHub Events

Total
  • Watch event: 8
  • Issue comment event: 1
  • Push event: 12
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Watch event: 8
  • Issue comment event: 1
  • Push event: 12
  • Pull request event: 1
  • Fork event: 1

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • josef821 (2)
Pull Request Authors
  • rramphal (1)
  • jasseeeem (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

requirements.txt pypi
  • matplotlib ==3.8.2
  • numpy ==1.23.5
  • opencv-python ==4.9.0.80
  • pandas ==2.2.0
  • pygam ==0.8.0
  • pytz ==2023.3.post1