<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmasfrec</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmareaopen.html"><tt>mmareaopen</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmcloserec.html"><tt>mmcloserec</tt></a>] </td> <td class="title">Connected Operators</td> </tr> </table> <h1>mmasfrec <br> <span class="subtitle">Reconstructive Alternating Sequential Filtering </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">y = <span class="fun">mmasfrec</span>( <span class="par">f</span>, <span class="par">SEQ</span> = "OC", <span class="par">b</span> = None, <span class="par">bc</span> = None, <span class="par">n</span> = 1 ) </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">SEQ</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>Values: "OC" or "CO".</p><p>Default: <code>"OC"</code> </p></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> <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>Default: <code>None</code> (3x3 elementary cross) </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> </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><p>Same type of <code>f</code> </p></td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> <code><span class="fun">mmasf</span></code> creates the image <code>y</code> by filtering the image <code>f</code> by <code>n</code> iterations of the close by reconstruction and open by reconstruction alternating sequential filter characterized by the structuring element <code>b</code>. The structure element <code>bc</code> is used in the reconstruction. The sequence of opening and closing is controlled by the parameter <code>SEQ</code>. 'OC' performs opening after closing, and 'CO' performs closing after opening. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="example"> <div class="listing"> <pre class="user">>>> f=mmreadgray('fabric.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> g=mmasfrec(f,'oc',mmsecross(),mmsecross(),3)</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> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="273" src="../images/img_mmasfrec_001.jpg"></td> <td><img width="273" src="../images/img_mmasfrec_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmasfrec_001.jpg">f</a></td> <td><a href="../images/img_mmasfrec_002.jpg">g</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">Case oc, reconstructive close-open filter:</div> <div class="eqfig"> <img src="../images/eq_mmasfrec001.png"> </div> <div class="bridge">Case co, reconstructive open-close filter:</div> <div class="eqfig"> <img src="../images/eq_mmasfrec002.png"> </div> </p> </div> </div> <div class="sourcecode"> <H2>Source Code</H2> <div class="H2"> <pre class="listing"> def mmasfrec(f, SEQ="OC", b=None, bc=None, n=1): from string import upper if b is None: b = mmsecross() if bc is None: bc = mmsecross() SEQ = upper(SEQ) y = f if SEQ == 'OC': for i in range(1,n+1): nb = mmsesum(b,i) y = mmcloserec(y,nb,bc) y = mmopenrec(y,nb,bc) elif SEQ == 'CO': for i in range(1,n+1): nb = mmsesum(b,i) y = mmopenrec(y,nb,bc) y = mmcloserec(y,nb,bc) else: assert 0,'Only accepts OC or CO for SEQ parameter' 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/mmasf.html">mmasf</a></td> <td class="def">Alternating Sequential Filtering</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/mmopenrec.html">mmopenrec</a></td> <td class="def">Opening by reconstruction.</td> </tr> <tr> <td class="term"><a href="../morph/mmcloserec.html">mmcloserec</a></td> <td class="def">Closing by reconstruction.</td> </tr> <tr> <td class="term"><a href="../morph/mmfreedom.html">mmfreedom</a></td> <td class="def">Control automatic data type conversion.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmareaopen.html"><tt>mmareaopen</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmcloserec.html"><tt>mmcloserec</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>