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

This interface provide functionalities of blob analysis. More...

Inheritance diagram for ILBlobAnalysis:
ILObject LBlobAnalysis

Public Member Functions

void AddBackgroundRange (int grayLB, int grayUB)
 
void AddBackgroundRangeColor (LColor colorLB, struct LColor colorUB)
 
void AddBlobFilter (ILBlobFilter *filter)
 
void AddBlobRange (int grayLB, int grayUB)
 
void AddBlobRangeColor (LColor colorLB, struct LColor colorUB)
 
LPVErrorCode Build (ILImage *img, ILRegion *region, ILBlobResults **results)
 
int CountBackgroundRange ()
 
int CountBackgroundRangeColor ()
 
int CountBlobFilter ()
 
int CountBlobRange ()
 
int CountBlobRangeColor ()
 
void ItemBackgroundRange (int index, int *grayLB, int *grayUB)
 
void ItemBackgroundRangeColor (int index, LColor *colorLB, struct LColor *colorUB)
 
ILBlobFilterItemBlobFilter (int index)
 
void ItemBlobRange (int index, int *grayLB, int *grayUB)
 
void ItemBlobRangeColor (int index, LColor *colorLB, struct LColor *colorUB)
 
void Preview (ILImage *img, ILImage *outputImg)
 
void ResetBackgroundRange ()
 
void ResetBackgroundRangeColor ()
 
void ResetBlobFilter ()
 
void ResetBlobRange ()
 
void ResetBlobRangeColor ()
 
void SelectRangeAuto (ILImage *image, int x, int y, double zoomX, double zoomY, double panX, double panY, int tolerance, int *grayLB, int *grayUB, ILImage *rangeMask)
 
void SelectRangeAutoColor (ILImage *image, int x, int y, double zoomX, double zoomY, double panX, double panY, int tolerance, LColor *colorLB, struct LColor *colorUB, ILImage *rangeMask)
 
void SetRangeThresholdAdaptGlobal (LPVPolarity blobPolarity)
 
void SetRangeThresholdAdaptLocal (LPVPolarity blobPolarity, int blockSize, int bias)
 
void SetSoftThresholdRange (int softRange)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

LPVPolarity AdaptBlobPolarity [get]
 The blob's polarity defined for the global or local adaptive thresholding in segmentation. More...
 
LPVImageFormat ColorMode [get, set]
 The mode of the blob analysis tool, either handling grayscale or color image.
 
LPVBlobContourType ContourType [get, set]
 The type of the result blob contours, see LPVBlobContourType. More...
 
BOOL EnableMerge [get, set]
 Whether to enable blob merging.
 
LPVExcludeBoundaryMode ExcludeBoundaryMode [get, set]
 The mode how to handle blobs that intersect the region boundary (exclude the entire blob, exclude only those outset pixels, or do nothing), see LPVExcludeBoundaryMode.
 
BOOL FillHole [get, set]
 Whether to enable the contribution of holes in the overall blob statistics. By default, it's off.
 
int Hierarchy [get, set]
 The hierarchy of the result blob contours. It's 0-based, negative value means all hierarchies. More...
 
int LocalBias [get]
 The revised value to generate a local adaptive threshold. More...
 
int LocalBlockSize [get]
 The size of the local region used in local adaptive thresholding. More...
 
int MaxCount [get, set]
 The maximum of blobs to find. If there are more than the setting counts of blobs in the detect region, sort the candidates then pick the tops. More...
 
int MergeAreaLB [get, set]
 The minimum acceptable area for the merged blobs. Area is the optional filtering property for the merged results and is not used to control the merging process. To constrain the size of the merged result, you should set the merge size bounds: MergeWidthLB, MergeWidthUB, MergeHeightLB, MergeHeightUB.
 
int MergeAreaUB [get, set]
 The maximum acceptable area for the merged blobs.
 
int MergeHeightLB [get, set]
 The minimum acceptable height (length of shorter axis) for the merged blobs.
 
int MergeHeightUB [get, set]
 The maximum acceptable height (length of shorter axis) for the merged blobs.
 
LPVBlobMergeType MergeType [get, set]
 The way to do the blob merging.
 
int MergeWidthLB [get, set]
 The minimum acceptable width (length of longer axis) for the merged blobs.
 
