L_RakeRemoveBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT EXT_FUNCTION L_RakeRemoveBitmap(pBitmap, bAuto, pComb, pDstRect, nRectCount, pCallback, pUserData, uFlags)

Removes the isolated data rakes from 1-bit black and white images.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that references the bitmap on which to perform rake removal.

L_BOOL bAuto

Flag that indicates whether to automate the rakes removal. Possible values are:

Value Meaning
TRUE Automate the rakes removal.
FALSE Do not automate the rakes removal.

pRAKEREMOVE pComb

Pointer to the RAKEREMOVE structure that LEADTOOLS uses to perform the rake removal operation.

RECT * pDstRect

Pointer to an array of Windows RECT structure specifying the areas where the rakes are in the image. If NULL is passed, the function will look for rakes in the entire image.

L_INT nRectCount

Number of rectangles specified which equals to the number of rakes in an image or more if one rectangle contains more than one rake. If NULL is passed for the pDstRect parameter, this parameter should be passed as 0.

RAKEREMOVECALLBACK pCallback

Optional callback function for additional processing.

If you do not provide a callback function, use NULL as the value of this parameter.

If you do provide a callback function, use the function pointer as the value of this parameter.

The callback function must adhere to the function prototype described in RAKEREMOVECALLBACK function.

L_VOID * pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

If the additional parameters are not needed, you can pass NULL in this parameter.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

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

Comments

A rake is a horizontal line with vertical partitioning lines pointing upward attached to it. Rakes are used to contain data (digits or characters) filled individually and separated by the spaces created by the partitioning vertical lines.

A typical rake looks like the following:

image\L_RakeRemoveBitmap.gif

(Document) This function removes data rakes from scanned text documents. If the rakes pass through text, the pRake parameter can be configured to remove or preserve the text. The behavior of this function can be further modified by using its callback.

If a region is selected, only the selected region will be changed. If no region is selected, the whole image will be processed.

For rake structures that are inside or part of tables, the user can select the rake structure and the rake structure only- via region (preferably a rectangular region) and call the function on that region.

This function works only on 1-bit black and white images.

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.

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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example loads a bitmap and applies the Rake Removal with specific rectangle areas on it then the Callback
function prints the length of each comb found

L_INT EXT_CALLBACK RakeRemoveExampleCB( L_HRGN     hRgn, L_INT    Length, L_VOID* pUserData) 
{ 
   UNREFERENCED_PARAMETER(hRgn); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   L_TCHAR szMsg[200]; 
 
   wsprintf(szMsg, TEXT("Length of Rake =  %d"), Length); 
 
   MessageBox(NULL, szMsg, TEXT(""), MB_OK); 
 
   return SUCCESS_NOREMOVE; 
} 
 
L_INT RakeRemoveExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap; /*Bitmap handle to hold the loaded image*/ 
   RECT rect[2] ;      /*Rectangle to specify area on Bitmap*/	       
   RAKEREMOVE Rake;        /*Rake structure*/ 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("Forms\\Forms to be Recognized\\OCR\\FCC-107_OCR_Filled.tif")),  
      &LeadBitmap, sizeof(BITMAPHANDLE), 0, 
      ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   //Specify rectangle parameters  
  rect[0].left = 30; 
  rect[0].top = 30; 
  rect[0].bottom = 60; 
  rect[0].right = 60; 
  rect[1].left = 70; 
  rect[1].top = 70; 
  rect[1].bottom = 100; 
  rect[1].right = 100; 
    
  //specifying comb structure parameters 
  Rake.nMaxMidteethLength = 50; 
  Rake.nMaxSideteethLength = 60; 
  Rake.nMaxWallPercent = 25; 
  Rake.nMaxWidth = 3; 
  Rake.nMinLength = 50; 
  Rake.nMinWallHeight = 10; 
  Rake.nTeethSpacing = 5; 
  Rake.nVariance = 1; 
  Rake.nGaps = 1; 
 
   //Apply the RakeRemove function 
   nRet = L_RakeRemoveBitmap(&LeadBitmap,TRUE, &Rake,rect, 2, RakeRemoveExampleCB,NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
    
   /* Free the region */ 
   L_FreeBitmapRgn(&LeadBitmap); 
   /* Free the bitmap */ 
   L_FreeBitmap(&LeadBitmap); 
 
   return SUCCESS; 
} 

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

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