BORDERREMOVE

Summary

The BORDERREMOVE structure provides border removal information.

Syntax

typedef struct _BORDERREMOVE 
{ 
   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; 

Members

uStructSize

Size of this structure in bytes. 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 LBitmap::BorderRemove, if the LBitmap::BorderRemoveCallback callback member function returns SUCCESS_REMOVE, the removed border is added to an internal single region. If the callback member function returns SUCCESS_NOREMOVE, the border is not added to the single region. When LBitmap::BorderRemove 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 LBitmap::BorderRemove 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 LBitmap::BorderRemove returns.
BORDER_IMAGE_UNCHANGED The original image is unchanged.
BORDER_CALLBACK_REGION LBitmap::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 member function, if the callback member function returns SUCCESS_REMOVE. The regions can be combined using a logical OR operator. Combining all regions received when the callback member function returns SUCCESS_REMOVE results in a 4region identical to the region created when BORDER_SINGLE_REGION is set in uFlags. For an example, refer to LBitmap::BorderRemove. When the region received by the callback member 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.
BORDER_ALLFLAGS Use all behaviors of the border removal process.

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 LBitmap::BorderRemove 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 LBitmapRgn::Free when it is no longer needed. Refer to the LBitmap::BorderRemove example to see how pBitmapRegion is used and freed.

uBitmapStructSize

Size of the structure pointed to by pBitmap. Use sizeof(BITMAPHANDLE).

hRgn

Handle to a windows region. When LBitmap::BorderRemove 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 API DeleteObject() when the region is no longer needed.

Comments

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

Usage

Data Types

Functions

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++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.