IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

generic seeded distance map transform of an input binary image according to a seeded image More...

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::image::ImagePtr ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg (const ipsdk::image::ImageConstPtr &pInBinImg, const ipsdk::image::ImageConstPtr &pInBinSeedImg, const ipsdk::imaproc::attr::DistWeight2dConstPtr &pInDistWeight2d)
 wrapper function for generic seeded distance map transform of an input binary image according to a seeded image More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg (const ipsdk::image::ImageConstPtr &pInBinImg, const ipsdk::image::ImageConstPtr &pInBinSeedImg, const ipsdk::imaproc::attr::DistWeight2dConstPtr &pInDistWeight2d, const ipsdk::image::ImagePtr &pOutDistImg)
 wrapper function for generic seeded distance map transform of an input binary image according to a seeded image More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::image::ImagePtr ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg (const ipsdk::image::ImageConstPtr &pInBinImg, const ipsdk::image::ImageConstPtr &pInBinSeedImg, const ipsdk::imaproc::attr::DistWeight2dConstPtr &pInDistWeight2d, const ipsdk::ipReal32 maxDistance)
 wrapper function for generic seeded distance map transform of an input binary image according to a seeded image constrained to a maximum distance propagation More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg (const ipsdk::image::ImageConstPtr &pInBinImg, const ipsdk::image::ImageConstPtr &pInBinSeedImg, const ipsdk::imaproc::attr::DistWeight2dConstPtr &pInDistWeight2d, const ipsdk::ipReal32 maxDistance, const ipsdk::image::ImagePtr &pOutDistImg)
 wrapper function for generic seeded distance map transform of an input binary image according to a seeded image constrained to a maximum distance propagation More...
 

Detailed Description

generic seeded distance map transform of an input binary image according to a seeded image

2d generic seeded distance map algorithm allows to compute the distance to the closest seeded pixel in a region for each pixel of this region, according to given weights stored in a ipsdk::imaproc::attr::DistWeight2d attribute. As in Seeded Distance Map 2d, the region is defined by a binary image with pixel intensities set to 1 and the seeded pixels are defined by a seeded image with pixel intensities set to 1.The weights can be seen as a distance between 2 successive pixels. If the parameter $ maxDistance $ is provided, the propagation is constrained so that it stops when the distance is higher than the $ maxDistance $ value.

The resulting image buffer type must be one of the following :

Output image values are given by :