int MergeWidthUB [get, set]
 The maximum acceptable width (length of longer axis) for the merged blobs.
 
LPVBlobFeatures SortBy [get, set]
 The method used to sort all blob candidates, the top ones are reported as final results. More...
 
BOOL SortByDescending [get, set]
 Works together with SortBy. True to sort all blob candidates descending(from large value to small), false for sorting in ascending order. More...
 
LPVThresholdType ThresholdType [get]
 The thresholding method used in segmentation. More...
 

Detailed Description

This interface provide functionalities of blob analysis.

Blob analysis is a useful approach to segment object from background into connected components of similar grayscale values. Various geometric features, such as area, perimeter or circularity, can be computed on these blobs. In addition, image-related features, such as average luminance or contrast, can be computed based on the image attached.

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

Example Code

Member Function Documentation

◆ AddBackgroundRange()

void AddBackgroundRange ( int  grayLB,
int  grayUB 
)

Add grayscale value range for background. Pixels in this range will be treated as background.
It indicates this is a grayscale-mode blob analysis tool, all the previous color range setting will be cleaned up.

Parameters
[in]grayLBThe lower bound of the grayscale value range in 0 ~ 255.
[in]grayUBThe upper bound of the grayscale value range in 0 ~ 255.
See also
AddBackgroundRangeColor(), AddBlobRange(), SelectRangeAuto().

◆ AddBackgroundRangeColor()

void AddBackgroundRangeColor ( LColor  colorLB,
struct LColor  colorUB 
)

Add color value range for background. Pixels in this range will be treated as background.
It indicates this is a color-mode blob analysis tool, all the previous grayscale range setting will be cleaned up.

Parameters
[in]colorLBThe lower bound of the color value range. It's in the same channel order and color space as the source image.
[in]colorUBThe upper bound of the color value range. It's in the same channel order and color space as the source image.
See also
AddBackgroundRange(), AddBlobRangeColor(), SelectRangeAutoColor().

◆ AddBlobFilter()

void AddBlobFilter ( ILBlobFilter filter)

Add an alternative blob filter.

Parameters
[in]filterThe new blob filter

◆ AddBlobRange()

void AddBlobRange ( int  grayLB,
int  grayUB 
)

Add grayscale value range for blob objects. Pixels in this range will be treated as foreground, and connected to be blobs.
It indicates this is a grayscale-mode blob analysis tool, all the previous color range setting will be cleaned up.

Parameters
[in]grayLBThe lower bound of the grayscale value range in 0 ~ 255.
[in]grayUBThe upper bound of the grayscale value range in 0 ~ 255.
See also
AddBlobRangeColor(), AddBackgroundRange(), SelectRangeAuto().

◆ AddBlobRangeColor()

void AddBlobRangeColor ( LColor  colorLB,
struct LColor  colorUB 
)

Add color value range for blob objects. Pixels in this range will be treated as foreground, and connected to be blobs.
It indicates this is a color-mode blob analysis tool, all the previous grayscale range setting will be cleaned up.

Parameters
[in]colorLBThe lower bound of the color value range. It's in the same channel order and color space as the source image.
[in]colorUBThe upper bound of the color value range. It's in the same channel order and color space as the source image.
See also
AddBlobRange(), AddBackgroundRangeColor(), SelectRangeAutoColor().

◆ Build()

LPVErrorCode Build ( ILImage img,
ILRegion region,
ILBlobResults **  results 
)

Build the blobs using the input image and the provided region.

Parameters
[in]imgThe input image. You should pass in the images of the matching format, aka. grayscale images for grayscale blob analysis mode. Otherwise, we will do the conversion automatically according to the current blob analysis mode.
[in]regionThe input region.
[out]resultsReturn the blob results.
Return values
errorReturn error code if anything is wrong.

◆ CountBackgroundRange()

int CountBackgroundRange ( )

Get count of the grayscale value ranges for background.

◆ CountBackgroundRangeColor()

int CountBackgroundRangeColor ( )

Get count of the color value ranges for background.

◆ CountBlobFilter()

int CountBlobFilter ( )

Get count of the blob filters.

◆ CountBlobRange()

int CountBlobRange ( )

Get count of the grayscale value ranges for blob objects.

