Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILImageThreshold Interface Reference

This interface provide functionalities of threshold operations. More...

Inheritance diagram for ILImageThreshold:
ILObject LImageThreshold

Public Member Functions

void Binarize (ILImage *img, ILImage *result)
 
void Clip (ILImage *img, ILImage *result)
 
void SetThreshold (int lb, int ub)
 
void SetThresholdAdaptGlobal (int lbBias, int ubBias)
 
void SetThresholdAdaptLocal (int blockWidth, int blockHeight, int lbBias, int ubBias)
 
void Stretch (ILImage *img, ILImage *result)
 
void ThresholdDistance (ILImage *img, ILImage *result)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

int LocalBlockHeight [get]
 The height of the local region used in local adaptive thresholding. More...
 
int LocalBlockWidth [get]
 The width of the local region used in local adaptive thresholding. More...
 
int ThresholdLB [get]
 The lower bound of used-specified threshold value. More...
 
int ThresholdLBBias [get]
 The revised value to generate a adaptive threshold lower bound. More...
 
LPVThresholdType ThresholdType [get]
 The thresholding method. More...
 
int ThresholdUB [get]
 The upper bound of used-specified threshold value. More...
 
int ThresholdUBBias [get]
 The revised value to generate a adaptive threshold upper bound. More...
 

Detailed Description

This interface provide functionalities of threshold operations.

Thresholding is a classic segmentation method to separate out regions of an image corresponding to objects which we want to analyze. This separation is based on the variation of intensity between the object and the background pixels. To differentiate the pixels, we perform a comparison of each pixel intensity value with respect to a threshold value (which is user-specified or determined by adaptive method)

To use this interface, you should create a LImageThreshold object.

Example Code

Member Function Documentation

◆ Binarize()

void Binarize ( ILImage img,
ILImage result 
)

Binarize the input image and return the result new image.
If the lower bound of threshold value is smaller than the upper bound, pixels within the lower and upper bound of threshold value is set to the object level (maximum value, 255 for 8bit images, 65536 for 16bit images), otherwise, the output pixel is set to the background level (0).
If the lower bound of threshold value is greater than the upper bound, the output result is inverted.

Parameters
[in]img The input image
[out]result Return result image

◆ Clip()

void Clip ( ILImage img,
ILImage result 
)

Pixels within the lower and upper bound of threshold value is assigned the value of the input pixel, otherwise, is assigned to the value of lower or upper bound.
For example, if the threshold lower bound is 100, upper bound is 200, a pixel of 150 value remains 150, a pixel of 230 outputs 200, a pixel of 50 outputs 100.

Parameters
[in]img The input image
[out]result Return result image

◆ SetThreshold()

void SetThreshold ( int  lb,
int  ub 
)

Use user-specified threshold value

Parameters
[in]lbThe lower bound of threshold range, in range of 0 ~ 255 for 8bit images, 0 ~ 65535 for 16bit images
[in]ubThe upper bound of threshold range, in range of 0 ~ 255 for 8bit images, 0 ~ 65535 for 16bit images

◆ SetThresholdAdaptGlobal()

void SetThresholdAdaptGlobal ( int  lbBias,
int  ubBias 
)

Use global-adaptive threshold value.
The optimal threshold value is calculated base on the entire input image, then revised by the given bias value. The lower bound of threshold value is @math_eq{t - lbBias} , the upper bound is @math_eq{t + ubBias} .

Parameters
[in]lbBiasRevise value to optimal threshold value, to generate a threshold lower bound.
[in]ubBiasRevise value to optimal threshold value, to generate a threshold upper bound.

◆ SetThresholdAdaptLocal()

void SetThresholdAdaptLocal ( int  blockWidth,
int  blockHeight,
int  lbBias,
int  ubBias 
)

Use local-adaptive threshold value.
The optimal threshold value is calculated base on a @math_eq{blockWidth \times blockHeight} region around individual pixel, then revised by the given bias value. The lower bound of threshold value is @math_eq{t - lbBias} , the upper bound is @math_eq{t + ubBias} .

Parameters
[in]blockWidthThe width of a pixel's local region, should be an odd number, say, 3, 5, 7, etc.
[in]blockHeightThe height of a pixel's local region, should be an odd number, say, 3, 5, 7, etc.
[in]lbBiasRevise value to optimal threshold value, to generate a threshold lower bound.
[in]ubBiasRevise value to optimal threshold value, to generate a threshold upper bound.

◆ Stretch()

void Stretch ( ILImage img,
ILImage result 
)

Stretch the pixel value within the lower and upper bound of threshold value, others is assigned to 0 or maximum value respectively.
For example for a 8bit image, if the threshold lower bound is 100, upper bound is 200, pixel is assigned to 0 if its input value is within range [0, 100], it's assigned to 255 if within range [200, 255], for the range [101, 199] it's assigned as:

\[ (p - 100) \times 255 / (200 - 100) \]

Parameters
[in]img The input image
[out]result Return result image

◆ ThresholdDistance()

void ThresholdDistance ( ILImage img,
ILImage result 
)

Each output pixel represents the difference between the greyscale value of each input pixel and the threshold lower bound.
For example, if a pixel value is 100 and the threshold lower bound is 25, then the output pixel value will be 75。

Parameters
[in]img The input image
[out]result Return result image

Property Documentation

◆ LocalBlockHeight

int LocalBlockHeight
get

The height of the local region used in local adaptive thresholding.

See also
SetThresholdAdaptLocal()

◆ LocalBlockWidth

int LocalBlockWidth
get

The width of the local region used in local adaptive thresholding.

See also
SetThresholdAdaptLocal()

◆ ThresholdLB

int ThresholdLB
get

The lower bound of used-specified threshold value.

See also
SetThreshold()

◆ ThresholdLBBias

int ThresholdLBBias
get

The revised value to generate a adaptive threshold lower bound.

See also
SetThresholdAdaptGlobal(), SetThresholdAdaptLocal()

◆ ThresholdType

LPVThresholdType ThresholdType
get

◆ ThresholdUB

int ThresholdUB
get

The upper bound of used-specified threshold value.

See also
SetThreshold()

◆ ThresholdUBBias

int ThresholdUBBias
get

The revised value to generate a adaptive threshold upper bound.

See also
SetThresholdAdaptGlobal(), SetThresholdAdaptLocal()