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 $\mu(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 $\mu(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 \geq threshold + \mu(I)$.
- In multiplicative mode, with comparison criterion set to GREATER_OR_EQUAL, the output is set to 1 if $I \geq threshold \times \mu(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 );
This function returns outputBinaryImage.
// Function prototype. adaptive_thresholding_2d( input_image, kernel_radius_x = 30, kernel_radius_y = 30, threshold = 1, comparison_criterion = AdaptiveThresholding2d.ComparisonCriterion.GREATER_OR_EQUAL, threshold_mode = AdaptiveThresholding2d.ThresholdMode.MULTIPLICATIVE, output_binary_image = None )
This function returns outputBinaryImage.
// Function prototype. public static IOLink.ImageView AdaptiveThresholding2d( IOLink.ImageView inputImage, Int32 kernelRadiusX = 30, Int32 kernelRadiusY = 30, double threshold = 1, AdaptiveThresholding2d.ComparisonCriterion comparisonCriterion = ImageDev.AdaptiveThresholding2d.ComparisonCriterion.GREATER_OR_EQUAL, AdaptiveThresholding2d.ThresholdMode thresholdMode = ImageDev.AdaptiveThresholding2d.ThresholdMode.MULTIPLICATIVE, IOLink.ImageView outputBinaryImage = null );
Class Syntax
Parameters
Class Name | AdaptiveThresholding2d |
---|
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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) adaptive_thresholding_2d_algo = imagedev.AdaptiveThresholding2d() adaptive_thresholding_2d_algo.input_image = polystyrene adaptive_thresholding_2d_algo.kernel_radius_x = 30 adaptive_thresholding_2d_algo.kernel_radius_y = 30 adaptive_thresholding_2d_algo.threshold = 1.0 adaptive_thresholding_2d_algo.comparison_criterion = imagedev.AdaptiveThresholding2d.GREATER_OR_EQUAL adaptive_thresholding_2d_algo.threshold_mode = imagedev.AdaptiveThresholding2d.MULTIPLICATIVE adaptive_thresholding_2d_algo.execute() print( "output_binary_image:", str( adaptive_thresholding_2d_algo.output_binary_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); AdaptiveThresholding2d adaptiveThresholding2dAlgo = new AdaptiveThresholding2d { inputImage = polystyrene, kernelRadiusX = 30, kernelRadiusY = 30, threshold = 1.0, comparisonCriterion = AdaptiveThresholding2d.ComparisonCriterion.GREATER_OR_EQUAL, thresholdMode = AdaptiveThresholding2d.ThresholdMode.MULTIPLICATIVE }; adaptiveThresholding2dAlgo.Execute(); Console.WriteLine( "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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.adaptive_thresholding_2d( polystyrene, 30, 30, 1.0, imagedev.AdaptiveThresholding2d.GREATER_OR_EQUAL, imagedev.AdaptiveThresholding2d.MULTIPLICATIVE ) print( "output_binary_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.ImageView result = Processing.AdaptiveThresholding2d( polystyrene, 30, 30, 1.0, AdaptiveThresholding2d.ComparisonCriterion.GREATER_OR_EQUAL, AdaptiveThresholding2d.ThresholdMode.MULTIPLICATIVE ); Console.WriteLine( "outputBinaryImage:" + result.ToString() );