DistanceMap3d
Computes the distance map of objects in a three-dimensional binary image.
Access to parameter description
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:
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.
See also
Access to parameter description
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.
See also
Function Syntax
This function returns outputMapImage.
// Function prototype
std::shared_ptr< iolink::ImageView > distanceMap3d( std::shared_ptr< iolink::ImageView > inputBinaryImage, DistanceMap3d::MappingMode mappingMode, DistanceMap3d::BorderCondition borderCondition, double faceDistance, double edgeDistance, double cornerDistance, DistanceMap3d::OutputType outputType, std::shared_ptr< iolink::ImageView > outputMapImage = NULL );
Class Syntax
Parameters
Class Name | DistanceMap3d |
---|
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.
|
Enumeration | INSIDE | |||||
![]() |
borderCondition |
The mode defining the border conditions.
|
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.
|
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 |
Object Examples
auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" ); DistanceMap3d distanceMap3dAlgo; distanceMap3dAlgo.setInputBinaryImage( foam_sep ); distanceMap3dAlgo.setMappingMode( DistanceMap3d::MappingMode::INSIDE ); distanceMap3dAlgo.setBorderCondition( DistanceMap3d::BorderCondition::MIRROR ); distanceMap3dAlgo.setFaceDistance( 1 ); distanceMap3dAlgo.setEdgeDistance( 1.4142135623730951 ); distanceMap3dAlgo.setCornerDistance( 1.7320508075688772 ); distanceMap3dAlgo.setOutputType( DistanceMap3d::OutputType::SIGNED_INTEGER_16_BIT ); distanceMap3dAlgo.execute(); std::cout << "outputMapImage:" << distanceMap3dAlgo.outputMapImage()->toString();
Function Examples
auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" ); auto result = distanceMap3d( foam_sep, DistanceMap3d::MappingMode::INSIDE, DistanceMap3d::BorderCondition::MIRROR, 1, 1.4142135623730951, 1.7320508075688772, DistanceMap3d::OutputType::SIGNED_INTEGER_16_BIT ); std::cout << "outputMapImage:" << result->toString();