<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmwatershed</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmthin.html"><tt>mmthin</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmhistogram.html"><tt>mmhistogram</tt></a>] </td> <td class="title">Thinning And Thickening</td> </tr> </table> <h1>mmwatershed <br> <span class="subtitle">Watershed detection. </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">y = <span class="fun">mmwatershed</span>( <span class="par">f</span>, <span class="par">Bc</span> = None, <span class="par">LINEREG</span> = "LINES" ) </div> <p>Implemented in <b>Python.</b> </p> <div class="input"> <H3>Input</H3> <div class="H3"> <table class="deflist"> <tbody valign="baseline"> <tr> <td class="term"><span class="par">f</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span> Gray-scale (uint8 or uint16) or binary image. </td> </tr> <tr> <td class="term"><span class="par">Bc</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmSe.html">Structuring Element</a></span><p>( connectivity)</p><p>Default: <code>None</code> (3x3 elementary cross) </p></td> </tr> <tr> <td class="term"><span class="par">LINEREG</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>'LINES' or ' REGIONS'.</p><p>Default: <code>"LINES"</code> </p></td> </tr> </tbody> </table> </div> </div> <div class="output"> <H3>Output</H3> <div class="H3"> <table class="deflist"> <tbody valign="baseline"> <tr> <td class="term"><span class="par">y</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span> Gray-scale (uint8 or uint16) or binary image. </td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> <span class="fun">mmwatershed</span> creates the image <code>y</code> by detecting the domain of the catchment basins of <code>f</code>, according to the connectivity defined by <code>Bc</code>. According to the flag LINEREG <code>y</code> 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. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmreadgray('astablet.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> grad=mmgradm(f)</pre> <pre class="computer"></pre> <pre class="user">>>> w1=mmwatershed(grad,mmsebox())</pre> <pre class="computer"></pre> <pre class="user">>>> w2=mmwatershed(grad,mmsebox(),'REGIONS')</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(grad)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(w1)</pre> <pre class="computer"></pre> <pre class="user">>>> mmlblshow(w2)</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="251" src="../images/img_mmwatershed_001.jpg"></td> <td><img width="251" src="../images/img_mmwatershed_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmwatershed_001.jpg">grad</a></td> <td><a href="../images/img_mmwatershed_002.jpg">w1</a></td> <td class="spare"></td> </tr> </tbody> </table> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="251" src="../images/img_mmwatershed_003.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmwatershed_003.jpg">w2</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="descr"> <H2>Limitations</H2> <div class="H2"> <p> The structuring elements allowed are the elementary cross (4-connected) and the elementary square (8-connected). </p> </div> </div> <div class="sourcecode"> <H2>Source Code</H2> <div class="H2"> <pre class="listing"> 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 </pre> </div> </div> <div class="seealso"> <H2>See also</H2> <div class="H2"> <table class="deflist"> <tbody valign="baseline"> <tr> <td class="term"><a href="../morph/mmcwatershed.html">mmcwatershed</a></td> <td class="def">Detection of watershed from markers.</td> </tr> <tr> <td class="term"><a href="../morph/mmfreedom.html">mmfreedom</a></td> <td class="def">Control automatic data type conversion.</td> </tr> <tr> <td class="term"><a href="../morph/mmsebox.html">mmsebox</a></td> <td class="def">Create a box structuring element.</td> </tr> <tr> <td class="term"><a href="../morph/mmsecross.html">mmsecross</a></td> <td class="def">Diamond structuring element and elementary 3x3 cross.</td> </tr> <tr> <td class="term"><a href="../morph/mmswatershed.html">mmswatershed</a></td> <td class="def">Detection of similarity-based watershed from markers.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmthin.html"><tt>mmthin</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmhistogram.html"><tt>mmhistogram</tt></a>] </td> <td rowspan="2" class="xhtml"><a href="http://www.python.org"><img width="55" alt="Python" height="22" src="../PythonPoweredSmall.gif"></a></td> </tr> <tr> <td class="copyright">Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.</td> </tr> </table> </center> </body> </html>