Foundation (CVFoundation.dll) 14.0
Thresholding Functions

Functions

cvbres_t CreateConstantThresholdImage (IMG ImgIn, double Values[], TThresholdComparison Comparison, IMG &ImgOut)
 Calculates and applies a constant threshold to each plane of the input image. More...
 
cvbres_t CreateDynamicThresholdImage (IMG ImgIn, long WindowSize, long Threshold, IMG &ImgOut)
 Performs dynamic thresholding on the input image. More...
 
cvbres_t CreateDynamicThresholdImageEx (IMG ImgIn, TDynamicThresholdNorm Norm, long WindowSize, double Threshold, IMG &ImgOut)
 Generates a dynamic thresholdized image from an input image. The mask for threshold determination is defined through the MaskWidth parameter, threshold and thresholding mode are selectable. More...
 
cvbres_t CreateImageThresholdImage (IMG ImgIn, IMG ImgThreshold, TThresholdComparison Comparison, IMG &ImgOut)
 Performs thresholding of an input image with pixel-by-pixel thresholds stored in the pixels of a threshold image. More...
 
cvbres_t CreateTransparentThresholdImage (IMG ImgIn, double Thresholds[], double Values[], TThresholdComparison Comparison, IMG &ImgOut)
 Create an image where the pixel values of an input image are checked versus a threshold; if the values exceed that threshold under the specified TThresholdComparison, the pixel will be set to the corresponding value from the Values array. Otherwise it will contain the pixel value from the input image. More...
 

Detailed Description

Function Documentation

◆ CreateConstantThresholdImage()

cvbres_t CreateConstantThresholdImage ( IMG  ImgIn,
double  Values[],
TThresholdComparison  Comparison,
IMG ImgOut 
)

Calculates and applies a constant threshold to each plane of the input image.

It generates a thresholded output image whose planes only have pixels that are either white or black. It is possible to supply a different threshold value for each plane, therefore the threshold is passed to the function as an array.

Parameters
[in]ImgInHandle of input image.
[in]ValuesArray with the individual thresholds for each channel.
The number of elements in this array needs to be at least the same as the number of planes in the image.
Attention: Visual Basic users need to create an array and pass the first element in that array.
[in]ComparisonComparison operation. See TThresholdComparison for possible methods.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64

◆ CreateDynamicThresholdImage()

cvbres_t CreateDynamicThresholdImage ( IMG  ImgIn,
long  WindowSize,
long  Threshold,
IMG ImgOut 
)

Performs dynamic thresholding on the input image.

Dynamic thresholding works such that for each pixel of the input image, the average gray-value over a mask with given size
(centered around the pixel in question) is calculated. \n
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. \n\n
This function is particularly useful when dealing with images that have a non-uniform illumination: 
<img class="ToDisplay" src="DynThreshTest.gif" align="left"  alt="Dynamic Threshold Test"> \n\n\n\n\n\n\n\n\n\n\n

Normally it is possible to find a set of parameters (averaging window size and threshold), that yield approximately the same results for varying lighting situations. For example the image above binarized with a window size of 9 and a threshold of 10 look like this: Dynamic Threshold










Attention
Works on input images with up to 16 bits per pixel.
Parameters
[in]ImgInHandle of input image to be binarized.
[in]WindowSizeSize of the averaging window. The anchor of the averaging window is its center point.
The images it is applied to will automatically be extended by repeating the last line or column of data. Window sizes need to be in the range of 3 to 511 and need to be odd (even input values will be decreased by 1).
[in]ThresholdThreshold value. See the description above on how it is being used.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64

◆ CreateDynamicThresholdImageEx()

cvbres_t CreateDynamicThresholdImageEx ( IMG  ImgIn,
TDynamicThresholdNorm  Norm,
long  WindowSize,
double  Threshold,
IMG ImgOut 
)

Generates a dynamic thresholdized image from an input image. The mask for threshold determination is defined through the MaskWidth parameter, threshold and thresholding mode are selectable.

Parameters
[in]ImgIn- Image to be binarized
[in]WindowSize- size of the convolution mask to be applied
[in]Norm- Norm with which to calculate the dynamic threshold
[in]Threshold- threshold value
[out]ImgOut- Will hold the result image after operation
Returns
None

◆ CreateImageThresholdImage()

cvbres_t CreateImageThresholdImage ( IMG  ImgIn,
IMG  ImgThreshold,
TThresholdComparison  Comparison,
IMG ImgOut 
)

Performs thresholding of an input image with pixel-by-pixel thresholds stored in the pixels of a threshold image.

Obviously, 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 three planes per image) and identical data-types.
Parameters
[in]ImgInHandle of input image.
[in]ImgThresholdHandle of second input image containing the threshold values.
[in]ComparisonComparison operation. See TThresholdComparison for possible methods.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64

◆ CreateTransparentThresholdImage()

cvbres_t CreateTransparentThresholdImage ( IMG  ImgIn,
double  Thresholds[],
double  Values[],
TThresholdComparison  Comparison,
IMG ImgOut 
)

Create an image where the pixel values of an input image are checked versus a threshold; if the values exceed that threshold under the specified TThresholdComparison, the pixel will be set to the corresponding value from the Values array. Otherwise it will contain the pixel value from the input image.

It is possible to supply a different thresholds and values for each plane, therefore the thresholds and values are passed to the function as an array.
If float images are used which contain infinite Values and NaNs these values are handled as follows.
Infinite Values:
Infinite Values are handled as maximum negative or positive values. Because of this it depends on the threshold values and the comparison method if the infinite values are set to the target value. NaN:
NaNs are set to zero if TH_Less is used. If TH_Greater is used NaNs are not changed.

Parameters
[in]ImgInHandle of input image.
[in]ThresholdsArray with the individual thresholds for each channel.
The number of elements in this array needs to be at least the same as the number of planes in the image.
Attention: Visual Basic users need to create an array and pass the first element in that array.
[in]ValuesArray with the individual target values for each channel.
The number of elements in this array needs to be at least the same as the number of planes in the image.
Attention: Visual Basic users need to create an array and pass the first element in that array.
[in]ComparisonComparison operation. Supported are TH_Less and TH_Greater. See TThresholdComparison.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64