AdaptiveThresholding2d
Performs a binarization of a grayscale image based on the mean intensity of a sliding window centered around each pixel.
Access to parameter description
Each pixel value I is compared to the mean intensity μ(I) of its local window.
The corresponding pixel in the binary output depends on a threshold value, an arithmetic mode, and a comparison criterion.
See also
Access to parameter description
Each pixel value I is compared to the mean intensity μ(I) of its local window.
The corresponding pixel in the binary output depends on a threshold value, an arithmetic mode, and a comparison criterion.
- In additive mode, with comparison criterion set to GREATER_OR_EQUAL, the output is set to 1 if I≥threshold+μ(I).
- In multiplicative mode, with comparison criterion set to GREATER_OR_EQUAL, the output is set to 1 if I≥threshold×μ(I).
See also
Function Syntax
This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > adaptiveThresholding2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelRadiusX, int32_t kernelRadiusY, double threshold, AdaptiveThresholding2d::ComparisonCriterion comparisonCriterion, AdaptiveThresholding2d::ThresholdMode thresholdMode, std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. Its type can be integer or float. | Image | Grayscale | nullptr | ||||
![]() |
kernelRadiusX |
The half horizontal size of the kernel size in pixels. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1." | Int32 | >=1 | 30 | ||||
![]() |
kernelRadiusY |
The half vertical size of the kernel size in pixels. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1." | Int32 | >=1 | 30 | ||||
![]() |
threshold |
The fraction or the additive thresholding value, according to the thresholdMode parameter value. | Float64 | Any value | 1 | ||||
![]() |
comparisonCriterion |
The comparison test to perform between image and value.
|
Enumeration | GREATER_OR_EQUAL | |||||
![]() |
thresholdMode |
The local thresholding mode.
|
Enumeration | MULTIPLICATIVE | |||||
![]() |
outputBinaryImage |
The output binary image. Its dimensions are forced to the same values as the input. | Image | nullptr |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); AdaptiveThresholding2d adaptiveThresholding2dAlgo; adaptiveThresholding2dAlgo.setInputImage( polystyrene ); adaptiveThresholding2dAlgo.setKernelRadiusX( 30 ); adaptiveThresholding2dAlgo.setKernelRadiusY( 30 ); adaptiveThresholding2dAlgo.setThreshold( 1.0 ); adaptiveThresholding2dAlgo.setComparisonCriterion( AdaptiveThresholding2d::ComparisonCriterion::GREATER_OR_EQUAL ); adaptiveThresholding2dAlgo.setThresholdMode( AdaptiveThresholding2d::ThresholdMode::MULTIPLICATIVE ); adaptiveThresholding2dAlgo.execute(); std::cout << "outputBinaryImage:" << adaptiveThresholding2dAlgo.outputBinaryImage()->toString();
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = adaptiveThresholding2d( polystyrene, 30, 30, 1.0, AdaptiveThresholding2d::ComparisonCriterion::GREATER_OR_EQUAL, AdaptiveThresholding2d::ThresholdMode::MULTIPLICATIVE ); std::cout << "outputBinaryImage:" << result->toString();