Is this page helpful?

In this page

L_AutoPageSplitter

Summary

Automatically splits document images that have two pages inside it.

Syntax

#include "Ltimgcor.h"

L_LTIMGCOR_API L_INT L_AutoPageSplitter(pBitmap, pOutBitmap, SplittingCoord)

Parameters

pBITMAPHANDLE pBitmap

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

pBITMAPHANDLE pOutBitmap

Pointer to a BITMAPHANDLE[2] array. The first element will be filled with the left page, and the second element with the right page.

L_UINT* SplittingCoord

Pointer to a L_UINT variable that will be filled with the column number of the splitting point.

Returns

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

Comments

Finds and splits a two-page document that has its pages horizontally side-by-side.

The two new bitmaps have the same dimensions as the original.

The new bitmaps are returned as 1-bit bitmaps.

This function can only process entire images. It does not support regions.

This function supports 24- and 36-bit color images and 8-bit grayscale images.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a two pages bitmap and applies the following filter to enhance document quality :-
1- Remove border
2- Split pages in bitmap
3- Expand the content of the page

Copied to clipboard
L_INT AutoPageSplitterExample(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("ScannedBook.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 1, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   BORDERREMOVE br; 
 
   br.uStructSize = sizeof(BORDERREMOVE); 
   br.iBorderPercent = 20; 
   br.iVariance = 2; 
   br.iWhiteNoiseLength = 5; 
   br.uBorderToRemove = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT; 
   br.uFlags = BORDER_CALLBACK_REGION | BORDER_USE_VARIANCE; 
   br.pBitmapRegion = &LeadBitmap; 
   br.uBitmapStructSize = sizeof(BITMAPHANDLE); 
 
   /* Apply border remove filter to clean up black borders*/ 
   nRet = L_BorderRemoveBitmap(&LeadBitmap, &br, NULL, NULL, 0); 
   if (nRet != SUCCESS) 
   { 
      if (LeadBitmap.Flags.Allocated) 
         L_FreeBitmap(&LeadBitmap); 
 
      return nRet; 
   } 
 
   /* Apply Page splitter*/ 
   BITMAPHANDLE OutBitmap[2]; 
   OutBitmap[0].Flags.Allocated = 0; 
   OutBitmap[1].Flags.Allocated = 0; 
   L_UINT SplitterCoordinates = 0; 
 
   nRet = L_AutoPageSplitter(&LeadBitmap, OutBitmap, &SplitterCoordinates); 
   if (nRet != SUCCESS) 
   { 
      if (LeadBitmap.Flags.Allocated) 
         L_FreeBitmap(&LeadBitmap); 
 
      return nRet; 
   } 
 
   nRet = L_ExpandPage(&(OutBitmap[0])); 
   if (nRet == SUCCESS) 
      nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result_BorderRemove.BMP")), &(OutBitmap[0]), FILE_BMP, 24, 0, NULL); 
 
   if (OutBitmap[0].Flags.Allocated) 
      L_FreeBitmap(&OutBitmap[0]); 
 
   if (OutBitmap[1].Flags.Allocated) 
      L_FreeBitmap(&OutBitmap[1]); 
 
   if (LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
 
   return nRet; 
} 

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

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.