IPSDK 4.1.0.2
IPSDK : Image Processing Software Development Kit
Seeded Watershed 2d
imageseededWatershed2dImg (inIntImg,inLabMarkImg,inWatershedOutputMode)
imageseededWatershed2dImg (inIntImg,inLabMarkImg,inWatershedOutputMode,inOptWatershedProcMode)

Detailed Description

seeded watershed 2d algorithm

Watershed algorithm allows to partition an input grey image InIntImg, associated to a marker image InLabMarkImg, into area of influence. This is a classical technic used for segmentation purposes.

Input grey image InIntImg (classically a gradient image) pixels intensity are considered has an elevation map (crests and catchment basins) :

seededWatershed2dImgElevationMap.png

Input marker image InLabMarkImg is used to define catchment basins used as seeds for a flooding process.

seededWatershed2dImgInput.png

An iterative flooding process is then started from water sources defined by seeds until entire image flood. Areas of influence are then defined by meet of different water sources.

Algorithm output is controlled by parameter InWatershedOutputMode which can take following values :

Two processing version (controlled by parameter InOptWatershedProcMode) of this algorithm are provided :

Parameter InOptNbMinDataByThread controls minimal number of data for each processing threads during flooding step and should only be use in expert mode.

Here is an example of watershed 2d algorithm applied to an unsigned char gradient input image associated to label image of seeds

Note
this algorithm has been packaged for easy separation in classical cases, see :
Warning
This algorithm will not be distributed, flooding processing computation and memory are proceeded on local computer.
See also
https://en.wikipedia.org/wiki/Watershed_%28image_processing%29

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho

Code Example

# opening of input images
inIntImg = PyIPSDK.loadTiffImageFile(inputGreyImgPath)
inLabMarkImg = PyIPSDK.loadTiffImageFile(inputLabelImgPath,
PyIPSDK.eTiffDirectoryMode.eTDM_Temporal,
PyIPSDK.eTiffBufferMode.eTBM_Label)
# process seeded watershed (watershed lines extraction mode)
outImg = advmorpho.seededWatershed2dImg(inIntImg, inLabMarkImg,
PyIPSDK.eWatershedOutputMode.eWOM_Lines)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/SeededWatershed2dImg/SeededWatershed2dImg.h>

Code Example

// opening of input grey image
ImagePtr pInIntImg = loadTiffImageFile(inputGreyImgPath);
// opening of input label seeds image
ImagePtr pInLabMarkImg = loadTiffImageFile(inputLabelImgPath,
eTiffDirectoryMode::eTDM_Temporal,
eTiffBufferMode::eTBM_Label);
// process seeded watershed (watershed lines extraction mode)
ImagePtr pOutImg = seededWatershed2dImg(pInIntImg, pInLabMarkImg, eWatershedOutputMode::eWOM_Lines);