ImageDev

EuclideanDistanceMap2d

Computes the Euclidean distance map of objects in a two-dimensional binary or label image.

Access to parameter description

This algorithm computes a 2D distance map for a 2D object. Each voxel is assigned a value depending on the distance to the nearest object boundary.

The boundary voxels of the object are assigned a value of zero whereas the assigned value increases as the distance increases. This algorithm computes distances using the Euclidean metric.

Note: This algorithm takes into account the input image calibration. The output values are indicating distance in world units, as defined by the calibration.

See also

Function Syntax

This function returns outputMapImage.
// Function prototype
std::shared_ptr< iolink::ImageView > euclideanDistanceMap2d( std::shared_ptr< iolink::ImageView > inputObjectImage, EuclideanDistanceMap2d::MappingMode mappingMode, EuclideanDistanceMap2d::BorderCondition borderCondition, std::shared_ptr< iolink::ImageView > outputMapImage = NULL );
This function returns outputMapImage.
// Function prototype.
euclidean_distance_map_2d( input_object_image,
                           mapping_mode = EuclideanDistanceMap2d.MappingMode.INSIDE,
                           border_condition = EuclideanDistanceMap2d.BorderCondition.ZERO,
                           output_map_image = None )
This function returns outputMapImage.
// Function prototype.
public static IOLink.ImageView
EuclideanDistanceMap2d( IOLink.ImageView inputObjectImage,
                        EuclideanDistanceMap2d.MappingMode mappingMode = ImageDev.EuclideanDistanceMap2d.MappingMode.INSIDE,
                        EuclideanDistanceMap2d.BorderCondition borderCondition = ImageDev.EuclideanDistanceMap2d.BorderCondition.ZERO,
                        IOLink.ImageView outputMapImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The binary or label input image. Image Binary or Label nullptr
input
mappingMode
The mode defining where the distance field is computed.
INSIDE The distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain at zero.
OUTSIDE The distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
Enumeration INSIDE
input
borderCondition
The mode defining the border conditions.
ZERO Voxels outside of the image are considered to have the value 0.
MIRROR Voxels outside of the image are considered as an extrapolation of the image voxels with a mirror border condition.
Enumeration ZERO
output
outputMapImage
The distance map output image. Distance map of the shape represented by the input image. Each voxel is assigned to a value depending on the distance to the nearest object boundary. Its dimensions are forced to the same values as the input. Its data type is 32-bit floating point. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_object_image
The binary or label input image. image Binary or Label None
input
mapping_mode
The mode defining where the distance field is computed.
INSIDE The distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain at zero.
OUTSIDE The distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
enumeration INSIDE
input
border_condition
The mode defining the border conditions.
ZERO Voxels outside of the image are considered to have the value 0.
MIRROR Voxels outside of the image are considered as an extrapolation of the image voxels with a mirror border condition.
enumeration ZERO
output
output_map_image
The distance map output image. Distance map of the shape represented by the input image. Each voxel is assigned to a value depending on the distance to the nearest object boundary. Its dimensions are forced to the same values as the input. Its data type is 32-bit floating point. image None
Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The binary or label input image. Image Binary or Label null
input
mappingMode
The mode defining where the distance field is computed.
INSIDE The distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain at zero.
OUTSIDE The distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
Enumeration INSIDE
input
borderCondition
The mode defining the border conditions.
ZERO Voxels outside of the image are considered to have the value 0.
MIRROR Voxels outside of the image are considered as an extrapolation of the image voxels with a mirror border condition.
Enumeration ZERO
output
outputMapImage
The distance map output image. Distance map of the shape represented by the input image. Each voxel is assigned to a value depending on the distance to the nearest object boundary. Its dimensions are forced to the same values as the input. Its data type is 32-bit floating point. Image null

Object Examples

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

EuclideanDistanceMap2d euclideanDistanceMap2dAlgo;
euclideanDistanceMap2dAlgo.setInputObjectImage( polystyrene_sep );
euclideanDistanceMap2dAlgo.setMappingMode( EuclideanDistanceMap2d::MappingMode::INSIDE );
euclideanDistanceMap2dAlgo.setBorderCondition( EuclideanDistanceMap2d::BorderCondition::ZERO );
euclideanDistanceMap2dAlgo.execute();

std::cout << "outputMapImage:" << euclideanDistanceMap2dAlgo.outputMapImage()->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

euclidean_distance_map_2d_algo = imagedev.EuclideanDistanceMap2d()
euclidean_distance_map_2d_algo.input_object_image = polystyrene_sep
euclidean_distance_map_2d_algo.mapping_mode = imagedev.EuclideanDistanceMap2d.INSIDE
euclidean_distance_map_2d_algo.border_condition = imagedev.EuclideanDistanceMap2d.ZERO
euclidean_distance_map_2d_algo.execute()

print( "output_map_image:", str( euclidean_distance_map_2d_algo.output_map_image ) )
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

EuclideanDistanceMap2d euclideanDistanceMap2dAlgo = new EuclideanDistanceMap2d
{
    inputObjectImage = polystyrene_sep,
    mappingMode = EuclideanDistanceMap2d.MappingMode.INSIDE,
    borderCondition = EuclideanDistanceMap2d.BorderCondition.ZERO
};
euclideanDistanceMap2dAlgo.Execute();

Console.WriteLine( "outputMapImage:" + euclideanDistanceMap2dAlgo.outputMapImage.ToString() );

Function Examples

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

auto result = euclideanDistanceMap2d( polystyrene_sep, EuclideanDistanceMap2d::MappingMode::INSIDE, EuclideanDistanceMap2d::BorderCondition::ZERO );

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

result = imagedev.euclidean_distance_map_2d( polystyrene_sep, imagedev.EuclideanDistanceMap2d.INSIDE, imagedev.EuclideanDistanceMap2d.ZERO )

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

IOLink.ImageView result = Processing.EuclideanDistanceMap2d( polystyrene_sep, EuclideanDistanceMap2d.MappingMode.INSIDE, EuclideanDistanceMap2d.BorderCondition.ZERO );

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