CVB++ 15.0
Cvb::Foundation::Threshold Namespace Reference

Namespace for collection of thresholding functions from the Foundation package. More...

Enumerations

enum class  StaticThresholding {
  LessThan = CExports::TH_Less , LessThanOrEqual = CExports::TH_LessOrEqual , Equal = CExports::TH_Equal , GreaterOrEqual = CExports::TH_GreaterOrEqual ,
  Greater = CExports::TH_Greater
}
 Comparisons for static thresholding. More...
 
enum class  DynamicThresholdNorm { Mean = CExports::DTN_Mean , MinMax = CExports::DTN_MinMax }
 Norm calculation approaches for dynamic thresholding. More...
 

Functions

std::unique_ptr< ImageStaticThreshold (const Image &image, const Image &thresholds, StaticThresholding comparison)
 This function performs thresholding of an input image with pixel-by-pixel thresholds stored in the pixels of a thresholds image. More...
 
template<class RANGE >
TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticThreshold (const Image &image, const RANGE &values, StaticThresholding comparison)
 Create an output image, that is the result of static thresholding. More...
 
std::unique_ptr< ImageStaticThreshold (const Image &image, double value, StaticThresholding comparison)
 Create an output image that is the result of static thresholding. More...
 
std::unique_ptr< ImageDynamicThreshold (const Image &image, int windowSize, int threshold, DynamicThresholdNorm norm=DynamicThresholdNorm::Mean)
 This function performs dynamic thresholding on the input image. More...
 
template<class RANGE >
TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticTransparentThreshold (const Image &image, const RANGE &thresholds, StaticThresholding comparison, const RANGE &values)
 Create a thresholded image using a transparency approach. More...
 
std::unique_ptr< ImageStaticTransparentThreshold (const Image &image, double threshold, StaticThresholding comparison, double value)
 Create a thresholded image using a transparency approach. More...
 
template<class RANGE >
TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticTransparentThreshold (const Image &image, const RANGE &thresholds, StaticThresholding comparison)
 Create a thresholded image using a transparency approach. More...
 
std::unique_ptr< ImageStaticTransparentThreshold (const Image &image, double threshold, StaticThresholding comparison)
 Create a thresholded image using a transparency approach. More...
 
void RangeThresholdToDst (const ImagePlane &plane, ValueRange< int > range, Image &imageDst, Rect< int > aoi)
 A range based binarization algorithm to the given input. More...
 
void RangeThresholdToDst (const ImagePlane &plane, ValueRange< int > range, Image &imageDst)
 A range based binarization algorithm to the given input. More...
 
std::unique_ptr< ImageRangeThreshold (const ImagePlane &plane, ValueRange< int > range, Rect< int > aoi)
 A range based binarization algorithm to the given input. More...
 
std::unique_ptr< ImageRangeThreshold (const ImagePlane &plane, ValueRange< int > range)
 A range based binarization algorithm to the given input. More...
 

Detailed Description

Namespace for collection of thresholding functions from the Foundation package.

Remarks
CMake users: Link to imported target CVB::CvbFoundationThreshold

Enumeration Type Documentation

◆ DynamicThresholdNorm

enum class DynamicThresholdNorm
strong

Norm calculation approaches for dynamic thresholding.

Enumerator
Mean 

Dynamic thresholding compares versus the mean value of the threshold mask (default).

MinMax 

Dynamic thresholding compares versus the middle between the minimum and the maximum value inside the threshold mask.

◆ StaticThresholding

enum class StaticThresholding
strong

Comparisons for static thresholding.

Enumerator
LessThan 

Less than.

LessThanOrEqual 

Less than or Equal.

Equal 

Equal.

GreaterOrEqual 

Greater or Equal.

Greater 

Greater.

Function Documentation

◆ DynamicThreshold()

std::unique_ptr< Image > DynamicThreshold ( const Image image,
int  windowSize,
int  threshold,
DynamicThresholdNorm  norm = DynamicThresholdNorm::Mean 
)
inline

This function performs dynamic thresholding on the input image.

Parameters
[in]imageImage to be thresholded.
[in]windowSizeWindow size to calculate the dynamic threshold. Bigger window sizes will lead to higher processing times.
[in]thresholdThreshold offset to use.
[in]normEither DynamicThresholdNorm::Mean (default) or DynamicThresholdNorm::MinMax.
Returns
Thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

Dynamic thresholding works by calculating the average gray value over a mask with given size (centered around the pixel in question) for each input pixel. If the difference between this average and the pixel, that is currently being looked at, is above the specified threshold, then the corresponding pixel in the output image is set to white, otherwise it is black.

This function is particularly useful, when dealing with images, that have a non-uniform illumination.

◆ RangeThreshold() [1/2]

std::unique_ptr< Image > RangeThreshold ( const ImagePlane plane,
ValueRange< int >  range 
)
inline

A range based binarization algorithm to the given input.

Parameters
[in]planeImage plane to binarize.
[in]rangeThe gray value range for binarization.
Returns
std::unique_ptr<Image> Resulting binarized image.
Exceptions
Anyexception derived from std::exception including CvbException.

The binarization algorithm is implemented in the blob analyzer.

◆ RangeThreshold() [2/2]

std::unique_ptr< Image > RangeThreshold ( const ImagePlane plane,
ValueRange< int >  range,
Rect< int >  aoi 
)
inline

A range based binarization algorithm to the given input.

