LBitmap::DeskewExt

#include "ltwrappr.h"

L_INT LBitmap::DeskewExt(pnAngle, uAngleRange, uAngleResolution, crBack, uFlags)

L_INT32 * pnAngle;

/* rotation angle */

L_UINT uAngleRange;

/* angle range */

L_UINT uAngleResolution;

/* angle resolution */

COLORREF crBack;

/* backgtound color */

L_UINT uFlags;

/* flags */

Rotates the specified bitmap to straighten it. This function typically is used to automatically straighten scanned images.

Parameter

Description

pnAngle

NULL or the address of the variable to be updated with the amount that the function rotates the image. The amount of rotation is expressed in hundredths of degrees. For example, 500 means 5 degrees clockwise. You can pass NULL if you do not need to check the amount of rotation.

uAngleRange

Maximum angle of deskew, in hundredths of degrees. Possible values range from 4500 to 4500. This value is divided internally by 100.

uAngleResolution

Deskew angle precision. The valid range is from 1 to uAngleRange (maximum deskew angle). The real value is divided by 10.

crBack

Color used to fill the background following rotation. This value is used only if DSK_FILL is set in uFlags.

uFlags

Flags that indicate whether or not to deskew the image, which background color to use, whether to deskew the image if the skew angle is very small, which type of interpolation is to be used, and whether the image is mostly text or text and pictures. You can use a bitwise OR (|) to specify one flag from each group.

The following flags indicate whether to deskew the image after the function finds the skew angle:

 

Value

Meaning

 

DSKW_PROCESS

[0x00000000] Deskew (rotate) the image.

 

DSKW_NOPROCESS

[0x00000001] Do not deskew (rotate) the image. Use this flag to find the angle of rotation.

 

The following flags indicate which background color to use to fill areas exposed after rotation:

 

Value

Meaning

 

DSKW_FILL

[0x00000000] Use the color in crBack to fill areas exposed after rotation.

 

DSKW_NOFILL

[0x00000010] Let the function automatically find the suitable background color to fill areas exposed after rotation. Ignore the crBack parameter.

 

The following flags specify whether to deskew the image if the skew angle is very small:

 

Value

Meaning

 

DSKW_NOTHRESHOLD

[0x00000000] Deskew (rotate) the image for any deskew angle value.

 

DSKW_THRESHOLD

[0x00000100] Do not deskew the image if the deskew angle is very small (less than 0.5 degrees).

 

The following flags indicate which type of interpolation to perform:

 

Value

Meaning

 

DSKW_LINEAR

[0x00000000] Do not perform interpolation when rotating.

 

DSKW_RESAMPLE

[0x00001000] Perform bilinear interpolation when rotating.

 

DSKW_BICUBIC

[0x00002000] Perform bicubic interpolation when rotating.

 

The following flags indicate whether the image contains plain text or text and pictures:

 

Value

Meaning

 

DSKW_DOCUMENTIMAGE

[0x00000000] The image contains only text.

 

DSKW_DOCUMENTANDPICTURE

[0x00010000] The image contains text and pictures.

 

DSKW_NORMALSPEEDROTATE

[0x00000000] Rotate at normal speed (high quality).  This is the default value.

 

DSKW_HIGHSPEEDROTATE

[0x00100000] Rotate at high speed (moderate quality, only for 1-bit images)

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Like LBitmap::Deskew, you can use this function to automatically straighten scanned documents. With this function, deskewing has been extended to increase the possible deskew angle (from 20 degrees to 45 degrees in either direction). In addition it adds the capability to forgo deskewing if the deskew angle is very small and to specify the resolution of the rotation step, and adds the capability to specify the type of interpolation to be performed while rotating.

If uFlags contains DSKW_NOPROCESS, the function will update pnAngle with the deskew angle without rotating the image.

Bitmaps can be rotated by as much as 45 degrees in either direction to remove the skew. This function is intended for images, such as scanned documents, that are mainly horizontal lines of text. The results are less predictable with other types of images.

To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

LTIMGCOR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

LBitmap::Despeckle, LBitmap::WindowLevel, LBitmap::ApplyTransformationParameters, LBitmap::GetMarksCenterMass, LBitmap::GetTransformationParameters, LBitmap::IsRegMark, LBitmap::SearchRegMarks, LBitmap::Deskew

Topics:

Raster Image Functions: Doing Geometric Transformations

 

Raster Image Functions: Filtering Images

 

Processing an Image

 

Deskewing

 

Raster Image Functions: Processing an Image

Example

L_INT LBitmap__DeskewExtExample()
{
   L_INT nRet;
   LBitmap LeadBitmap;
   nRet =LeadBitmap.Load(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\IMAGE4.CMP"), 0,ORDER_BGR);
   if(nRet !=SUCCESS)
      return nRet;
   nRet =LeadBitmap.DeskewExt(NULL, 1000, 2, 0, DSKW_PROCESS | DSKW_NOFILL| DSKW_LINEAR| DSKW_DOCUMENTIMAGE);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}