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.
Divide a blurred copy by the original and you end up with effectively an adaptive-normalize filter where the result is nice and clear with the shadows and uneven lighting left behind.
I really rate Microsoft's free Office Lens for document scanning. It automatically crops and there are a few filters you can experiment with to get the best result and the output to PDF or whatever.
MS OL works surprisingly well with OneDrive on my iPhone. I frequently use this pipeline on my desktop instead of using my USB printer/scanner.
I've also used OL on Windows 10 (desktop) to crop images of documents sent to me from others. The GUI assumes you're using the app on a tablet, but it's workable.
I don't like the recent update to OL which added a carousel of images from my iPhone's stored photos. I use OL exclusively for business, so the carousel showing personal photos is idiocy.
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
Most commercial solutions solve this by using bright illumination from both sides to avoid shadows. In a pinch a couple of led under-cupboard light strips off would probably work. Something like:
I'm surprised nobody has mentioned Scannable yet, by Evernote. I use it regularly: it's a simple and pleasant marvel of technology. Free, no account, point your camera at a doc and it somehow recognizes it, snaps a pic and makes it look just like a document scan, no shadow no nothing. Share as PDF or image. Miles ahead of Apple's "import scan from iPhone" feature, even though it predates it.
I don't have an Evernote account but I'd definitely pay a few bucks for this app if they pulled up a paywall.
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 adaptive-normalize filter where the result is nice and clear with the shadows and uneven lighting left behind.
Also though, there are tools like https://miro.com and https://beta.plectica.com which kinda make this obsolete for many common use cases.