Giter VIP home page Giter VIP logo

curved-text-alignment's Introduction

Text Line Dewarping

Dependencies

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 :

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

To process the image only where there's text

Run the tight_dewarp.py script :

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

  1. Convert from RGB to Grayscale :

Output image

  1. Apply Otsu's Thresholding Method, Erosion and then Dilation :

Original image

  1. Calculate curve using Generalized Additive Model :

Output image

  1. Final Image :

Output image

Greek Text Example

  1. Input Image :

Output image

  1. Output Image :

Output image

Rectification

  1. Input Image :

Output image

  1. Semi-processed Image :

Output image

  1. Output Image :

Output image

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

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.

curved-text-alignment's People

Contributors

rramphal avatar tomstog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rramphal silverl

curved-text-alignment's Issues

Correcting incomplete curvature

i try to fix this this curve image:
output png_tresh

it found red line very good:
Screenshot 2024-03-17 175241

this is output image:
Screenshot 2024-03-17 175248

The algorithm you wrote needs some changes due to the large curvature. In fact, the middle of the curve is correctly smoothed( "S" character was uncurved correctly), but the left and right sides are not smoothed well.
In an article titled "Alignment of Curved Text Strings for Enhanced
"OCR Readability" worked like this. Can you make changes like this?
Screenshot 2024-03-18 130251

LinearGAM gridsearch is slow

hi. thanks for sharing your code.
it works great.
is there any faster alternative for LinearGAM library or gridsearch function? it takes 1 second to run and it will make ocr slow (for example run for 20 line in one image)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.