Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4a71d9984febeb5a206904a5a379841a > files > 698

python-morph-0.8-7mdv2010.0.noarch.rpm

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>mmimg2se</title>
    <link href="../tbxdok.css" rel="stylesheet">
  </head>
  <body>
    <table class="topNav">
      <tr>
        <td class="index">
                  [<a href="../morph/mmunion.html"><tt>mmunion</tt></a>]
              
                  [<a href="index.html">Up</a>]
                  
                  [<a href="../morph/mmsebox.html"><tt>mmsebox</tt></a>]
              </td>
        <td class="title">Structuring Elements</td>
      </tr>
    </table>
    <h1>mmimg2se
      <br>
      <span class="subtitle">Create a structuring element from a pair of images.
</span>
    </h1>
    <div class="synopsis">
      <H2>Synopsis</H2>
      <div class="H2">
        <div class="prototype">B = 
          <span class="fun">mmimg2se</span>(
                  
          <span class="par">fd</span>, 
          <span class="par">FLAT</span> = "FLAT", 
          <span class="par">f</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">fd</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span>          Binary image.
                          <p>The image is in the matrix format where the origin (0,0) is at the matrix center.</p></td>
                </tr>
                <tr>
                  <td class="term"><span class="par">FLAT</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>'FLAT' or 'NON-FLAT'.</p><p>Default: 
                      <code>"FLAT"</code>
                    </p></td>
                </tr>
                <tr>
                  <td class="term"><span class="par">f</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span>          Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image.
                                <p>Default: 
                      <code>None</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">B</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmSe.html">Structuring Element</a></span></td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="descr">
      <H2>Description</H2>
      <div class="H2">
        <p>
          <span class="fun">mmimg2se</span> creates a flat structuring element 
          <code>B</code> from the binary image 
          <code>fd</code> or creates a non-flat structuring element 
          <code>b</code> from the binary image 
          <code>fd</code> and the gray-scale image 
          <code>f</code>. 
          <code>fd</code> represents the domain of 
          <code>b</code> and 
          <code>f</code> represents the image of the points  in 
          <code>fd</code>.
                  
        </p>
      </div>
    </div>
    <div class="examples">
      <H2>Examples</H2>
      <div class="H2">
        <p>
                          Let us apply 
          <span class="fun">mmimg2se</span> to create structuring elements. In the example below, the flat 3x3 diamond is created.

          <br>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; a = mmimg2se(mmbinary([
  [0,1,0],
  [1,1,1],
  [0,1,0]]))</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print mmseshow(a)</pre>
              <pre class="computer">[[0 1 0]
 [1 1 1]
 [0 1 0]]</pre>
            </div>
          </div>
          <br>In this next example, the image sizes are even. Note the origin of the
          structuring element.

          <br>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; b = mmbinary([
  [0,1,1,1],
  [1,1,1,0]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; b1 = mmimg2se(b)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print mmseshow(b1)</pre>
              <pre class="computer">[[0 0 0 0 0]
 [0 0 1 1 1]
 [0 1 1 1 0]]</pre>
            </div>
          </div>In the example below,  a non-flat diamond is created.

          <br>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; c = mmbinary([
  [0,1,0],
  [1,1,1],
  [0,1,0]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; d = int32([
  [0,0,0],
  [0,1,0],
  [0,0,0]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; e = mmimg2se(c,'NON-FLAT',d)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print mmseshow(e)</pre>
              <pre class="computer">[[-2147483647           0 -2147483647]
 [          0           1           0]
 [-2147483647           0 -2147483647]]</pre>
            </div>
          </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_mmimg2se001.png">
          </div>
          <div class="bridge">Non-flat structuring element:</div>
          <div class="eqfig">
            <img src="../images/eq_mmimg2se002.png">
          </div>H and W are the number of rows and columns of f, respectively.
                      
        </p>
      </div>
    </div>
    <div class="sourcecode">
      <H2>Source Code</H2>
      <div class="H2">
        <pre class="listing">
def mmimg2se(fd, FLAT="FLAT", f=None):
    from string import upper
    from Numeric import choose, ones
    assert mmisbinary(fd),'First parameter must be binary'
    FLAT = upper(FLAT)
    if FLAT == 'FLAT':
        return mmseshow(fd)
    else:
        B = choose(fd, (mmlimits(int32([0]))[0]*ones(fd.shape),f) )
    B = mmseshow(int32(B),'NON-FLAT')
    return B
    </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/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/mmsedisk.html">mmsedisk</a></td>
              <td class="def">Create a disk or a semi-sphere structuring element.</td>
            </tr>
            <tr>
              <td class="term"><a href="../morph/mmseline.html">mmseline</a></td>
              <td class="def">Create a line structuring element.</td>
            </tr>
            <tr>
              <td class="term"><a href="../morph/mmseshow.html">mmseshow</a></td>
              <td class="def">Display a structuring element as an image.</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>
          </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/mmsecross.html">mmsecross</a></td>
              <td class="def">Diamond structuring element and elementary 3x3 cross.</td>
            </tr>
            <tr>
              <td class="term"><a href="../morph/mmseshow.html">mmseshow</a></td>
              <td class="def">Display a structuring element as an image.</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/mmmat2set.html">mmmat2set</a></td>
              <td class="def">Converts image representation from matrix to set</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <center>
      <table class="botNav">
        <tr>
          <td class="index">
                    [<a href="../morph/mmunion.html"><tt>mmunion</tt></a>]
                
                    [<a href="index.html">Up</a>]
                    
                    [<a href="../morph/mmsebox.html"><tt>mmsebox</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>