SMIL  1.0.4
Watershed Segmentation

Image segmentation - Watershed More...

Detailed Description

Image segmentation - Watershed

In the study of image processing, a watershed is a transformation defined on a grayscale image. The name refers metaphorically to a geological watershed, or drainage divide, which separates adjacent drainage basins. The watershed transformation treats the image it operates upon like a topographic map, with the brightness of each point representing its height, and finds the lines that run along the tops of ridges.

See also
Watershed - Image segmentation
+ Collaboration diagram for Watershed Segmentation:

Functions

template<class T , class labelT >
RES_T basins (const Image< T > &imIn, const Image< labelT > &imMarkers, Image< labelT > &imBasinsOut, const StrElt &se=DEFAULT_SE)
 Constrained basins. More...
 
template<class T , class labelT >
RES_T watershed (const Image< T > &imIn, const Image< labelT > &imMarkers, Image< T > &imOut, Image< labelT > &imBasinsOut, const StrElt &se=DEFAULT_SE)
 Constrained watershed. More...
 
template<class T >
RES_T lblSkiz (Image< T > &labelIm1, Image< T > &labelIm2, const Image< T > &maskIm, const StrElt &se=DEFAULT_SE)
 Skiz on label image. More...
 
template<class T1 , class T2 >
RES_T inflBasins (const Image< T1 > &imIn, Image< T2 > &basinsOut, const StrElt &se=DEFAULT_SE)
 Influences basins. More...
 
template<class T >
RES_T inflZones (const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
 Influences zones. More...
 
template<class T >
RES_T waterfall (const Image< T > &gradIn, const Image< T > &wsIn, Image< T > &imGradOut, Image< T > &imWsOut, const StrElt &se=DEFAULT_SE)
 Waterfall.
 
template<class T >
RES_T waterfall (const Image< T > &gradIn, UINT nLevel, Image< T > &imWsOut, const StrElt &se=DEFAULT_SE)
 Waterfall.
 

Function Documentation

◆ basins()

RES_T smil::basins ( const Image< T > &  imIn,
const Image< labelT > &  imMarkers,
Image< labelT > &  imBasinsOut,
const StrElt se = DEFAULT_SE 
)

Constrained basins.

Hierachical queue based algorithm as described by S. Beucher (2011) [1]

Parameters
[in]imInInput image.
[in]imMarkersLabel image containing the markers.
[out]imBasinsOut(optional) Output image containing the basins.
[in]seStructuring element After processing, this image will contain the basins with the same label values as the initial markers.

Example

from smilPython import *
# Load an image
imIn = Image("https://smil.cmm.minesparis.psl.eu/images/DNA_small.png")
imIn.show()
# Create a gradient image
imGrad = Image(imIn)
gradient(imIn, imGrad)
# Manually impose markers on image
imMark = Image(imIn, "UINT16")
imMark << 0
# One for the background...
imMark.setPixel(75, 40, 1)
# and one on two connected particules
imMark.setPixel(78, 86, 2)
imMark.setPixel(88, 76, 3)
# Dilate the markers to avoid to be blocked in a minimum
dilate(imMark, imMark, 2)
#imMark.showLabel()
# Create the watershed
imWS = Image(imIn)
watershed(imGrad, imMark, imWS)
# Display output
imWS.show()
# Display the output as overlay on the original image
imIn.getViewer().drawOverlay(imWS & 1)
RES_T drawOverlay(const Image< T > &imToDraw, Image< T > &imOut)
Draw overlay.
Definition: DImage.hpp:516
RES_T dilate(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE, const T borderVal=ImDtTypes< T >::min())
dilate() - Morphological grayscale dilation
Definition: DMorphoBase.hpp:65
RES_T gradient(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
gradient() - Morphological gradient
Definition: DMorphoResidues.hpp:62
RES_T watershed(const Image< T > &imIn, const Image< labelT > &imMarkers, Image< T > &imOut, Image< labelT > &imBasinsOut, const StrElt &se=DEFAULT_SE)
Constrained watershed.
Definition: DMorphoWatershed.hpp:402

◆ watershed()

RES_T smil::watershed ( const Image< T > &  imIn,
const Image< labelT > &  imMarkers,
Image< T > &  imOut,
Image< labelT > &  imBasinsOut,
const StrElt se = DEFAULT_SE 
)

Constrained watershed.

Hierachical queue based algorithm as described by S. Beucher (2011) [1]

Parameters
[in]imInInput image.
[in]imMarkersLabel image containing the markers.
[in]seStructuring element
[out]imOutOutput image containing the watershed lines.
[out]imBasinsOut(optional) Output image containing the basins. After processing, this image will contain the basins with the same label values as the initial markers.

Example

from smilPython import *
# Load an image
imIn = Image("https://smil.cmm.minesparis.psl.eu/images/DNA_small.png")
imIn.show()
# Create a gradient image
imGrad = Image(imIn)
gradient(imIn, imGrad)
# Manually impose markers on image
imMark = Image(imIn, "UINT16")
imMark << 0
# One for the background...
imMark.setPixel(75, 40, 1)
# and one on two connected particules
imMark.setPixel(78, 86, 2)
imMark.setPixel(88, 76, 3)
# Dilate the markers to avoid to be blocked in a minimum
dilate(imMark, imMark, 2)
#imMark.showLabel()
# Create the watershed
imWS = Image(imIn)
watershed(imGrad, imMark, imWS)
# Display output
imWS.show()
# Display the output as overlay on the original image
imIn.getViewer().drawOverlay(imWS & 1)

◆ lblSkiz()

RES_T smil::lblSkiz ( Image< T > &  labelIm1,
Image< T > &  labelIm2,
const Image< T > &  maskIm,
const StrElt se = DEFAULT_SE 
)

Skiz on label image.

Performs the influence zones on a label image as described by S. Beucher (2011) [3] If a maskIm is provided, the skiz is geodesic.

◆ inflBasins()

RES_T smil::inflBasins ( const Image< T1 > &  imIn,
Image< T2 > &  basinsOut,
const StrElt se = DEFAULT_SE 
)

Influences basins.

Performs the influence basins using the lblSkiz function. Input image is supposed to be binary.

◆ inflZones()

RES_T smil::inflZones ( const Image< T > &  imIn,
Image< T > &  imOut,
const StrElt se = DEFAULT_SE 
)

Influences zones.

Performs the influence zones using the lblSkiz function. Input image is supposed to be binary.