IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

seeded watershed 2d algorithm More...

IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::seededWatershed2dImg (const image::ImageConstPtr &pInIntImg, const image::ImageConstPtr &pInLabMarkImg, const ipsdk::imaproc::attr::eWatershedOutputMode &inWatershedOutputMode)
 wrapper function for seeded watershed 2d algorithm More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::seededWatershed2dImg (const image::ImageConstPtr &pInIntImg, const image::ImageConstPtr &pInLabMarkImg, const ipsdk::imaproc::attr::eWatershedOutputMode &inWatershedOutputMode, const ipsdk::imaproc::attr::eWatershedProcessingMode &inOptWatershedProcMode)
 wrapper function for seeded watershed 2d algorithm More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::seededWatershed2dImg (const image::ImageConstPtr &pInIntImg, const image::ImageConstPtr &pInLabMarkImg, const ipsdk::imaproc::attr::eWatershedOutputMode &inWatershedOutputMode, const ipsdk::imaproc::attr::eWatershedProcessingMode &inOptWatershedProcMode, const ipUInt32 inOptNbMinDataByThread, const image::ImagePtr &pOutBinLabImg)
 wrapper function for seeded watershed 2d algorithm More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InIntImg [Input] image for processing operation (data contained in image buffer are integers) X
ipsdk::imaproc::attr::InLabMarkImg [Input] label marker image for processing operation X
ipsdk::imaproc::attr::InWatershedOutputMode [Input] parameter allowing to define watershed output mode X
ipsdk::imaproc::attr::InOptWatershedProcMode [Input Optional] Watershed processing mode X
ipsdk::imaproc::attr::InOptNbMinDataByThread [Input Optional] minimum number of data by thread X
ipsdk::imaproc::attr::OutOptWk1Img [Output Optional] Temporary working image for algorithm X
ipsdk::imaproc::attr::OutBinLabImg [Output] binary or label image for processing operation customOutput (_pOutBinLabImg, outputWatershed(_pInLabMarkImg,_pInWatershedOutputMode))

Global Rule description

Global rule description for algorithm :
(ipsdk::imaproc::matchSize (_pInIntImg,_pInLabMarkImg) && 
 ipsdk::imaproc::customImageProperty (_pOutBinLabImg,
  allowedBufferType (_pInWatershedOutputMode)) && 
 ipsdk::processor::ifIsSet (_pOutOptWk1Img,
  ipsdk::imaproc::matchSize (_pInIntImg,_pOutOptWk1Img)) && 
 ipsdk::processor::If (
  ipsdk::imaproc::bufferType (_pOutBinLabImg,ipsdk::image::eImageBufferType::eIBT_Binary),
  ipsdk::imaproc::matchSize (_pOutBinLabImg,_pInLabMarkImg),
  ipsdk::imaproc::matchSizeAndType (_pOutBinLabImg,_pInLabMarkImg)))

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

Associated library

IPSDKIPLAdvancedMorphology

Header file

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);
See also
SeededWatershed2dImgLvl1

Function Documentation

◆ seededWatershed2dImg() [1/3]

IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::seededWatershed2dImg ( const image::ImageConstPtr pInIntImg,
const image::ImageConstPtr pInLabMarkImg,
const ipsdk::imaproc::attr::eWatershedOutputMode inWatershedOutputMode 
)

wrapper function for seeded watershed 2d algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ seededWatershed2dImg() [2/3]

IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::seededWatershed2dImg ( const image::ImageConstPtr pInIntImg,
const image::ImageConstPtr pInLabMarkImg,
const ipsdk::imaproc::attr::eWatershedOutputMode inWatershedOutputMode,
const ipsdk::imaproc::attr::eWatershedProcessingMode inOptWatershedProcMode 
)

wrapper function for seeded watershed 2d algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ seededWatershed2dImg() [3/3]

IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::seededWatershed2dImg ( const image::ImageConstPtr pInIntImg,
const image::ImageConstPtr pInLabMarkImg,
const ipsdk::imaproc::attr::eWatershedOutputMode inWatershedOutputMode,
const ipsdk::imaproc::attr::eWatershedProcessingMode inOptWatershedProcMode,
const ipUInt32  inOptNbMinDataByThread,
const image::ImagePtr pOutBinLabImg 
)

wrapper function for seeded watershed 2d algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure