I saw some research papers
Book Fold Correction
Distortion Reduction
Distortion Reduction 2
which should do that "automagically" and also some high-end book scanners:
High-End Book Scanner
If they can do it, then perhaps also some clever mind could do something similar