batch.py
contains a system for cropping collections of images and creating a PDF.
dewarp.py
contains (incomplete) implementations of two dewarping algorithms:
- Kim et al. 2015, Document dewarping via text-line based optimization
- Meng et al. 2011, Metric rectification of curved document images
Focal length is currently assumed to be that of the iPhone 7, because that’s what I have been using to test. Change the f value at the top of this file if using a different camera.
binarize.py
contains a ton of binarization algorithms, which should all have mostly-optimized implementations.
- Niblack binarization
- Sauvola and Pietikäinen 2000, Adaptive document image binarization
- Kamel and Zhao 1993, Extraction of binary character/graphics images from grayscale document images
- Yang and Yan 2000, An adaptive logical method for binarization of degraded document images
- Lu et al. 2010, Document image binarization using background estimation and stroke edges (background estimation portion incomplete)
- Su et al. 2013, Robust document image binarization technique for degraded document images (DIBCO 2013 champion)
- Ntirogiannis et al. 2014, A combined approach for the binarization of handwritten document images
block.py
contains some text-structuring stuff.
upscale.py
has some (incomplete) routines for single-image superresolution using text as a prior.
- Lee et al. 2007, Efficient sparse coding algorithms
- Walha et al. 2012, Super-resolution of single text image by sparse representation
- Liu et al. 2014, Blockwise coordinate descent schemes for sparse representation
Requirements: Numpy/Scipy, OpenCV (with python bindings), Cython
I don’t know how to make a proper build system for Cython modules, so just do:
python setup.py build_ext --inplace
I have not examined the patent status of any of these algorithms. Use at your own risk.
Do not use this program to violate copyright laws in your country.
Copyright 2018 Patrick Hulin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.