ImageDev

FloodFillThreshold2d

Transforms a grayscale two-dimensional image into a binary image by performing a region growing from a seed.

Access to parameter description

For an introduction: This algorithm performs a so-called region growing on a 2D image. Starting from a pixel seed, the algorithm selects the largest connected area that contains the pixel itself and all pixels with gray values lying inside an input range.
The input range is specified with the thresholdRange parameter.

This algorithm can be used to implement, for instance, an interactive magic wand tool.

See also

Function Syntax

This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > floodFillThreshold2d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector2i32 seedPoint, iolink::Vector2d thresholdRange, std::shared_ptr< iolink::ImageView > outputBinaryImage = nullptr );
This function returns outputBinaryImage.
// Function prototype.
flood_fill_threshold_2d(input_image: idt.ImageType,
                        seed_point: Iterable[int] = [1, 1],
                        threshold_range: Union[Iterable[int], Iterable[float]] = [128, 255],
                        output_binary_image: idt.ImageType = None) -> idt.ImageType
This function returns outputBinaryImage.
// Function prototype.
public static IOLink.ImageView
FloodFillThreshold2d( IOLink.ImageView inputImage,
                      int[] seedPoint = null,
                      double[] thresholdRange = null,
                      IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input grayscale image. Image Binary, Label or Grayscale nullptr
input
seedPoint
The seed point coordinates. Vector2i32 >=0 {1, 1}
input
thresholdRange
The low and high threshold levels defining the input range. Vector2d Any value {128.f, 255.f}
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input image. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input grayscale image. image Binary, Label or Grayscale None
input
seed_point
The seed point coordinates. vector2i32 >=0 [1, 1]
input
threshold_range
The low and high threshold levels defining the input range. vector2d Any value [128, 255]
output
output_binary_image
The output binary image. Its dimensions are forced to the same values as the input image. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input grayscale image. Image Binary, Label or Grayscale null
input
seedPoint
The seed point coordinates. Vector2i32 >=0 {1, 1}
input
thresholdRange
The low and high threshold levels defining the input range. Vector2d Any value {128f, 255f}
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input image. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

FloodFillThreshold2d floodFillThreshold2dAlgo;
floodFillThreshold2dAlgo.setInputImage( polystyrene );
floodFillThreshold2dAlgo.setSeedPoint( {1, 1} );
floodFillThreshold2dAlgo.setThresholdRange( {128.0, 255.0} );
floodFillThreshold2dAlgo.execute();

std::cout << "outputBinaryImage:" << floodFillThreshold2dAlgo.outputBinaryImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

flood_fill_threshold_2d_algo = imagedev.FloodFillThreshold2d()
flood_fill_threshold_2d_algo.input_image = polystyrene
flood_fill_threshold_2d_algo.seed_point = [1, 1]
flood_fill_threshold_2d_algo.threshold_range = [128.0, 255.0]
flood_fill_threshold_2d_algo.execute()

print("output_binary_image:", str(flood_fill_threshold_2d_algo.output_binary_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

FloodFillThreshold2d floodFillThreshold2dAlgo = new FloodFillThreshold2d
{
    inputImage = polystyrene,
    seedPoint = new int[]{1, 1},
    thresholdRange = new double[]{128.0, 255.0}
};
floodFillThreshold2dAlgo.Execute();

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

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = floodFillThreshold2d( polystyrene, {1, 1}, {128.0, 255.0} );

std::cout << "outputBinaryImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.flood_fill_threshold_2d(polystyrene, [1, 1], [128.0, 255.0])

print("output_binary_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.FloodFillThreshold2d( polystyrene, new int[]{1, 1}, new double[]{128.0, 255.0} );

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