Parameters
[in]planeImage plane to binarize.
[in]rangeThe gray value range for binarization.
[in]aoiArea of interest to binarize.
Returns
std::unique_ptr<Image> Resulting binarized image.
Exceptions
Anyexception derived from std::exception including CvbException.

The binarization algorithm is implemented in the blob analyzer.

◆ RangeThresholdToDst() [1/2]

void RangeThresholdToDst ( const ImagePlane plane,
ValueRange< int >  range,
Image imageDst 
)
inline

A range based binarization algorithm to the given input.

Parameters
[in]planeImage plane to binarize.
[in]rangeThe gray value range for binarization.
[in]imageDstDestination image to receive the binarization result.
Exceptions
Anyexception derived from std::exception including CvbException.

The binarization algorithm is implemented in the blob analyzer.

This destination image must have one plane only with 8 bits per pixel and be compatible with the input aoi in terms of size.

◆ RangeThresholdToDst() [2/2]

void RangeThresholdToDst ( const ImagePlane plane,
ValueRange< int >  range,
Image imageDst,
Rect< int >  aoi 
)
inline

A range based binarization algorithm to the given input.

Parameters
[in]planeImage plane to binarize.
[in]rangeThe gray value range for binarization.
[in]imageDstDestination image to receive the binarization result.
[in]aoiArea of interest to binarize.
Exceptions
Anyexception derived from std::exception including CvbException.

The binarization algorithm is implemented in the blob analyzer.

Please note, that despite the fact, that it is possible to specify an area of interest, the binarized data will always be located in the top left corner of the image.

This destination image must have one plane only with 8 bits per pixel and be compatible with the input aoi in terms of size.

◆ StaticThreshold() [1/3]

std::unique_ptr< Image > StaticThreshold ( const Image image,
const Image thresholds,
StaticThresholding  comparison 
)
inline

This function performs thresholding of an input image with pixel-by-pixel thresholds stored in the pixels of a thresholds image.

Parameters
[in]imageImage to be thresholded.
[in]thresholdsImage containing the threshold values for the pixels of the input image.
[in]comparisonComparison to apply.
Returns
The thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

Both images should be identical in size. However, if they are not, the smallest common rectangle (located at the top left pixel) of both images will be the size of the result image. Both input images should have identical dimensions (either 1 or 3 planes per image) and identical data types.

◆ StaticThreshold() [2/3]

TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticThreshold ( const Image image,
const RANGE &  values,
StaticThresholding  comparison 
)
inline

Create an output image, that is the result of static thresholding.

Parameters
[in]imageImage to apply static thresholding to.
[in]valuesThreshold values - the array must contain at least one threshold per plane available in the image.
[in]comparisonComparison method.
Returns
The result image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ StaticThreshold() [3/3]

std::unique_ptr< Image > StaticThreshold ( const Image image,
double  value,
StaticThresholding  comparison 
)
inline

Create an output image that is the result of static thresholding.

Parameters
[in]imageImage to apply static thresholding to.
[in]valueThreshold value to be applied to each image plane.
[in]comparisonComparison method.
Returns
Result image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ StaticTransparentThreshold() [1/4]

TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticTransparentThreshold ( const Image image,
const RANGE &  thresholds,
StaticThresholding  comparison 
)
inline

Create a thresholded image using a transparency approach.

Parameters
[in]imageInput image.
[in]thresholdsThresholds to apply (one per plane).
[in]comparisonThresholding condition.
Returns
Thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

In the result image every pixel, that violates the comparison to its threshold, will be assigned the threshold value. All others will be assigned the same value, they had in the input image.

◆ StaticTransparentThreshold() [2/4]

TypedRange< std::unique_ptr< Image >, double, RANGE >::type StaticTransparentThreshold ( const Image image,
const RANGE &  thresholds,
StaticThresholding  comparison,
const RANGE &  values 
)
inline

Create a thresholded image using a transparency approach.

Parameters
[in]imageInput image.
[in]thresholdsThresholds to apply (one per plane).
[in]comparisonThresholding condition.
[in]valuesValue to set for pixels, that violate the thresholding condition (one per plane required).
Returns
Thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

In the result image every pixel, that violates the comparison to its threshold, will be assigned the value specified in values argument. All others will be assigned the same value, they had in the input image.

◆ StaticTransparentThreshold() [3/4]

std::unique_ptr< Image > StaticTransparentThreshold ( const Image image,
double  threshold,
StaticThresholding  comparison 
)
inline

Create a thresholded image using a transparency approach.

Parameters
[in]imageInput image.
[in]thresholdThreshold to apply to each image plane.
[in]comparisonThresholding condition.
Returns
Thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

In the result image every pixel, that violates the comparison to its threshold, will be assigned the threshold value. All others will be assigned the same value, they had in the input image.

◆ StaticTransparentThreshold() [4/4]

std::unique_ptr< Image > StaticTransparentThreshold ( const Image image,
double  threshold,
StaticThresholding  comparison,
double  value 
)
inline

Create a thresholded image using a transparency approach.

Parameters
[in]imageInput image.
[in]thresholdThreshold value to be applied to each image plane.
[in]comparisonThresholding condition.
[in]valueValue to set for pixels, that violate the thresholding condition (applies to all planes).
Returns
Thresholded image.
Exceptions
Anyexception derived from std::exception including CvbException.

In the result image every pixel, that violates the comparison to its threshold, will be assigned the value specified in values argument. All others will be assigned the same value, they had in the input image.