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
Colour, Grayscale or Black and White: Choosing the Right Scan Mode
What each scan mode does, which documents suit which mode, and how the choice affects readability and file size.
Read article →Fixing Glare, Shadows and Low Light in Document Scans
Why scans come out shiny, shadowed or dim, and simple lighting and positioning changes that give you clean, readable pages.
Read article →Scan Resolution and DPI Explained: How Sharp Does a Scan Need to Be?
What DPI means for scanned documents, how much you need for reading, printing and archiving, and how resolution affects file size.
Read article →Scanning Curled, Crumpled and Folded Pages Flat
Ways to flatten and capture creased, rolled or damp-warped paper so your scan doesn't show distorted text or dark fold lines.
Read article →