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 );

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

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();

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();