<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmthin</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmthick.html"><tt>mmthick</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmwatershed.html"><tt>mmwatershed</tt></a>] </td> <td class="title">Thinning And Thickening</td> </tr> </table> <h1>mmthin <br> <span class="subtitle">Image transformation by thinning. </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">y = <span class="fun">mmthin</span>( <span class="par">f</span>, <span class="par">Iab</span> = None, <span class="par">n</span> = -1, <span class="par">theta</span> = 45, <span class="par">DIRECTION</span> = "CLOCKWISE" ) </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> Binary image. </td> </tr> <tr> <td class="term"><span class="par">Iab</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmInterval.html">Interval</a></span><p>Default: <code>None</code> (mmhomothin) </p></td> </tr> <tr> <td class="term"><span class="par">n</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmDouble.html">Double</a></span> Non-negative integer. <p>Number of iterations.</p><p>Default: <code>-1</code> </p></td> </tr> <tr> <td class="term"><span class="par">theta</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmDouble.html">Double</a></span><p>Degrees of rotation: 45, 90, or 180.</p><p>Default: <code>45</code> </p></td> </tr> <tr> <td class="term"><span class="par">DIRECTION</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>'CLOCKWISE' or ' ANTI-CLOCKWISE'</p><p>Default: <code>"CLOCKWISE"</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> Binary image. </td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> <span class="fun">mmthin</span> creates the binary image <code>y</code> by performing a thinning of the binary image <code>f</code>. The number of iterations of the thinning is <code>n</code> and each iteration is performed by subtracting the points that are detect in <code>f</code> by hit-miss operators characterized by rotations of <code>theta</code> of the interval <code>Iab</code>. When <code>n</code> is infinite and the interval is <code><span class="fun">mmhomothin</span></code> (default conditions), <span class="fun">mmthin</span> gives the skeleton by thinning. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmreadgray('scissors.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> f1=mmthin(f)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f,f1) # skeleton</pre> <pre class="computer"></pre> <pre class="user">>>> f2=mmthin(f1,mmendpoints(),15) # prunning 15 pixels</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f,f2) # prunned skeleton</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="320" src="../images/img_mmthin_001.jpg"></td> <td><img width="320" src="../images/img_mmthin_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmthin_001.jpg">f,f1</a></td> <td><a href="../images/img_mmthin_002.jpg">f,f2</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="equation"> <H2>Equation</H2> <div class="H2"> <p> <div class="eqfig"> <img src="../images/eq_mmthin001.png"> </div> </p> </div> </div> <div class="sourcecode"> <H2>Source Code</H2> <div class="H2"> <pre class="listing"> def mmthin(f, Iab=None, n=-1, theta=45, DIRECTION="CLOCKWISE"): from Numeric import product from string import upper if Iab is None: Iab = mmhomothin() DIRECTION = upper(DIRECTION) assert mmisbinary(f),'f must be binary image' if n == -1: n = product(f.shape) y = f zero = mmintersec(f,0) for i in range(n): aux = zero for t in range(0,360,theta): sup = mmsupgen( y, mminterot(Iab, t, DIRECTION)) aux = mmunion( aux, sup) y = mmsubm( y, sup) if mmisequal(aux,zero): break 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/mmfreedom.html">mmfreedom</a></td> <td class="def">Control automatic data type conversion.</td> </tr> <tr> <td class="term"><a href="../morph/mmcthin.html">mmcthin</a></td> <td class="def">Image transformation by conditional thinning.</td> </tr> <tr> <td class="term"><a href="../morph/mmthick.html">mmthick</a></td> <td class="def">Image transformation by thickening.</td> </tr> <tr> <td class="term"><a href="../morph/mmendpoints.html">mmendpoints</a></td> <td class="def">Interval to detect end-points.</td> </tr> <tr> <td class="term"><a href="../morph/mmhomothin.html">mmhomothin</a></td> <td class="def">Interval for homotopic thinning.</td> </tr> <tr> <td class="term"><a href="../morph/mmse2hmt.html">mmse2hmt</a></td> <td class="def">Create a Hit-or-Miss Template (or interval) from a pair of structuring elements.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmthick.html"><tt>mmthick</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmwatershed.html"><tt>mmwatershed</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>