ImageDev

AdaptiveThresholding3d

Performs a binarization of a grayscale image based on the mean intensity of a sliding window centered around each voxel.

Access to parameter description

Each voxel value $I$ is compared to the mean intensity $\mu(I)$ of its local window.
The corresponding voxel in the binary output depends on a threshold value, an arithmetic mode, and a comparison criterion. For example, to select voxels lower than 90% of their local mean, set the threshold parameter to 0.9, comparisonCriterion to LESS_OR_EQUAL and thresholdMode to MULTIPLICATIVE.

See also

Function Syntax

This function returns the outputBinaryImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
adaptiveThresholding3d( std::shared_ptr< iolink::ImageView > inputImage,
                        int32_t kernelRadiusX,
                        int32_t kernelRadiusY,
                        int32_t kernelRadiusZ,
                        double threshold,
                        AdaptiveThresholding3d::ComparisonCriterion comparisonCriterion,
                        AdaptiveThresholding3d::ThresholdMode thresholdMode,
                        std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
This function returns the outputBinaryImage output parameter.
// Function prototype.
adaptive_thresholding_3d( input_image,
                          kernel_radius_x = 30,
                          kernel_radius_y = 30,
                          kernel_radius_z = 30,
                          threshold = 1,
                          comparison_criterion = AdaptiveThresholding3d.ComparisonCriterion.GREATER_OR_EQUAL,
                          threshold_mode = AdaptiveThresholding3d.ThresholdMode.MULTIPLICATIVE,
                          output_binary_image = None )
This function returns the outputBinaryImage output parameter.
// Function prototype.
public static IOLink.ImageView
AdaptiveThresholding3d( IOLink.ImageView inputImage,
                        Int32 kernelRadiusX = 30,
                        Int32 kernelRadiusY = 30,
                        Int32 kernelRadiusZ = 30,
                        double threshold = 1,
                        AdaptiveThresholding3d.ComparisonCriterion comparisonCriterion = ImageDev.AdaptiveThresholding3d.ComparisonCriterion.GREATER_OR_EQUAL,
                        AdaptiveThresholding3d.ThresholdMode thresholdMode = ImageDev.AdaptiveThresholding3d.ThresholdMode.MULTIPLICATIVE,
                        IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Class Name AdaptiveThresholding3d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Its type can be integer or float. Image Grayscale nullptr
input
kernelRadiusX
The horizontal kernel size in voxels. Int32 >=1 30
input
kernelRadiusY
The vertical kernel size in voxels. Int32 >=1 30
input
kernelRadiusZ
The depth kernel size in voxels. Int32 >=1 30
input
threshold
The fraction or the additive thresholding value, according to the thresholdMode parameter value. Float64 Any value 1
input
comparisonCriterion
The comparison test to perform between image and value.
GREATER_OR_EQUAL All voxels whose value is greater than or equal to the local threshold value are set to 1, others are set to 0.
LESS_OR_EQUAL All voxels whose value is less than or equal to the local threshold value are set to 1, others are set to 0.
Enumeration GREATER_OR_EQUAL
input
thresholdMode
The local thresholding mode.
MULTIPLICATIVE The local threshold is equal to mean(I) x threshold.
ADDITIVE The local threshold is equal to mean(I) + threshold.
Enumeration MULTIPLICATIVE
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image nullptr

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

AdaptiveThresholding3d adaptiveThresholding3dAlgo;
adaptiveThresholding3dAlgo.setInputImage( foam );
adaptiveThresholding3dAlgo.setKernelRadiusX( 30 );
adaptiveThresholding3dAlgo.setKernelRadiusY( 30 );
adaptiveThresholding3dAlgo.setKernelRadiusZ( 30 );
adaptiveThresholding3dAlgo.setThreshold( 1.0 );
adaptiveThresholding3dAlgo.setComparisonCriterion( AdaptiveThresholding3d::ComparisonCriterion::GREATER_OR_EQUAL );
adaptiveThresholding3dAlgo.setThresholdMode( AdaptiveThresholding3d::ThresholdMode::MULTIPLICATIVE );
adaptiveThresholding3dAlgo.execute();

std::cout << "outputBinaryImage:" << adaptiveThresholding3dAlgo.outputBinaryImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

adaptive_thresholding_3d_algo = imagedev.AdaptiveThresholding3d()
adaptive_thresholding_3d_algo.input_image = foam
adaptive_thresholding_3d_algo.kernel_radius_x = 30
adaptive_thresholding_3d_algo.kernel_radius_y = 30
adaptive_thresholding_3d_algo.kernel_radius_z = 30
adaptive_thresholding_3d_algo.threshold = 1.0
adaptive_thresholding_3d_algo.comparison_criterion = imagedev.AdaptiveThresholding3d.GREATER_OR_EQUAL
adaptive_thresholding_3d_algo.threshold_mode = imagedev.AdaptiveThresholding3d.MULTIPLICATIVE
adaptive_thresholding_3d_algo.execute()

print( "output_binary_image:", str( adaptive_thresholding_3d_algo.output_binary_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

AdaptiveThresholding3d adaptiveThresholding3dAlgo = new AdaptiveThresholding3d
{
    inputImage = foam,
    kernelRadiusX = 30,
    kernelRadiusY = 30,
    kernelRadiusZ = 30,
    threshold = 1.0,
    comparisonCriterion = AdaptiveThresholding3d.ComparisonCriterion.GREATER_OR_EQUAL,
    thresholdMode = AdaptiveThresholding3d.ThresholdMode.MULTIPLICATIVE
};
adaptiveThresholding3dAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + adaptiveThresholding3dAlgo.outputBinaryImage.ToString() );

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = adaptiveThresholding3d( foam, 30, 30, 30, 1.0, AdaptiveThresholding3d::ComparisonCriterion::GREATER_OR_EQUAL, AdaptiveThresholding3d::ThresholdMode::MULTIPLICATIVE );

std::cout << "outputBinaryImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.adaptive_thresholding_3d( foam, 30, 30, 30, 1.0, imagedev.AdaptiveThresholding3d.GREATER_OR_EQUAL, imagedev.AdaptiveThresholding3d.MULTIPLICATIVE )

print( "output_binary_image:", str( result ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.AdaptiveThresholding3d( foam, 30, 30, 30, 1.0, AdaptiveThresholding3d.ComparisonCriterion.GREATER_OR_EQUAL, AdaptiveThresholding3d.ThresholdMode.MULTIPLICATIVE );

Console.WriteLine( "outputBinaryImage:" + result.ToString() );