#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_DeskewBitmap(pBitmap, pnAngle, crBack, uFlags)
Rotates the specified bitmap to straighten it. Typically this function is used to automatically straighten scanned images.
This function contains special algorithms for detecting skewed checks. For more information, refer to the Comments section, below.
Pointer to the bitmap handle referencing the bitmap to straighten.
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. Pass NULL if you do not need to check the amount of rotation. Valid values range from -2000 to 2000.
Color used to fill the background following rotation. This is used only if DSK_FILL is set in uFlags
.
Flags that indicate whether or not to deskew the image and what background color to use. You can use a bitwise OR (|) to specify one flag from each group.
Value | Meaning |
---|---|
Deskewing the image after finding the skew angle: | |
DSKW_PROCESS | [0x00000000] Deskew (rotate) the image. |
DSKW_NOPROCESS | [0x00000001] Do not deskew (rotate) the image. Generally this flag is used to find the angle of rotation. |
Background color to use: | |
DSKW_FILL | [0x00000000] Use the color in crBack to fill areas exposed by rotation. |
DSKW_NOFILL | [0x00000010] Let the function automatically find the suitable background color to fill areas exposed by rotation. crBack is ignored in this case. |
Image type: | |
DSKW_DOCUMENTIMAGE | [0x00000000] The image contains text only. |
DSKW_DOCUMENTANDPICTURE | [0x00010000] The image contains text and pictures, or light text. |
Type of interpolation to perform: | |
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. |
Rotation type: | |
DSKW_NORMALSPEEDROTATE | [0x00000000] Rotate the image at normal speed with a high rotation quality. |
DSKW_HIGHSPEEDROTATE | [0x00100000] Speed up image rotation with a moderate rotation quality (only for 1-bit images). |
Perform preprocessing to enhance results: | |
DSKW_PERFORM_PREPROCESSING | [0x00000000] Perform pre-processing operations. Use this with images that contain black borders as a result of scanning in order to enhance accuracy. Works only with 1-bit document images. |
DSKW_DONT_PERFORM_PREPROCESSING | [0x10000000] Do not perform pre-processing operations. |
Detect the skew angle: | |
DSKW_SELECTIVE_DETECTION | [0x00000000] Detect the skew angle selectively using important features of the document, to enhance accuracy. Works only with 1-bit document images. |
DSKW_NORMAL_DETECTION | [0x10000000] Detect the skew angle normally using all the features of the document. |
Perform deskewing using the bank check algorithms: | |
DSKW_DONT_USE_CHECK_DESKEW | [0x00000000] Do not use any of the bank check algorithms. Perform ordinary deskewing. This is the default value. |
DSKW_USE_CHECK_DESKEW | [0x01000000] Use the bank check algorithm to deskew the bitmap. This algorithm considers many features common to standard bank checks in order to determine orientation. |
DSKW_USE_CHECK_DESKEW_DETECT_LINES | [0x02000000] Use the bank check line detection algorithm to deskew the image. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function contains special algorithms for detecting skewed checks. These are specified by using the XX_CHECK_DESKEW_XX flags in the uFlags
parameter.
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.
If uFlags contains DSKW_NOPROCESS, the function will update pnAngle
with the deskew angle, without rotating the image.
The calculated rotation is limited to 20 degrees in either direction. 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 L_SetStatusCallback.
This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.
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
Win32, x64, Linux.
For complete sample code, refer to the CHILD.C module of the DEMO example. This example loads a bitmap and straightens it.
L_INT DeskewBitmapExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/* Deskew the bitmap */
nRet = L_DeskewBitmap(&LeadBitmap, NULL, 0, DSKW_PROCESS | DSKW_NOFILL | DSKW_DOCUMENTIMAGE);
if(nRet !=SUCCESS)
return nRet;
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
if(nRet !=SUCCESS)
return nRet;
//free bitmap
if(LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document