Deskewing
Scanned documents often become skewed (slanted) during scanning because of misfeeds or other alignment errors. Skew is the amount of rotation necessary to return an image to horizontal and vertical alignment. Skew is measured in degrees. Deskewing is a process whereby skew is removed by rotating an image by the same amount as its skew but in the opposite direction. This results in a horizontally and vertically aligned image where the text runs horizontally across the page rather than at an angle.
When an image is not aligned correctly, optical character recognition (OCR) is more difficult and becomes slower and less accurate. Deskewing the documents beforehand can make the OCR process faster and more accurate.
LEADTOOLS offers some command classes that can automatically straighten scanned documents, as well as some that can be used manually:
The Leadtools.ImageProcessing.Core.DeskewCommand command class has the following features:
- Ability to deskew documents containing pictures
- Option to use high-speed rotation with 1-bit images (faster than normal rotation)
- Option to report the skew angle without performing deskew
Use the Leadtools.ImageProcessing.Core.DeskewCommand class to automatically straighten scanned documents of any kind. Images can be rotated by as much as 20 degrees in either direction to remove the skew. It can also be used when performing bank check scanning to obtain more accuracy than provided by the Leadtools.ImageProcessing.Core.DeskewCommand class. Images can be rotated by as much as 20 degrees in either direction. This class provides three different algorithms for performing deskew:
- The normal algorithm
- The bank check algorithm, which considers many features common to standard bank checks in order to determine orientation
- The line detection algorithm, which is an algorithm based on finding the lines in an image
The following images demonstrate the use of the DeskewCommand command on color, grayscale, and 1-bit images.
The original color image is shown in the following figure:
The deskewed color image is shown in the following figure:
The original grayscale image is shown in the following figure:
The deskewed grayscale image is shown in the following figure:
The original 1-bit image is shown in the following figure:
The deskewed 1-bit image is shown in the following figure:
The Leadtools.ImageProcessing.Core.PerspectiveDeskewCommand class has the following features:
- Created to preprocess images captured from digital cameras where the document's boundaries are inside the captured view and have a different background color than the background of the captured view.
- Deskews documents and takes the depth of the objects inside the image and their relative dimension into account.
- Works when there is depth (z-axis) deformation as well as deformation along the x- and y- axes.
- Unlike the Leadtools.ImageProcessing.Core.DeskewCommand, the PerspectiveDeskewCommand does not look at the content of the captured document. Therefore, use the Deskew Command when working with documents that contain straight lines that need to be rotated.
The Leadtools.ImageProcessing.Core.ManualPerspectiveDeskewCommand class has the following features:
- Created to preprocess images captured from digital cameras.
- Deskews documents and takes the depth of the objects inside the image and their relative dimension into account.
- Changes an image based on the perspective view equation which is a linear operation.
- Maps a polygon to a polygon.
- Unlike the Leadtools.ImageProcessing.Core.DeskewCommand, the ManualPerspectiveDeskewCommand does not look at the content of the captured document. Therefore, use the Deskew Command when working with documents that contain straight lines that need to be rotated.
- The Leadtools.ImageProcessing.SpecialEffects.FreePlaneBendCommand command changes the image by blending and merging the straight line that represents the image, whereas the ManualPerspectiveDeskewCommand changes an image by changing its perspective and taking the depth of the objects into consideration.
The Leadtools.ImageProcessing.Core.KeyStoneCommand class has the following features:
- Performs inverse perspective transformation (keystoning) on an image.
- Maps a polygon to a rectangle.
The Leadtools.ImageProcessing.Core.UnWarpCommand class has the following features:
- Removes the distortion in an image of a cylindrical object, as if removing a label from off of the cylinder and flattening it out.
Use the Leadtools.ImageProcessing.Core.UnWarpCommand if the image contains a distortion of a cylindrical object.