LINEREMOVE

typedef struct _LINEREMOVE 
{ 
   L_UINT uStructSize; 
   L_UINT uFlags; 
   L_INT iMinLineLength; 
   L_INT iMaxLineWidth; 
   L_INT iWall; 
   L_INT iMaxWallPercent; 
   L_INT iGapLength; 
   L_INT iVariance; 
   L_UINT uRemoveFlags; 
   L_HRGN hRgn; 
   pBITMAPHANDLE pBitmapRegion; 
   L_UINT uBitmapStructSize; 
} LINEREMOVE, *pLINEREMOVE; 

The LINEREMOVE structure provides line removal information for the LBitmap::LineRemove function.

Member

Description

uStructSize

Size of this structure in bytes. Use the sizeof() macro to calculate this value.

uFlags

Flags that determine the behavior of the line removal process. Flags may be combined using a bitwise OR (|). Possible values are:

 

Value

Meaning

 

LINE_SINGLE_REGION

For each line encountered by LBitmap::LineRemove, if the LBitmap::LineRemoveCallback callback member function returns SUCCESS_REMOVE, the removed line is added to an internal single region. If the callback member function returns SUCCESS_NOREMOVE, the line is not added to the single region. When LBitmap::LineRemove returns, either pBitmapRegion or hRgn will reference a region that contains all the removed lines. If LINE_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 lines. If LINE_LEAD_REGION is not set, hRgn is updated with a Windows region that contains all the removed lines. When the region (either LEAD or Windows) is no longer needed, it must be destroyed (either pBitmapRegion->pRgnInfo or hRgn).

 

LINE_LEAD_REGION

When LBitmap::LineRemove 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 LINE_SINGLE_REGION. To use this flag declare a variable of type BITMAPHANDLE and point pBitmapRegion to this variable. Then set uFlags to LINE_SINGLE_REGION | LINE_LEAD_REGION. This variable will be updated when LBitmap::LineRemove returns.

 

LINE_IMAGE_UNCHANGED

The original image is unchanged.

 

LINE_USE_DPI

The unit of measure for all fields of the LINEREMOVE structure is thousandths of an inch. Use the image's DPI to convert to pixels. This allows the processing of many images with different DPI. If this flag is not set, the unit of measure for all fields of the LINEREMOVE structure is pixels.

 

LINE_CALLBACK_REGION

LBitmap::LineRemoveCallback 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 lines 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 region identical to the region created when LINE_SINGLE_REGION is set in uFlags. For an example, refer to LBitmap::LineRemove. When the region received by the callback member function is no longer needed, it must be destroyed using DeleteObject().

 

LINE_REMOVE_ENTIRE

Remove the entire line, even if the line passes through a character or a wall.

 

Consider the line below.

 

 

image\Wall1.gif

 

 

 

Setting iMaxWallPercent as 80 and passing LINE_REMOVE_ENTIRE will remove the red pixels as shown below.

 

image\Wall3.gif

 

 

LINE_USE_GAP

Consider "gaps" in lines when performing line removal. If this flag is passed, the iGapLength field of the LINEREMOVE structure is used. If this flag is not passed, the iGapLength field is ignored.

 

LINE_USE_VARIANCE

Consider line variance when performing line removal. If this flag is passed, the iLineVariance field of the structure is used. If this flag is not passed, the iLineVariance field of the structure is ignored.

 

LINE_ALLFLAGS

Use all behaviors of the line removal process.

iMinLineLength

Minimum length of a line considered for removal. Lines less than this length are not removed. If LINE_USE_DPI is set in uFlags, units are in thousandths of an inch, otherwise units are in pixels.

iMaxLineWidth

Maximum average width of a line that is considered for removal. Lines that are greater in average width are not removed. If LINE_USE_DPI is set in uFlags, units are in thousandths of an inch, otherwise units are in pixels.

iWall

Height of a wall. Walls are slices of a line that are too wide to be considered part of the line. Examples of walls include a character that a line passes through or a perpendicular line. If the image contains lines that pass through characters, set iWall to be equal to or a little larger than iMaxLineWidth. If LINE_USE_DPI is set in uFlags, units are in thousandths of an inch, otherwise units are in pixels.

iMaxWallPercent

The maximum number of wall slices (expressed as a percent of the total length of the line) that are allowed. A line consists of wall slices and non-wall slices (see description of iWall). This field specifies that maximum number of wall slices (expressed as a percent of the total length of the line) that are allowed. Lines that have a wall percent that is larger than iMaxWallPercent will not be removed. For example, consider the line below that is 10 pixels in length, and 1 pixel in height in some places, and five pixels in height in other places.

 

image\Wall1.gif

 

Setting iMinLineLength to 10 pixels and iWall to four pixels will identify the line below as a candidate for removal. Note that the wall percent for this line is 60% (because six of ten line slices are walls). If iMaxWallPercent is 80 then the line will be removed (actually, the pixels marked as red will be removed). If iMaxWallPercent is 30, then the line will not be removed.

 

image\Wall2.gif

iGapLength

Maximum length of a break or a hole in a line. This can be used to remove dotted lines, dashed lines, or lines that have breaks due to scanning. If LINE_USE_DPI is set in uFlags, units are in thousandths of an inch, otherwise units are in pixels. This member is valid only if LINE_USE_GAP is set in uFlags.

iVariance

Amount of width change that is tolerated between adjacent line slices. If LINE_USE_DPI is set in uFlags, units are in thousandths of an inch, otherwise units are in pixels. This member is valid only if LINE_USE_VARIANCE is set in uFlags. For example, the following horizontal line is 30 pixels in length (X represents a pixel)

 

XXXXXXXXXX

 

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

XXXXXXXXXX

 

XXXXXXXXXX

 

If iLineVariance is 2 pixels (i.e. tolerate width changes of 2 pixels or less), the first 10 columns and the last 10 columns of the line will be removed. The middle 10 columns will be unchanged. This helps preserve characters that intersect a line that is being removed.

uRemoveFlags

Flag that indicates which lines to remove. Possible values are:

 

Value

Meaning

 

LINEREMOVE_HORIZONTAL

remove horizontal lines

 

LINEREMOVE_VERTICAL

remove vertical lines

pBitmapRegion

Pointer to a variable of type BITMAPHANDLE. If LINE_SINGLE_REGION | LINE_LEAD_REGION have been set in uFlags, then when LBitmap::LineRemove returns, this is updated with a shallow copy of pBitmap that also has a region that contains the removed lines. To use this, declare a variable of type BITMAPHANDLE and point pBitmapRegion to this variable. Set uFlags to (LINE_SINGLE_REGION | LINE_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::LineRemove example to see how pBitmapRegion is used and freed.

uBitmapStructSize

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

hRgn

Handle to a windows region. When LBitmap::LineRemove returns, this is updated with a single windows region corresponding to all changes, only if LINE_SINGLE_REGION has been set in uFlags and LINE_LEAD_REGION has not been set. To use this, set the flags field to (LINE_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::LineRemove, try modifying the values for iWall, iGapLength and iVariance.

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C++ Class Library Help