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
.
Run the dewarp.py
script :
python ./dewarp.py ./sample.png ./output.png
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.
- Load Image :
- Convert from RGB to Grayscale :
- Apply Otsu's Thresholding Method, Erosion and then Dilation :
- Calculate curve using Generalized Additive Model :
- Final Image :
- Input Image :
- Output Image :
- Input Image :
- Semi-processed Image :
- Output Image :
The rectification dataset can be viewed and downloaded through this link.
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.