[mmthin] [Up] [mmhistogram] Thinning And Thickening

mmwatershed
Watershed detection.

Synopsis

y = mmwatershed( f, Bc = None, LINEREG = "LINES" )

Implemented in Python.

Input

f Image Gray-scale (uint8 or uint16) or binary image.
Bc Structuring Element

( connectivity)

Default: None (3x3 elementary cross)

LINEREG String

'LINES' or ' REGIONS'.

Default: "LINES"

Output

y Image Gray-scale (uint8 or uint16) or binary image.

Description

mmwatershed creates the image y by detecting the domain of the catchment basins of f, according to the connectivity defined by Bc. According to the flag LINEREG y will be a labeled image of the catchment basins domain or just a binary image that presents the watershed lines. The implementation of this function is based on VincSoil:91.

Examples

>>> f=mmreadgray('astablet.tif')

              
>>> grad=mmgradm(f)

              
>>> w1=mmwatershed(grad,mmsebox())

              
>>> w2=mmwatershed(grad,mmsebox(),'REGIONS')

              
>>> mmshow(grad)

              
>>> mmshow(w1)

              
>>> mmlblshow(w2)

            
grad w1
w2

Limitations

The structuring elements allowed are the elementary cross (4-connected) and the elementary square (8-connected).

Source Code

def mmwatershed(f, Bc=None, LINEREG="LINES"):
    from string import upper
    if Bc is None: Bc = mmsecross()
    return mmcwatershed(f,mmregmin(f,Bc),upper(LINEREG))
    return y
    

See also

mmcwatershed Detection of watershed from markers.
mmfreedom Control automatic data type conversion.
mmsebox Create a box structuring element.
mmsecross Diamond structuring element and elementary 3x3 cross.
mmswatershed Detection of similarity-based watershed from markers.
[mmthin] [Up] [mmhistogram] Python