L_DetectBitmapDeskewOrientation

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_DetectBitmapDeskewOrientation(pBitmap, pDeskewDetection, pOrientationDetection, uFlags)

pBITMAPHANDLE pBitmap; pointer to the bitmap
pDESKEWDETECTION pDeskewDetection; pointer to a structure
pORIENTATIONDETECTION pOrientationDetection; pointer to a structure
L_UINT32 uFlags; flags

Finds and rotates deskew angle.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap to be deskewed.
pDeskewDetection Pointer to the DESKEWDETECTION structure that handles different deskew angle detection options.
pOrientationDetection Pointer to the ORIENTATIONDETECTION structure that handles different orientation angle detection options.
uFlags Has two options to disable deskew or orientation functionalities, DSKW_DONT_DETECT_DESKEW_ANGLE [0x00000001] is user needs to detect orientation angle only and DSKW_DONT_DETECT_ORIENTATION_ANGLE [0x00000002] for detecting deskew angle.

Returns

SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function supports detecting deskew and orientation angle.

This function contains special algorithms for detecting skewed checks. These are specified by using the XX_CHECK_DESKEW_XX flags in the pDeskewDetection 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 variable in pDeskewDetection structure contains DSKW_NOPROCESS, the function will update nAngle variable in pDeskewDetection structure with the deskew angle, without rotating the image.

If uFlags variable in pOrientationDetection structure contains ORNT_NOPROCESS, the function will update nOrientationAngle variable in pOrientationDetection structure with the orientation 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.

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

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, Linux.

See Also
Functions: DOTREMOVECALLBACK, L_SmoothBitmap, L_LineRemoveBitmap, L_AutoLineRemove, L_InvertedTextBitmap, L_BorderRemoveBitmap, L_HolePunchRemoveBitmap, L_HolesRemovalBitmapRgn, L_AutoBinarizeBitmap, L_DynamicBinaryBitmap, L_AutoBinaryBitmap, L_InvertedPageBitmap
Topics: Cleaning Up 1-Bit Images

Example

The following example detects the bitmap's deskew angle.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
#if !defined (LEADTOOLS_V17_OR_LATER) 
L_INT DetectBitmapDeskewExample(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("clean.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   // Change bitmap orientation 
   nRet = L_RotateBitmap( &LeadBitmap, 9000, 0, RGB(255,255,255)); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   // Detect and correct deskew and orientation angle the bitmap 
   DESKEWDETECTION DeskewDetection ; 
   DeskewDetection.uStructSize = sizeof(DESKEWDETECTION); 
   DeskewDetection.uFlags = DSKW_PROCESS | DSKW_NOFILL| DSKW_LINEAR| DSKW_DOCUMENTIMAGE ; 
 
   ORIENTATIONDETECTION OrientationDetection ; 
   OrientationDetection.uStructSize = sizeof(ORIENTATIONDETECTION); 
   OrientationDetection.uFlags = 0 ; // The default is processing bitmap orientation 
 
   L_UINT uFlags = 0 ; // The default is detecting deskew and orientation angles 
 
   nRet = L_DetectBitmapDeskewOrientation( &LeadBitmap, &DeskewDetection, &OrientationDetection, uFlags); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   // Free Bitmap 
   L_FreeBitmap(&LeadBitmap); 
   return SUCCESS; 
} 
#endif 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help