The automatic tilt correction function detects and corrects tilts of approximately ±3 degrees automatically. Correction is optional, and the application can also rotate the image based on the tilt information obtained. It may seem that ±3 degrees is small, but for an A4 document, as shown in the figure below, it is a noticeable tilt and sufficient for people who roughly place the document on the scanner.
1 degree 2 degrees 3 degrees
Tilt detection is performed using a hybrid method that utilizes both the tilt information of line segments and the tilt information of text.
  1. If the tilt of a line segment is nearly the same as the tilt of mostly horizontal or vertical line segments, use that tilt as the document's tilt.
  2. Use the function of the raster-vector transformation library.

  3. If there are few line segments that are nearly horizontal or vertical, and the tilt of the line segments varies significantly, use the tilt of the text as the document's tilt.
  4. If the tilt of a text line that is mostly horizontal or vertical and of a certain length is nearly the same, use that tilt as the document's tilt.
  5. Use the function of the OCR library.

  6. If there are few text lines that are nearly horizontal or vertical, and the tilt of the text lines varies significantly, tilt detection of the document fails.