ImageDev

RemoveSmallHoles

Fills the smallest holes of a binary image.

Access to parameter description

This algorithm removes holes smaller than a user-defined size in a binary image.
The holeSize parameter indicates the maximum size, in pixels, of the holes to be filled.

In order to fill the small holes, this algorithm amounts to filtering the complement of the input image with: See also

Function Syntax

This function returns outputObjectImage.
// Function prototype
std::shared_ptr< iolink::ImageView > removeSmallHoles( std::shared_ptr< iolink::ImageView > inputObjectImage, double holeSize, std::shared_ptr< iolink::ImageView > outputObjectImage = NULL );
This function returns outputObjectImage.
// Function prototype.
remove_small_holes( input_object_image, hole_size = 10, output_object_image = None )
This function returns outputObjectImage.
// Function prototype.
public static IOLink.ImageView
RemoveSmallHoles( IOLink.ImageView inputObjectImage,
                  double holeSize = 10,
                  IOLink.ImageView outputObjectImage = null );

Class Syntax

Parameters

Class Name RemoveSmallHoles

Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The input binary image. Image Binary nullptr
input
holeSize
The maximum size in pixels of holes to fill. Float64 >0 10
output
outputObjectImage
The output binary image. Its dimensions are forced to the same values as the input. Image nullptr

Object Examples

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

RemoveSmallHoles removeSmallHolesAlgo;
removeSmallHolesAlgo.setInputObjectImage( foam_sep );
removeSmallHolesAlgo.setHoleSize( 10.0 );
removeSmallHolesAlgo.execute();

std::cout << "outputObjectImage:" << removeSmallHolesAlgo.outputObjectImage()->toString();
foam_sep = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep.vip"))

remove_small_holes_algo = imagedev.RemoveSmallHoles()
remove_small_holes_algo.input_object_image = foam_sep
remove_small_holes_algo.hole_size = 10.0
remove_small_holes_algo.execute()

print( "output_object_image:", str( remove_small_holes_algo.output_object_image ) )
ImageView foam_sep = Data.ReadVipImage( @"Data/images/foam_sep.vip" );

RemoveSmallHoles removeSmallHolesAlgo = new RemoveSmallHoles
{
    inputObjectImage = foam_sep,
    holeSize = 10.0
};
removeSmallHolesAlgo.Execute();

Console.WriteLine( "outputObjectImage:" + removeSmallHolesAlgo.outputObjectImage.ToString() );

Function Examples

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

auto result = removeSmallHoles( foam_sep, 10.0 );

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

result = imagedev.remove_small_holes( foam_sep, 10.0 )

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

IOLink.ImageView result = Processing.RemoveSmallHoles( foam_sep, 10.0 );

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