In these situations where you're taking a photograph of writing or a diagram on a piece of paper, it can be surprisingly tricky to get rid of the shading from the lighting conditions and be left with just the content on the page in high contrast. This explanation nails how to do it though: http://www.imagemagick.org/Usage/compose/#divide Divide a blurred copy by the original and you end up with effectively an adaptiv…
Google Photoscan mentioned by someone else is also great, it's available on iOS and Android
It takes a series of photos, and guides you to move the phone as the document is illuminated from different angles by the led flash. It then blends them for optimal result to eliminate glare