◆ CountBlobRangeColor()

int CountBlobRangeColor ( )

Get count of the color value ranges for blob objects.

◆ ItemBackgroundRange()

void ItemBackgroundRange ( int  index,
int *  grayLB,
int *  grayUB 
)

Get the grayscale value ranges for background, with the given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
[out]grayLBReturn the lower bound of the grayscale value range.
[out]grayUBReturn the upper bound of the grayscale value range.

◆ ItemBackgroundRangeColor()

void ItemBackgroundRangeColor ( int  index,
LColor colorLB,
struct LColor colorUB 
)

Get the color value ranges for background, with the given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
[out]colorLBReturn the lower bound of the color value range.
[out]colorUBReturn the upper bound of the color value range.

◆ ItemBlobFilter()

ILBlobFilter* ItemBlobFilter ( int  index)

Reset the blob filters, all settings are cleaned up.

◆ ItemBlobRange()

void ItemBlobRange ( int  index,
int *  grayLB,
int *  grayUB 
)

Get the grayscale value ranges for blob objects, with the given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
[out]grayLBReturn the lower bound of the grayscale value range.
[out]grayUBReturn the upper bound of the grayscale value range.

◆ ItemBlobRangeColor()

void ItemBlobRangeColor ( int  index,
LColor colorLB,
struct LColor colorUB 
)

Get the color value ranges for blob objects, with the given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
[out]colorLBReturn the lower bound of the color value range.
[out]colorUBReturn the upper bound of the color value range.

◆ Preview()

void Preview ( ILImage img,
ILImage outputImg 
)

Preview the binarized image the input image with current foreground and background range configuration.

Parameters
[in]imgThe input image. You should pass in the images of the matching format, aka. grayscale images for grayscale blob analysis mode. Otherwise, we will do the conversion automatically according to the current blob analysis mode.
[out]outputImg Return the preview image.

◆ ResetBackgroundRange()

void ResetBackgroundRange ( )

Reset the grayscale value ranges for background, all settings are cleaned up.

◆ ResetBackgroundRangeColor()

void ResetBackgroundRangeColor ( )

Reset the color value ranges for background, all settings are cleaned up.

◆ ResetBlobFilter()

void ResetBlobFilter ( )

Remove all blob filters.

◆ ResetBlobRange()

void ResetBlobRange ( )

Reset the grayscale value ranges for blob objects, all settings are cleaned up.

◆ ResetBlobRangeColor()

void ResetBlobRangeColor ( )

Reset the color value ranges for blob objects, all settings are cleaned up.

◆ SelectRangeAuto()

void SelectRangeAuto ( ILImage image,
int  x,
int  y,
double  zoomX,
double  zoomY,
double  panX,
double  panY,
int  tolerance,
int *  grayLB,
int *  grayUB,
ILImage rangeMask 
)

Select a grayscale value range on the provided image. You should then explicitly add the range as blob or background range. It's usually called for a grayscale-mode blob analysis tool.

Parameters
[in]image The input image.
[in]xThe x-coordinate of the cursor(selected) position.
[in]yThe y-coordinate of the cursor(selected) position.
[in]toleranceThe maximum relative difference of neighbor pixels that build the selection
[out]grayLBReturn the lower bound of the grayscale value range in 0 ~ 255.
[out]grayUBReturn the upper bound of the grayscale value range in 0 ~ 255.
[out]rangeMask Return the mask image of the same size as the input image, white pixels represent the ones in selected grayscale value range in 0 ~ 255. Optional, could be null.
See also
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.
See also
SelectRangeAutoColor(), AddBlobRange(), AddBackgroundRange().

◆ SelectRangeAutoColor()

void SelectRangeAutoColor ( ILImage image,
int  x,
int  y,
double  zoomX,
double  zoomY,
double  panX,
double  panY,
int  tolerance,
LColor colorLB,
struct LColor colorUB,
ILImage rangeMask 
)

Select a color value range on the provided image. You should then explicitly add the range as blob or background range.

