Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

B. Output Tabs: Dewarping

daa2018 edited this page May 5, 2018 · 3 revisions

Dewarping

The dewarping grid for current processed page is shown on the same-name tab in the upper right corner of the central window. If dewarping mode is OFF then the grid is rectangular with straight lines:

Pressing "Change", you will see the two main ST dewarping modes - Auto and Manual:

AUTO dewarping makes it easy to get very nice output results for curved input:

The algorithm finds two vertical bondaries and two curves representing long horizontal text lines (perpendicular to boundaries and being far apart; they don't have to be the topmost and the bottommost lines). This distortion model is enough to dewarp the whole page:

All steps of the detection can be seen in the debugging mode:

The main stages are: 1. Detection of vertical boundaries; 2. Rough tracing of text lines, getting polylines; 3. Improvement of polylines with so-called "coupled snakes"; 4. Fitting X-splines to polylines with the aim of editing these splines (and our dewarping grid) later manually; 5. Selection of best splines pair (the larger the distance between them, the better) and building distortion model.

There is also an edge tracer integrated into the dewarping algorithm. Where available, it traces top & bottom page edges, detecting their right position. These edges complement the text lines and will be treated in the same way. After all, the algorithm doesn't need specifically text lines, but anything that's long and horizontal on the flat page.

Picture zones are not taken into account for dewarping. So, this layout is one of the most hopeless cases for auto-improvement. No book edges, no long text lines, and each of them either starts, or ends with a picture:

If the auto-detected grid was not set properly, user can adjust it manually. (To apply these changes, switch the dewarping mode to MANUAL.) First of all, notice the relation between the grid's vertical boundaries and the content zone's boundaries. Nothing will be added (1), or lost (2). (The output mode here is "Color/Grayscale" with "White margins".) So you can edit the left and right grid's edges carelessly. Content in the content's zone will not disappear:

Secondly, notice that with the distortion model of our initial example the bottom line needs more accuracy as it is not the bottommost text line:

You can improve the dewarping results in top and bottom areas by adding more new control points (red dots) and matching better line fit with movements of the existing ones. Non-corner red dots might not be on the text line, but the spline generated by them should be. Unnecessary control points can be deleted with D or DEL keys:

The middle red control points are configured as approximation points: the X-spline does not have to pass through them, but will be attracted to them as if being pulled by springs. These control points don't matter by themselves - they only help the user to control the shape of the top and bottom curves. If you delete all midpoints and these curves will be straight lines, you will get dekeystoning without dewarping.

Finally, consider the effect of "Depth perception" control, which is adjustable in both AUTO and MANUAL dewarping modes:

This control adjusts the distance from the camera to the page, but in normalized units. Its value changes from 1 to 3 in steps of 0,1. ST couldn't derive this distance from the image itself. Its changes affect the horizontal compression of letters at the binding:

After the dewarping grid is set on the page (the distortion model is built), the output image will be transformed so that this grid becomes rectangular with straight and equidistant lines.

References:

  1. Cao H., Ding X., Liu C., "Rectifying the bound document image captured by the camera: A model based approach." Document Analysis and Recognition, 2003. Proceedings. Seventh International Conference on. IEEE, 2003 [download]

  2. Bukhari S., Shafait F., Breuel T., "Coupled snakelets for curled text-line segmentation from warped document images" // International Journal on Document Analysis and Recognition, vol 16(1), March 2011, pp 1-21 [download]

  3. Blanc C., Schlick C., "X-splines: A spline model designed for the end-user." Proceedings of the 22nd annual conference on Computer graphics and interactive techniques. ACM, 1995. [download]