[mmcthin] [Up] [mmskiz] Thinning And Thickening

mmcwatershed
Detection of watershed from markers.

Synopsis

Y = mmcwatershed ( f , g , Bc = NullStrel, LINEREG = "LINES" )

Input

f Image Gray-scale (uint8 or uint16) image

g Image Gray-scale (uint8 or uint16) or binary image

marker image: binary or labeled.

Bc Structuring Element

(watershed connectivity)

Default: NullStrel (3x3 elementary cross)

LINEREG String

Output image: 'LINES' or 'REGIONS'.

Default: "LINES" ('LINES')

Output

Y Image Gray-scale (uint8 or uint16) or binary image

Description

mmcwatershed creates the image y by detecting the domain of the catchment basins of f indicated by the marker image g, 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. To know more about watershed and watershed from markers, see [BM93]. The implementation of this function is based on [LF00].

WARNING: There is a common mistake related to the marker image g. If this image contains only zeros and ones, but it is not a binary image, the result will be an image with all ones. If the marker image is binary, you have to set this explicitly using the logical function.

Examples

a = uint8([\
    [10,   10,   10,   10,   10,   10,   10],\
    [10,    9,    6,   18,    6,    5,   10],\
    [10,    9,    6,   18,    6,    8,   10],\
    [10,    9,    9,   15,    9,    9,   10],\
    [10,    9,    9,   15,   12,   10,   10],\
    [10,   10,   10,   10,   10,   10,   10]])
b = mmcmp(a,'==',uint8(6))
print mmcwatershed(a,b)
[[False False False  True False False False]
 [False False False  True False False False]
 [False False False  True False False False]
 [False False False  True False False False]
 [False False False  True False False False]
 [False False False False  True False False]]
print mmcwatershed(a,b,mmsecross(),'REGIONS')
[[1 1 1 1 2 2 2]
 [1 1 1 1 2 2 2]
 [1 1 1 1 2 2 2]
 [1 1 1 1 2 2 2]
 [1 1 1 1 2 2 2]
 [1 1 1 1 2 2 2]]
f=mmreadgray('astablet.tif')
grad=mmgradm(f)
mark=mmregmin(mmhmin(grad,17))
w=mmcwatershed(grad,mark)
mmshow(grad)
mmshow(mark)
mmshow(w)
grad mark
w

Equation

Equation (watershed regions):
Minimum length of a point to a set:
Length of a point to a set:
Where:
is the path between the point x and subset X under connectivity Bc

See also

mmfreedom Control automatic data type conversion.
mmwatershed Watershed detection.
mmsebox Create a box structuring element.
mmsecross Diamond structuring element and elementary 3x3 cross.
mmswatershed Detection of similarity-based watershed from markers.
mmdcalc Extract the keys of a calculator.
[mmcthin] [Up] [mmskiz]