L_DetectBitmapDeskewOrientation

#include "l_bitmap.h"

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

Finds and rotates deskew angle.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap to be deskewed.

pDESKEWDETECTION pDeskewDetection

Pointer to the DESKEWDETECTION structure that handles different deskew angle detection options.

pORIENTATIONDETECTION pOrientationDetection

Pointer to the ORIENTATIONDETECTION structure that handles different orientation angle detection options.

L_UINT uFlags

Has two options to disable deskew or orientation functionalities. Possible values are:

Value Meaning
DSKW_DONT_DETECT_DESKEW_ANGLE [0x00000001] is user needs to detect orientation angle only.
DSKW_DONT_DETECT_ORIENTATION_ANGLE [0x00000002] for detecting deskew angle.

Returns

Value Meaning
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

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

The following example detects the bitmap's deskew angle.

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; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help