How Edge Detection and Perspective Correction Turn a Photo into a Scan
A plain-English look at what a scanner app does automatically — finding the page, straightening it and evening out the light — and how to help it.
Point a phone at a page from an angle, and you get a trapezoid, with the near edge wider than the far edge. A scanner app turns that into a flat rectangle in a moment. It's helpful to know what's happening, because you can then help the app do a better job.
Step one: finding the edges
The app analyses the camera image to find the boundary of the page. It looks for lines where the brightness or colour changes, such as where white paper meets a dark table, and tries to identify four corners forming a document shape.
What helps it:
- A plain surface that contrasts with the page, such as a dark desk under a white sheet.
- Good, even light, so edges are distinct.
- The whole page in view, with a little margin.
What confuses it:
- A white page on a white table.
- Busy patterns, such as a wooden tabletop with strong grain or a patterned tablecloth.
- Shadows falling across an edge.
- Other objects overlapping the page.
Step two: correcting perspective
Once the four corners are identified, the app stretches the image so that those corners become the corners of a true rectangle. The result is a flat page, as if you had photographed it from directly above.
Perspective correction has limits. The more extreme the angle, the more the far side of the page is stretched, and the softer the text becomes. Shooting close to square-on gives sharper results.
Step three: cropping
The area outside the detected page is cut away. If corners are placed wrongly, you might lose part of the page, or include unwanted background. Most apps let you drag the corner handles to adjust before saving.
Step four: enhancement
The app can then improve the look of the scan by:
- Evening out lighting and shadows across the page
- Whitening the paper background
- Boosting contrast so text is darker
- Converting to grayscale or black and white, if you choose
Step five: saving as PDF
Finally, the processed image or images are combined into a PDF, with compression applied to keep the file size manageable.
How to help the app
- Use a contrasting background.
- Keep the phone roughly parallel to the page.
- Fill the frame without cutting off corners.
- Check the crop handles before you accept the scan.
- Rescan if the edges look wrong.
When automatic detection fails
If the app can't find the page, adjust the corners by hand, or place the page on a different surface. For pages with very light edges, such as a pale receipt on a white table, a dark backing sheet makes a big difference.
Why it matters
Understanding the process explains why some scans look crisp and others look stretched. The steps you control, lighting, angle and background, do most of the work.
Let Document Scanner find edges and straighten pages automatically →
Document Scanner
Turn your phone camera into a professional PDF scanner
More about Document Scanner
Scanning Children's Artwork Before It Piles Up
Kids produce mountains of drawings. Scan the artwork to preserve memories without keeping every sheet, and turn the collection into something you'll actually enjoy.
Read article →Scanning Contracts Page by Page Without Missing Anything
A contract scan is only useful if every page, initial and signature is there. Follow this checklist to scan long agreements completely and in the right order.
Read article →Scanning Your Driving Licence and Vehicle Documents
Keep clear digital copies of your driving licence, registration, insurance and pollution certificates for renewals, rentals and emergencies.
Read article →Scanning Educational Certificates and Mark Sheets
Degree certificates and mark sheets are needed for jobs, admissions and visas. Learn how to scan them clearly, keep originals safe and organise a complete academic file.
Read article →