<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmero</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmdil.html"><tt>mmdil</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmcenter.html"><tt>mmcenter</tt></a>] </td> <td class="title">Dilations And Erosions</td> </tr> </table> <h1>mmero <br> <span class="subtitle">Erode an image by a structuring element. </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">y = <span class="fun">mmero</span>( <span class="par">f</span>, <span class="par">b</span> = None ) </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">b</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmSe.html">Structuring Element</a></span><p>Default: <code>None</code> (3x3 elementary cross) </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></td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> <span class="fun">mmero</span> performs the erosion of the image <code>f</code> by the structuring element <code>b</code>. Erosion is a neighbourhood operator that compairs locally <code>b</code> with <code>f</code>, according to an inclusion rule. Since erosion is a fundamental operator to the construction of all other morphological operators, it is also called an elementary operator of Mathematical Morphology. When <code>f</code> is a gray-scale image , <code>b</code> may be a flat or non-flat structuring element. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="bridge">Numerical examples</div> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmbinary([ [1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0]])</pre> <pre class="computer"></pre> <pre class="user">>>> b=mmbinary([1, 1, 0])</pre> <pre class="computer"></pre> <pre class="user">>>> mmero(f,b)</pre> <pre class="computer">array([[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]],'1')</pre> <pre class="user">>>> f=uint8([ [ 0, 1, 2, 50, 4, 5], [ 2, 3, 4, 0, 0, 0], [12, 255, 14, 15, 16, 17]])</pre> <pre class="computer"></pre> <pre class="user">>>> mmero(f,b)</pre> <pre class="computer">array([[ 0, 0, 1, 2, 4, 4], [ 2, 2, 3, 0, 0, 0], [12, 12, 14, 14, 15, 16]],'b')</pre> </div> </div> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmbinary(mmreadgray('blob.tif'))</pre> <pre class="computer"></pre> <pre class="user">>>> bimg=mmbinary(mmreadgray('blob1.tif'))</pre> <pre class="computer"></pre> <pre class="user">>>> b=mmimg2se(bimg)</pre> <pre class="computer"></pre> <pre class="user">>>> g=mmero(f,b)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(g)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(g,mmgradm(f))</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="239" src="../images/img_mmero_001.jpg"></td> <td><img width="239" src="../images/img_mmero_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmero_001.jpg">f</a></td> <td><a href="../images/img_mmero_002.jpg">g</a></td> <td class="spare"></td> </tr> </tbody> </table> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="239" src="../images/img_mmero_003.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmero_003.jpg">g,mmgradm(f)</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> <div class="bridge">Gray-scale image:</div> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmreadgray('pcb_gray.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> b=mmsedisk(3)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(mmero(f,b))</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="256" src="../images/img_mmero_004.jpg"></td> <td><img width="256" src="../images/img_mmero_005.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmero_004.jpg">f</a></td> <td><a href="../images/img_mmero_005.jpg">mmero(f,b)</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="bridge">Flat structuring element:</div> <div class="eqfig"> <img src="../images/eq_mmero001.png"> </div> <div class="bridge">Non-flat structuring element:</div> <div class="eqfig"> <img src="../images/eq_mmero002.png"> </div>Where <div class="eqfig"> <img src="../images/eq_mmero003.png"> </div> </p> </div> </div> <div class="sourcecode"> <H2>Source Code</H2> <div class="H2"> <pre class="listing"> def mmero(f, b=None): if b is None: b = mmsecross() y = mmneg(mmdil(mmneg(f),mmsereflect(b))) 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/mmdil.html">mmdil</a></td> <td class="def">Dilate an image by a structuring element.</td> </tr> <tr> <td class="term"><a href="../morph/mmimg2se.html">mmimg2se</a></td> <td class="def">Create a structuring element from a pair of images.</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/mmcero.html">mmcero</a></td> <td class="def">Erode an image conditionally.</td> </tr> <tr> <td class="term"><a href="../morph/mmdist.html">mmdist</a></td> <td class="def">Distance transform.</td> </tr> <tr> <td class="term"><a href="../morph/mmsesum.html">mmsesum</a></td> <td class="def">N-1 iterative Minkowski additions</td> </tr> </tbody> </table> </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/mmdil.html">mmdil</a></td> <td class="def">Dilate an image by a 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/mmcero.html">mmcero</a></td> <td class="def">Erode an image conditionally.</td> </tr> <tr> <td class="term"><a href="../morph/mmdist.html">mmdist</a></td> <td class="def">Distance transform.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmdil.html"><tt>mmdil</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmcenter.html"><tt>mmcenter</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>