L_LineRemoveBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_LineRemoveBitmap(pBitmap, pLineRemove, pfnCallback, pUserData, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap */

pLINEREMOVE pLineRemove;

/* pointer to a structure */

LINEREMOVECALLBACK pfnCallback;

/* optional callback function */

L_VOID* pUserData;

/* pointer to more parameters for the callback */

L_UINT32 uFlags;

/* flags*/

Removes horizontal and vertical lines in a 1-bit black and white image.

This function is available in the Document and Medical Imaging toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap on which to perform line removal.

pLineRemove

Pointer to the LINEREMOVE structure that LEADTOOLS uses to perform the line removal operation.

pfnCallback

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 LINEREMOVECALLBACK Function.

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.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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.

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

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

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

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

Windows 2000 / XP/Vista.

See Also

Functions:

LINEREMOVECALLBACK, L_SmoothBitmap, L_BorderRemoveBitmap, L_InvertedTextBitmap, L_DotRemoveBitmap, L_HolePunchRemoveBitmap, L_BlankPageDetectorBitmap, L_AutoBinarizeBitmap, L_DynamicBinaryBitmap, L_AutoBinaryBitmap, L_InvertedPageBitmap

Topics:

Cleaning Up 1-Bit Images

Example

This examples removes vertical lines that are at least 200 pixels in length and no more than 5 pixels in width. The lines can have gaps up to two pixels in length. A callback is used to display information about each line removed. The callback does NOT return a region.

#if defined (LEADTOOLS_V16_OR_LATER)
L_INT  EXT_CALLBACK ExampleLineRemoveCB( HRGN hRgn, L_INT32 iStartRow, L_INT32 iStartCol, L_INT32 iLength, L_VOID *pUserData )
{
   UNREFERENCED_PARAMETER(pUserData); 

   L_TCHAR szMsg[200];
   RECT rcRect;

   GetRgnBox(hRgn, &rcRect);
   wsprintf(
      szMsg, 
      TEXT("Region Bounds: left=%d, right=%d, top=%d, bottom=%d \n"),
      rcRect.left, rcRect.right, rcRect.top, rcRect.bottom);
   OutputDebugString(szMsg);
   DeleteObject(hRgn);

   wsprintf(
      szMsg, 
      TEXT("RowCol[%d,%d] Length[%d]\n"),
      iStartRow,
      iStartCol,
      iLength
      );
   OutputDebugString(szMsg);
   return SUCCESS_REMOVE; 
}

 L_INT  LineRemoveBitmapExample(pBITMAPHANDLE pBitmap)
{
   L_INT32           nRet;
   LINEREMOVE        lr;
   BITMAPHANDLE      RegionBitmap;

   memset(&RegionBitmap, 0, sizeof(BITMAPHANDLE));

   lr.uStructSize = sizeof(LINEREMOVE);
   lr.iGapLength     = 3;
   lr.iMaxLineWidth  = 9;
   lr.iMinLineLength = 400;
   lr.iWall          = 15;
   lr.iMaxWallPercent = 10;
   lr.iVariance       = 3;
   lr.uRemoveFlags   = LINEREMOVE_HORIZONTAL;
   lr.uFlags         = LINE_USE_GAP | LINE_CALLBACK_REGION;
   lr.uBitmapStructSize = sizeof(BITMAPHANDLE);
   lr.pBitmapRegion = &RegionBitmap;

   nRet = L_LineRemoveBitmap( pBitmap, 
                              &lr,
                              ExampleLineRemoveCB, 
                              NULL                              
                              , 0);
   if(nRet != SUCCESS )
      return nRet;

   return SUCCESS;
}
#else
L_INT  EXT_CALLBACK ExampleLineRemoveCB( HRGN hRgn, L_INT32 iStartRow, L_INT32 iStartCol, L_INT32 iLength, L_VOID *pUserData )
{
   UNREFERENCED_PARAMETER(pUserData); 

   L_TCHAR szMsg[200];
   RECT rcRect;

   GetRgnBox(hRgn, &rcRect);
   wsprintf(
      szMsg, 
      TEXT("Region Bounds: left=%d, right=%d, top=%d, bottom=%d \n"),
      rcRect.left, rcRect.right, rcRect.top, rcRect.bottom);
   OutputDebugString(szMsg);
   DeleteObject(hRgn);

   wsprintf(
      szMsg, 
      TEXT("RowCol[%d,%d] Length[%d]\n"),
      iStartRow,
      iStartCol,
      iLength
      );
   OutputDebugString(szMsg);
   return SUCCESS_REMOVE; 
}

 L_INT  LineRemoveBitmapExample(pBITMAPHANDLE pBitmap)
{
   L_INT32           nRet;
   LINEREMOVE        lr;
   BITMAPHANDLE      RegionBitmap;

   memset(&RegionBitmap, 0, sizeof(BITMAPHANDLE));

   lr.uStructSize = sizeof(LINEREMOVE);
   lr.iGapLength     = 3;
   lr.iMaxLineWidth  = 9;
   lr.iMinLineLength = 400;
   lr.iWall          = 15;
   lr.iMaxWallPercent = 10;
   lr.iVariance       = 3;
   lr.uRemoveFlags   = LINEREMOVE_HORIZONTAL;
   lr.uFlags         = LINE_USE_GAP | LINE_CALLBACK_REGION;
   lr.uBitmapStructSize = sizeof(BITMAPHANDLE);
   lr.pBitmapRegion = &RegionBitmap;

   nRet = L_LineRemoveBitmap( pBitmap, 
                              &lr,
                              ExampleLineRemoveCB, 
                              NULL                              
                              );
   if(nRet != SUCCESS )
      return nRet;

   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER