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) :
Input marker image InLabMarkImg is used to define catchment basins used as seeds for a flooding process.
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 :
- ipsdk::imaproc::attr::eWatershedOutputMode::eWOM_Lines for extraction of watershed separation lines (a binary image)
- ipsdk::imaproc::attr::eWatershedOutputMode::eWOM_Basins for extraction of watershed catchment basins (a label image)
Two processing version (controlled by parameter InOptWatershedProcMode) of this algorithm are provided :
- a fast parallelised version for which two successive executions give two distinct results. Watershed problem has indeed most of time a lot of valid solutions. This parallelised version of watershed algorithm does not grant a repeatable choice of solution. This mode is associated to value ipsdk::imaproc::attr::eWatershedProcessingMode::eWPM_OptimizeSpeed for InOptWatershedProcMode parameter.
- a slower default version which allows repeatable results and which corresponds to ipsdk::imaproc::attr::eWatershedProcessingMode::eWPM_Repeatable value for InOptWatershedProcMode parameter.
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
- extraction of watershed separation lines
- extraction of catchment basins
- 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
inIntImg = PyIPSDK.loadTiffImageFile(inputGreyImgPath)
inLabMarkImg = PyIPSDK.loadTiffImageFile(inputLabelImgPath,
PyIPSDK.eTiffDirectoryMode.eTDM_Temporal,
PyIPSDK.eTiffBufferMode.eTBM_Label)
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
eTiffDirectoryMode::eTDM_Temporal,
eTiffBufferMode::eTBM_Label);