Tutorial · Output Stage
Dewarping in ScanTailor Advanced: Flatten Curved Book Pages
A page photographed in the gutter of a thick book is not a rectangle — it curves down into the spine, and its text lines curve with it. Dewarping builds a distortion model of that curved page and re-renders it flat. It lives at the Output stage, on its own tab, and it is the most powerful — and most easily misused — tool in the pipeline.
Why Pages Curve, and What Dewarping Does About It
Deskew could only rotate the page; it assumed the page was flat. Book pages near a binding are not. The text block wraps around the spine’s curve, lines bow, and characters near the gutter are foreshortened because that part of the page angles away from the camera or scanner.
Dewarping replaces rotation with a distortion model. You see it as a grid (mesh) over the page on the Dewarping tab of the Output stage. When the output is rendered, that grid is forced back into a rectangle with straight, evenly spaced lines — and the page image is transformed with it. Curved text lines become straight because the model says where they would sit on a flat page.
Automatic dewarping builds the model from the page itself: it detects the two vertical boundaries of the text block and two long, roughly horizontal text lines far apart on the page, traces them precisely, and fits the grid to them. Page edges, where they can be traced, complement the text lines — the algorithm ultimately needs anything that is long and horizontal on the flat page. Then one rendering pass flattens everything.
The Modes: Off, Automatic, Manual — and Marginal
Off
The grid stays rectangular: no dewarping at all. This is the correct setting for genuinely flat sources — flatbed scans, loose sheets, single pages pressed flat. Running dewarping on an already-flat page can only invent curvature that is not there.
Automatic
The program finds boundaries and text lines and builds the model itself. Right for the great majority of bound-book camera scans and the starting point even when you expect to hand-tune a few pages afterwards.
Manual
You adjust the grid: move the existing control points, add new ones (unnecessary points can be deleted with the D or Delete keys), and shape the top and bottom curves until they follow the text. Note the Advanced behaviour: as soon as you drag the mesh on an automatic page, the mode switches to Manual by itself.
Marginal dewarping
An automatic variant inherited from the Featured branch. It works only on scans that show the page’s curved top and bottom borders against a black background: it sets the grid’s points along those borders to build the model. The documentation is specific that it works best on low-curved scans.
Two manual-mode details that matter
- The middle control points are approximation points. The curve does not have to pass through them; they pull it like springs. If you delete all the midpoints on a curve, that curve becomes a straight line — which turns dewarping into pure de-keystoning (trapezoid correction without curve flattening), sometimes exactly what a slanted-but-flat page needs.
- Depth perception. Adjustable in both automatic and manual modes, this control represents the camera-to-page distance (in normalised units, from 1 to 3 in steps of 0.1). The program cannot derive the real distance from the image, and the value changes how much the letters near the binding are horizontally decompressed. If gutter text still looks squeezed after automatic dewarping, this is the control to try before redrawing the whole mesh.
- The grid edges are forgiving. The grid’s left and right boundaries relate to the content zone, not to the raw image: adjusting them does not add or lose content — the content you selected at Select Content is what gets dewarped.
When to Skip Dewarping — and Its Hard Limits
- Flatbed scans: skip it. A page pressed against flat glass has no curve to model. Leave the mode Off (the rectangular grid) and let the other stages do their work.
- Pages with nothing to model from: automatic will struggle. The algorithm needs long horizontal references — text lines or page edges. Picture zones are not taken into account. The documentation’s own “hopeless case” is a page where every line begins or ends with a picture, with no book edges visible: expect to hand-build the grid in Manual mode, or accept the page as it is.
- Severe curl near a tight spine exceeds the model. Dewarping assumes the traced lines describe the page’s shape. A page that dives steeply into a narrow gutter may have text the camera barely resolved at capture time; no model restores characters that were never captured. Rescan with the book better supported — capture quality is decided at the hardware stage, not here.
- Illustration-heavy pages: straightening a full-page engraving with a text-line model can warp the artwork. Consider Off for plates, and let them pass through with deskew and margins only.
← Previous: Page Layout Next: Binarization & Threshold Methods →
Frequently Asked Questions
Should I dewarp flatbed scans?
No. A page pressed flat on a scanner has no curvature to model, so leave dewarping Off — the grid stays rectangular and the page passes through untransformed. Dewarping exists for bound-book pages whose surface genuinely curves, typically photographed or scanned on an overhead device.
Automatic dewarping made my page worse. What now?
Switch to the page and adjust the grid manually — dragging the mesh automatically puts the page into Manual mode. Reposition control points so the top and bottom curves follow real text lines, add points where the curve is under-fitted (delete with D or Delete), and try the depth perception control if letters near the binding still look compressed.
Why does automatic dewarping fail on illustrated pages?
The model is built from the text block’s vertical boundaries and long horizontal text lines (or traced page edges); picture zones are explicitly not used. A page whose lines are all interrupted by pictures gives the algorithm nothing to fit, which the project documentation itself calls a hopeless case for automatic improvement — use Manual mode or leave dewarping off for such pages.
