BORDERREMOVE

typedef struct tagBORDERREMOVE 
{ 
   L_UINT uStructSize; 
   L_UINT uFlags; 
   L_UINT uBorderToRemove; 
   L_INT iBorderPercent; 
   L_INT iWhiteNoiseLength; 
   L_INT iVariance; 
   L_HRGN hRgn; 
   pBITMAPHANDLE pBitmapRegion; 
   L_UINT uBitmapStructSize; 
} BORDERREMOVE, *pBORDERREMOVE; 

The BORDERREMOVE structure provides border removal information for the L_BorderRemoveBitmap function.

Member Description
uStructSize Size of this structure in bytes, for versioning. Use the sizeof() operator to calculate this value.
uFlags Flags that determine the behavior of the border removal process. Flags may be combined using a bitwise OR (|). Possible values are:
  Value Meaning
  BORDER_SINGLE_REGION For each border encountered by L_BorderRemoveBitmap, if the BORDERREMOVECALLBACK function returns SUCCESS_REMOVE, the removed border is added to an internal single region. If the callback returns SUCCESS_NOREMOVE, the border is not added to the single region. When L_BorderRemoveBitmap returns, either pBitmapRegion or hRgn will reference a region that contains all the removed borders. If BORDER_LEAD_REGION is also set, pBitmapRegion will be updated with a shallow copy of pBitmap that has a LEAD region that contains all the removed borders. If BORDER_LEAD_REGION is not set, hRgn is updated with a Windows region that contains all the removed borders. When the region (either LEAD or Windows) is no longer needed, it must be destroyed (either pBitmapRegion->pRgnInfo or hRgn).
  BORDER_LEAD_REGION When L_BorderRemoveBitmap returns, pBitmapRegion is updated with a shallow copy of pBitmap that also contains a region with all the removed lines. This flag must be used in conjunction with BORDER_SINGLE_REGION. To use this flag declare a variable of type BITMAPHANDLE and point pBitmapRegion to this variable. Then set uFlags to BORDER_SINGLE_REGION | BORDER_LEAD_REGION. This variable will be updated when L_BorderRemoveBitmap returns.
  BORDER_IMAGE_UNCHANGED The original image is unchanged.
  BORDER_CALLBACK_REGION BORDERREMOVECALLBACK receives a Windows region that contains the current line to be removed. Setting this flag lets the user create his or her own composite of removed borders by combining the regions received by the callback function, if the callback function returns SUCCESS_REMOVE. The regions can be combined using a logical OR operator. Combining all regions received when the callback function returns SUCCESS_REMOVE results in a region identical to the region created when BORDER_SINGLE_REGION is set in uFlags. For an example, refer to L_BorderRemoveBitmap. When the region received by the callback function is no longer needed, it must be destroyed using DeleteObject().
BORDER_USE_VARIANCE Consider border variance when performing border removal. If this flag is passed, the iVariance field of the structure is used. If this flag is not passed, the iVariance field of the structure is ignored.
BORDER_SMART_AUTO_REMOVE 0x00001000, Used to automatically remove relatively wide black borders. If this flag is set, all other parameters will be ignored.
uBorderToRemove Flag that indicates which border to remove. These values can be combined using the OR operator (|). Possible values are:
  Value Meaning
  BORDER_LEFT Remove the left border.
  BORDER_RIGHT Remove the right border.
  BORDER_TOP Remove the top border.
  BORDER_BOTTOM Remove the bottom border.
  BORDER_ALL Remove all borders. This is the same as BORDER_LEFT | BORDER_RIGHT | BORDER_TOP | BORDER_BOTTOM.
iBorderPercent Percent of the image dimension in which the border will be found. For most images, use 20. For example, if an image is 200 pixels wide, iBorderPercent is set to 20 and uBorderToRemove is set to BORDER_LEFT, then the left border will be found in the area between the left edge of the image and a line 40 pixels from the left edge. If the border is closer to the edge of the image, use a smaller value. If the border is farther from the edge, use a larger value.
iWhiteNoiseLength Amount of white noise tolerated when determining the border. The units are in pixels. Values of 0 to 10 are sufficient for most images.
iVariance Amount of variance tolerated in the border. If the border varies significantly in thickness, you should use a higher value for iVariance. Range is 0 to 10.
pBitmapRegion Pointer to a variable of type BITMAPHANDLE. If BORDER_SINGLE_REGION | BORDER_LEAD_REGION have been set in uFlags, then when L_BorderRemoveBitmap returns, this is updated with a shallow copy of pBitmap that also has a region that contains the removed borders. To use this, declare a variable of type BITMAPHANDLE and point pBitmapRegion to this variable. Set uFlags to (BORDER_SINGLE_REGION | BORDER_LEAD_REGION). It is the programmer's responsibility to free the region using L_FreeBitmapRgn() when it is no longer needed. Refer to the L_BorderRemoveBitmap example to see how pBitmapRegion is used and freed.
uBitmapStructSize Size of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).
hRgn Handle to a windows region. When L_BorderRemoveBitmap returns, this is updated with a single windows region corresponding to all changes, only if BORDER_SINGLE_REGION has been set in uFlags and BORDER_LEAD_REGION has not been set. To use this, set the flags field to (BORDER_SINGLE_REGION). It is the programmer's responsibility to delete this region using the windows C API DeleteObject() when the region is no longer needed.

Comments

To "fine-tune" the performance of L_BorderRemoveBitmap, try modifying the values for iWhiteNoiseLength, iBorderPercent and iVariance.

Help Version 20.0.2018.7.30
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help