algorithm, based on watershed, allowing to separate grey 2d shapes
This algorithm, based on watershed algorithm, allows to separate shapes of an input grey image. It is an equivalent of Watershed Binary Separation 2d applied on grey scale images case.
Input grey image InIntImg is classicaly a gradient image since it will be used in place of distance map used in binary case.
- Note
- In the following, images are given for illustration purpose, used input image is classicaly a gradient image.
Given an input grey image InIntImg, algorithm process following steps :
- Dilation of local extrema on input image (see Dilate Local Extrema 2d). This step can be customized using parameter InDilateFactor which allows to merge local extrema and parameter InShapeGreyscaleType which allows to search for light or dark shapes (see below).
- Separation of shapes using watershed algorithm (see Seeded Watershed 2d). This step can be customized using parameters InOptWatershedProcMode and InOptNbMinDataByThread.
Parameter InShapeGreyscaleType allows to select for searched shapes type :
- for light shapes this parameters should take ipsdk::imaproc::attr::eShapeGreyscaleType::eSGT_Light value
- for dark shapes this parameters should take ipsdk::imaproc::attr::eShapeGreyscaleType::eSGT_Dark value
Global output of a algorithm can be customized using parameter InWatershedSeparationMode which can take following values :
- ipsdk::imaproc::attr::eWatershedSeparationMode::eWSM_Split (in this case OutImg has same type as InIntImg). Used split value is equal to minimum or maximum supported value for image, depending on InShapeGreyscaleType value (minimal value for light shapes search and maximal value for dark shapes search).
- ipsdk::imaproc::attr::eWatershedSeparationMode::eWSM_Lines (in this case OutImg is a binary image)
- ipsdk::imaproc::attr::eWatershedSeparationMode::eWSM_Basins (in this case OutImg is a label image)
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho
Code Example
inGreyImg = PyIPSDK.loadTiffImageFile(inputGreyImgPath)
outImg = advmorpho.watershedGreySeparation2dImg(inGreyImg, PyIPSDK.eShapeGreyscaleType.eSGT_Light, 50,
PyIPSDK.eWatershedSeparationMode.eWSM_Split)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/WatershedGreySeparation2dImg/WatershedGreySeparation2dImg.h>
Code Example
ImagePtr pInGreyImg =
loadTiffImageFile(utImagesCommonPath /
"blobs3d_483x348x31_UInt8.tif");