\[ OutDistImg[x, y] = \left\{ \begin{array}{rl} 0 &\mbox{\text{if } InBinImg[x, y] = 0} \\ 1 &\mbox{\text{if } InBinImg[x, y] \text{is a seeded pixel}} \\ \min\limits_{(x_d, y_d) \in \aleph \wedge InBinImg[x_d, y_d] > 0} {\left( InBinImg[x_d, y_d]+\omega_d \right) } &\mbox{otherwise} \end{array} \right. \]

Where $\aleph$ is the pixel's neighbourhood, $d$ is the set of directions allowed by $\aleph$ and can be lateral (along the x-axis), axial (along the y-axis) or diagonal. $\omega_d$ is the weight corresponding to the direction $d$.

Note
Weights with zero value are not taken into account.

The following figure illustrates the algorithm with a simple example :

genericSeededDistanceMap2dImg_example.png

If, for instance, $\omega_x = 1$, $\omega_y = 1$ and $\omega_{xy} = 0$. The neighbours along the diagonals are not taken into account : it corresponds to a 4-connexity. In this case, the resulting distance will be :

\begin{eqnarray*} OutDistImg[x, y] & = & \min \left( { \left\{ 127 + \omega_y, 127 + \omega_x, 129 + \omega_y \right\} } \right) \\ &=& \min \left( { \left( \left\{ 127 + 1, 127 + 1, 129 + 1 \right\} \right) } \right) \\ &=& 128 \end{eqnarray*}

Here is an example of a 2d generic seeded distance map computation applied to a binary input image with a real result image and with weighting coefficients along the x an y directions set to 1 and the weighting coefficient along the diagonal set to $ \sqrt{2} $ :

genericSeededDistanceMap2dImg.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InBinImg [Input] binary image for processing operation X
ipsdk::imaproc::attr::InBinSeedImg [Input] Seeded binary image X
ipsdk::imaproc::attr::InDistWeight2d [Input] Weighting coefficients for 2d distance calculation X
ipsdk::imaproc::attr::InOptMaxDistance [Input Optional] Maximum distance authorized for the propagation (a value of 0 means no distance restriction) X
ipsdk::imaproc::attr::OutDistImg [Output] distance map image ipsdk::imaproc::duplicateInOut (_pOutDistImg, _pInBinImg, ipsdk::image::eImageBufferType::eIBT_Real32)

Global Rule description

Global rule description for algorithm :
(ipsdk::imaproc::matchSize (_pInBinImg,_pOutDistImg)) && 
(ipsdk::imaproc::matchSize (_pInBinSeedImg,_pOutDistImg))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inSeedsImg = PyIPSDK.loadTiffImageFile(inputSeedsImgPath)
# setting of used distance weights
inDistWeight2d = PyIPSDK.createDistWeight2d(3, 4, 5)
# generic seeded distance map 2d computation
outDistImg = advmorpho.genericSeededDistanceMap2dImg(inImg, inSeedsImg, inDistWeight2d)

Example of C++ code :

Example informations

Associated library

IPSDKIPLAdvancedMorphology

Header file

Code Example

// opening input image
ImagePtr pInBinImg = loadTiffImageFile(inputImgPath);
// opening seed input image
ImagePtr pInSeedImg = loadTiffImageFile(inputSeedImgPath);
// Distance weighting coefficients
DistWeight2dPtr pDistWeight2d = createDistWeight2d(xWeight, yWeight, xyWeight);
// define output image geometry
ImageGeometryPtr pDistGeometry = geometry2d(outputImageBufferType,
pInBinImg->getSizeX(),
pInBinImg->getSizeY());
// creation of output image
boost::shared_ptr<MemoryImage> pOutDistImg(boost::make_shared<MemoryImage>());
pOutDistImg->init(*pDistGeometry);
// compute distance map on input image
genericSeededDistanceMap2dImg(pInBinImg, pInSeedImg, pDistWeight2d, pOutDistImg);
See also
GenericSeededDistanceMap2dImgLvl1
GenericSeededDistanceMap2dImgLvl2

Function Documentation

◆ genericSeededDistanceMap2dImg() [1/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::image::ImagePtr ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg ( const ipsdk::image::ImageConstPtr pInBinImg,
const ipsdk::image::ImageConstPtr pInBinSeedImg,
const ipsdk::imaproc::attr::DistWeight2dConstPtr pInDistWeight2d 
)

wrapper function for generic seeded distance map transform of an input binary image according to a seeded image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ genericSeededDistanceMap2dImg() [2/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::image::ImagePtr ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg ( const ipsdk::image::ImageConstPtr pInBinImg,
const ipsdk::image::ImageConstPtr pInBinSeedImg,
const ipsdk::imaproc::attr::DistWeight2dConstPtr pInDistWeight2d,
const ipsdk::ipReal32  maxDistance 
)

wrapper function for generic seeded distance map transform of an input binary image according to a seeded image constrained to a maximum distance propagation

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ genericSeededDistanceMap2dImg() [3/4]

IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg ( const ipsdk::image::ImageConstPtr pInBinImg,
const ipsdk::image::ImageConstPtr pInBinSeedImg,
const ipsdk::imaproc::attr::DistWeight2dConstPtr pInDistWeight2d,
const ipsdk::image::ImagePtr pOutDistImg 
)

wrapper function for generic seeded distance map transform of an input binary image according to a seeded image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ genericSeededDistanceMap2dImg() [4/4]

IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::genericSeededDistanceMap2dImg ( const ipsdk::image::ImageConstPtr pInBinImg,
const ipsdk::image::ImageConstPtr pInBinSeedImg,
const ipsdk::imaproc::attr::DistWeight2dConstPtr pInDistWeight2d,
const ipsdk::ipReal32  maxDistance,
const ipsdk::image::ImagePtr pOutDistImg 
)

wrapper function for generic seeded distance map transform of an input binary image according to a seeded image constrained to a maximum distance propagation

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure