image = | distanceMap3dImg (inBinImg3d) |
image = | distanceMap3dImg (inBinImg3d,maxDistance) |
Algorithm for distance map transform computation of an input binary 3d image.
Distance map algorithm, also called distance transform, allows to compute exact euclidian distance for each set pixel (with intensity set to 1) to the nearest boundary (nearest zero pixel) in a binary image. If the parameter
is provided, the propagation is constrained so that it stops when the distance is higher than the
value.
Resulting image buffer type must be one of the following :
- ipsdk::image::eImageBufferType::eIBT_UInt16
- ipsdk::image::eImageBufferType::eIBT_UInt32
- ipsdk::image::eImageBufferType::eIBT_Real32
Output image values are given by :
where
stands for euclidian norm :
Here is an example of a distance map 3d computation applied to a binary input image with an unsigned int 16 result image :
- Note
- A real 32 image can be used as output to avoid distance rounding approximation associated to integer output data type.
- See also
- http://en.wikipedia.org/wiki/Distance_transform
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = morpho.distanceMap3dImg(inImg)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBasicMorphology/Processor/DistanceMap3dImg/DistanceMap3dImg.h>
Code Example
pInBinImg->getSizeX(),
pInBinImg->getSizeY(),
pInBinImg->getSizeZ());
boost::shared_ptr<MemoryImage> pOutDistImg(boost::make_shared<MemoryImage>());
pOutDistImg->init(*pGeometry);
distanceMap3dImg(pInBinImg, pOutDistImg);