A distance map, also known as distance transform, is a representation of an image where each voxel value
corresponds to its distance to the nearest boundary voxel in a given metric.
Two metrics are commonly used:
The Chessboard distance, also known as Chebyshev distance, where all neighbor voxels are considered as a
same distance of 1 from a given voxel.
The Chamfer distance where face neighbors are considered as a distance of 1, edge neighbors are considered
with a √2 weight and corner neighbors are considered with a √3 weight in order to better
approximate a Euclidean distance.
In the output image O, a voxel x belonging to a particle X, takes an intensity I equal to the distance
to the boundary.
In the case of the Chessboard metric, the distance is given by: I=dC(x,δ(X))
Where: dC((i,j,k),(l,m,n))=max(|l−i|,|m−j|,|n−k|)
The weight used for each neighbor configuration can be user defined. Some optimizations are automatically
performed when the weights set correspond to a Chamfer or a Chessboard distance map.
Distance maps are computed on binary images either on object voxels (foreground) or on the background.
The output image can have either a 16-bit signed integer or a 32-bit float type.
Note: This algorithm does not take into account the input image calibration. The output values
are systematically indicating distance in voxel units.
// Command constructor.DistanceMap3d();/// Gets the inputBinaryImage parameter./// The binary input image.
std::shared_ptr< iolink::ImageView> inputBinaryImage()const;/// Sets the inputBinaryImage parameter./// The binary input image.void setInputBinaryImage( std::shared_ptr< iolink::ImageView> inputBinaryImage );/// Gets the mappingMode parameter./// The mode defining where the distance field is computed.DistanceMap3d::MappingMode mappingMode()const;/// Sets the mappingMode parameter./// The mode defining where the distance field is computed.void setMappingMode(constDistanceMap3d::MappingMode& mappingMode );/// Gets the borderCondition parameter./// The mode defining the border conditions.DistanceMap3d::BorderCondition borderCondition()const;/// Sets the borderCondition parameter./// The mode defining the border conditions.void setBorderCondition(constDistanceMap3d::BorderCondition& borderCondition );/// Gets the faceDistance parameter./// The distance weight between 2 voxels having a face connection.double faceDistance()const;/// Sets the faceDistance parameter./// The distance weight between 2 voxels having a face connection.void setFaceDistance(constdouble& faceDistance );/// Gets the edgeDistance parameter./// The distance weight between 2 voxels having an edge connection.double edgeDistance()const;/// Sets the edgeDistance parameter./// The distance weight between 2 voxels having an edge connection.void setEdgeDistance(constdouble& edgeDistance );/// Gets the cornerDistance parameter./// The distance weight between 2 voxels having a corner connection.double cornerDistance()const;/// Sets the cornerDistance parameter./// The distance weight between 2 voxels having a corner connection.void setCornerDistance(constdouble& cornerDistance );/// Gets the outputType parameter./// The output image type to provide.DistanceMap3d::OutputType outputType()const;/// Sets the outputType parameter./// The output image type to provide.void setOutputType(constDistanceMap3d::OutputType& outputType );/// Gets the outputMapImage parameter./// The output distance map image.
std::shared_ptr< iolink::ImageView> outputMapImage()const;/// Sets the outputMapImage parameter./// The output distance map image.void setOutputMapImage( std::shared_ptr< iolink::ImageView> outputMapImage );// Method to launch the command.void execute();
# Property of the inputBinaryImage parameter.DistanceMap3d.input_binary_image
# Property of the mappingMode parameter.DistanceMap3d.mapping_mode
# Property of the borderCondition parameter.DistanceMap3d.border_condition
# Property of the faceDistance parameter.DistanceMap3d.face_distance
# Property of the edgeDistance parameter.DistanceMap3d.edge_distance
# Property of the cornerDistance parameter.DistanceMap3d.corner_distance
# Property of the outputType parameter.DistanceMap3d.output_type
# Property of the outputMapImage parameter.DistanceMap3d.output_map_image
// Method to launch the command.
execute()
// Command constructor.DistanceMap3d()// Property of the inputBinaryImage parameter.DistanceMap3d.inputBinaryImage
// Property of the mappingMode parameter.DistanceMap3d.mappingMode
// Property of the borderCondition parameter.DistanceMap3d.borderCondition
// Property of the faceDistance parameter.DistanceMap3d.faceDistance
// Property of the edgeDistance parameter.DistanceMap3d.edgeDistance
// Property of the cornerDistance parameter.DistanceMap3d.cornerDistance
// Property of the outputType parameter.DistanceMap3d.outputType
// Property of the outputMapImage parameter.DistanceMap3d.outputMapImage
// Method to launch the command.Execute()
Parameters
Parameter Name
Description
Type
Supported Values
Default Value
inputBinaryImage
The binary input image.
Background is represented by zero values while objects are represented by one values.
Image
Binary
nullptr
mappingMode
The mode defining where the distance field is computed.
INSIDE
Distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain to zero.
OUTSIDE
Distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
Enumeration
INSIDE
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
MIRROR
faceDistance
The distance weight between 2 voxels having a face connection.
The value must be strictly positive.
Float64
>0
1
edgeDistance
The distance weight between 2 voxels having an edge connection.
The value must be greater than or equal to faceDistance.
Float64
Any value
1.41421
cornerDistance
The distance weight between 2 voxels having a corner connection.
The value must be greater than or equal to edgeDistance.
Float64
Any value
1.73205
outputType
The output image type to provide.
SIGNED_INTEGER_16_BIT
The output image type is 16-bit signed integer.
FLOAT_32_BIT
The output image type is 32-bit float.
Enumeration
SIGNED_INTEGER_16_BIT
outputMapImage
The output distance map image.
The distance map of the shape represented by the input image. Each voxel is assigned to a value
corresponding to the distance to the nearest object boundary. Its dimensions are forced to the same values
as the input. Its data type is defined by the outputType parameter.
Image
nullptr
Parameter Name
Description
Type
Supported Values
Default Value
input_binary_image
The binary input image.
Background is represented by zero values while objects are represented by one values.
image
Binary
None
mapping_mode
The mode defining where the distance field is computed.
INSIDE
Distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain to zero.
OUTSIDE
Distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
enumeration
INSIDE
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
MIRROR
face_distance
The distance weight between 2 voxels having a face connection.
The value must be strictly positive.
float64
>0
1
edge_distance
The distance weight between 2 voxels having an edge connection.
The value must be greater than or equal to faceDistance.
float64
Any value
1.41421
corner_distance
The distance weight between 2 voxels having a corner connection.
The value must be greater than or equal to edgeDistance.
float64
Any value
1.73205
output_type
The output image type to provide.
SIGNED_INTEGER_16_BIT
The output image type is 16-bit signed integer.
FLOAT_32_BIT
The output image type is 32-bit float.
enumeration
SIGNED_INTEGER_16_BIT
output_map_image
The output distance map image.
The distance map of the shape represented by the input image. Each voxel is assigned to a value
corresponding to the distance to the nearest object boundary. Its dimensions are forced to the same values
as the input. Its data type is defined by the outputType parameter.
image
None
Parameter Name
Description
Type
Supported Values
Default Value
inputBinaryImage
The binary input image.
Background is represented by zero values while objects are represented by one values.
Image
Binary
null
mappingMode
The mode defining where the distance field is computed.
INSIDE
Distances are computed for voxels inside the objects (having an intensity equal to 1). Outside voxels remain to zero.
OUTSIDE
Distances are computed for voxels outside of objects (having an intensity equal to 0). Inside voxels are set to zero.
Enumeration
INSIDE
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
MIRROR
faceDistance
The distance weight between 2 voxels having a face connection.
The value must be strictly positive.
Float64
>0
1
edgeDistance
The distance weight between 2 voxels having an edge connection.
The value must be greater than or equal to faceDistance.
Float64
Any value
1.41421
cornerDistance
The distance weight between 2 voxels having a corner connection.
The value must be greater than or equal to edgeDistance.
Float64
Any value
1.73205
outputType
The output image type to provide.
SIGNED_INTEGER_16_BIT
The output image type is 16-bit signed integer.
FLOAT_32_BIT
The output image type is 32-bit float.
Enumeration
SIGNED_INTEGER_16_BIT
outputMapImage
The output distance map image.
The distance map of the shape represented by the input image. Each voxel is assigned to a value
corresponding to the distance to the nearest object boundary. Its dimensions are forced to the same values
as the input. Its data type is defined by the outputType parameter.