Parameters
[in]image The input image.
[in]xThe x-coordinate of the cursor(selected) position.
[in]yThe y-coordinate of the cursor(selected) position.
[in]toleranceThe maximum relative difference of neighbor pixels that build the selection
[out]colorLBReturn the lower bound of the color value range. It's in the same channel order and color space as the source image.
[out]colorUBReturn the upper bound of the color value range. It's in the same channel order and color space as the source image.
[out]rangeMask Return the mask image of the same size as the input image, white pixels represent the ones in selected grayscale value range in 0 ~ 255. Optional, could be null.
See also
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.
See also
SelectRangeAuto(), AddBlobRangeColor(), AddBackgroundRangeColor().

◆ SetRangeThresholdAdaptGlobal()

void SetRangeThresholdAdaptGlobal ( LPVPolarity  blobPolarity)

Use global-adaptive thresholding for segmentation. The optimal threshold value is calculated base on the entire input image.

Parameters
[in]blobPolarityThe object polarity of the blob. LPVBlackOnWhite indicates black pixels with smaller value than global threshold are the blobs, LPVWhiteOnBlack is exactly the opposite.

◆ SetRangeThresholdAdaptLocal()

void SetRangeThresholdAdaptLocal ( LPVPolarity  blobPolarity,
int  blockSize,
int  bias 
)

Use local-adaptive threshold value. The optimal threshold value is calculated base on a @math_eq{blockSize \times blockSize} region around individual pixel, then revised by the given bias value.

Parameters
[in]blobPolarityThe object polarity of the blob. LPVBlackOnWhite indicates black pixels with smaller value than global threshold are the blobs, LPVWhiteOnBlack is exactly the opposite.
[in]blockSizeSize of a pixel's local region, should be an odd number, say, 3, 5, 7, etc. Set it to 0 for auto-generate block size based in the input image size.
[in]biasRevise value to optimal threshold value as \( t' = t - bias \) for LPVBlackOnWhite , \( t' = t + bias \) for LPVWhiteOnBlack .

◆ SetSoftThresholdRange()

void SetSoftThresholdRange ( int  softRange)

Set the weighted range of soft thresholding. By default, it's 0 which means soft thresholding is not enabled.
It is useful to locate blobs more robust and more accurately.
For example, if we define blob color range to be [100, 200], and soft thresholding range to be 5, then, [0, 95] and [205, 255] are background, [105, 195] are foreground, [96, 104] are weighted as 0.1 ~ 0.9 to be foreground, [196, 204] are weighted as 0.9 ~ 0.1 to be foreground. Soft thresholding results in soft mask of the result blobs, and will affect the calculation of blob's geometric features, such as area or center. Pixels inside the blob contribute to the final result according to its weight.

Parameters
[in]softRangeThe soft thresholding range, create a [t - softRange, t + softRange] range.

Property Documentation

◆ AdaptBlobPolarity

LPVPolarity AdaptBlobPolarity
get

The blob's polarity defined for the global or local adaptive thresholding in segmentation.

See also
SetRangeThresholdAdaptGlobal(), SetRangeThresholdAdaptLocal()

◆ ContourType

LPVBlobContourType ContourType
getset

The type of the result blob contours, see LPVBlobContourType.

See also
Hierarchy.

◆ Hierarchy

int Hierarchy
getset

The hierarchy of the result blob contours. It's 0-based, negative value means all hierarchies.

See also
ContourType.

◆ LocalBias

int LocalBias
get

The revised value to generate a local adaptive threshold.

See also
SetRangeThresholdAdaptLocal()

◆ LocalBlockSize

int LocalBlockSize
get

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

See also
SetRangeThresholdAdaptLocal()

◆ MaxCount

int MaxCount
getset

The maximum of blobs to find. If there are more than the setting counts of blobs in the detect region, sort the candidates then pick the tops.

See also
SortBy

◆ SortBy

LPVBlobFeatures SortBy
getset

The method used to sort all blob candidates, the top ones are reported as final results.

See also
MaxCount, SortByDescending

◆ SortByDescending

BOOL SortByDescending
getset

Works together with SortBy. True to sort all blob candidates descending(from large value to small), false for sorting in ascending order.

See also
SortBy

◆ ThresholdType

LPVThresholdType ThresholdType
get

The thresholding method used in segmentation.

See also
AddBlobRange(), AddBlobRangeColor(), SetRangeThresholdAdaptGlobal(), SetRangeThresholdAdaptLocal()