Skip to content

phulin/rebook

Repository files navigation

Rebook: various book-scan-processing programs

Cropping

batch.py contains a system for cropping various input formats of collections of images and creating a PDF.

Dewarping

dewarp.py contains implementations of two dewarping algorithms:

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.

The Kim et al. algorithm seems to actually work (and be fast enough to process large numbers of pages in a reasonable amount of time); you can use it directly or via batch.py --dewarp.

Binarization

binarize.py contains a ton of binarization algorithms, which should all have mostly-optimized implementations.

The last algorithm is the best I've found on this set of inputs.

Text Structuring

block.py contains some text-structuring stuff. I intended to use this as a replacement for the current text-line detection system, but I haven't been able to get it to work.

Super-resolution

upscale.py has some (incomplete) routines for single-image superresolution using text as a prior.

Building

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'd love to convert this all to Python 3, but there's something wrong with Cython. PRs are, of course, welcome.

Disclaimer

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.

License (MIT)

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.

About

A collection of tools for cleaning up book scans.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages