Sophie

Sophie

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

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

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>mmgdist</title>
    <link href="../tbxdok.css" rel="stylesheet">
  </head>
  <body>
    <table class="topNav">
      <tr>
        <td class="index">
                  [<a href="../morph/mmdist.html"><tt>mmdist</tt></a>]
              
                  [<a href="index.html">Up</a>]
                  
                  [<a href="../morph/mmopentransf.html"><tt>mmopentransf</tt></a>]
              </td>
        <td class="title">Image Transforms</td>
      </tr>
    </table>
    <h1>mmgdist
      <br>
      <span class="subtitle">Geodesic Distance Transform.
</span>
    </h1>
    <div class="synopsis">
      <H2>Synopsis</H2>
      <div class="H2">
        <div class="prototype">y = 
          <span class="fun">mmgdist</span>(
                  
          <span class="par">f</span>, 
          <span class="par">g</span>, 
          <span class="par">Bc</span> = None, 
          <span class="par">METRIC</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>          Binary image.
                        </td>
                </tr>
                <tr>
                  <td class="term"><span class="par">g</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span>          Binary image.
                          <p>Marker image</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>(metric for distance).</p><p>Default: 
                      <code>None</code> (3x3 elementary cross)
                    </p></td>
                </tr>
                <tr>
                  <td class="term"><span class="par">METRIC</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>'EUCLIDEAN' if specified.</p><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">y</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span><p>uint16 (distance image).</p></td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="descr">
      <H2>Description</H2>
      <div class="H2">
        <p>
          <span class="fun">mmgdist</span> creates the geodesic distance image 
          <code>y</code> of the binary image 
          <code>f</code> relative to the binary image 
          <code>g</code>.  The value of 
          <code>y</code> at the pixel 
          <code>x</code> is the length of the smallest path between 
          <code>x</code> and 
          <code>f</code>. The distances available are based  on the Euclidean metrics  and on metrics generated by a neighbourhood graph,  that is characterized by a connectivity rule defined by the structuring element 
          <code>Bc</code>.   The  connectivity for defining the paths is consistent with the metrics adopted to measure their length.   In the case of the Euclidean distance, the space is considered continuos and, in the other cases, the connectivity is the one defined by 
          <code>Bc</code>.
                  
        </p>
      </div>
    </div>
    <div class="examples">
      <H2>Examples</H2>
      <div class="H2">
        <p>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; f=mmbinary([
 [1,1,1,1,1,1],
 [1,1,1,0,0,1],
 [1,0,1,0,0,1],
 [1,0,1,1,0,0],
 [0,0,1,1,1,1],
 [0,0,0,1,1,1]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; g=mmbinary([
 [0,0,0,0,0,0],
 [1,1,0,0,0,0],
 [0,0,0,0,0,0],
 [0,0,0,0,0,0],
 [0,0,0,0,0,0],
 [0,0,0,0,0,1]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; y=mmgdist(f,g,mmsecross())</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print y</pre>
              <pre class="computer">[[    1     1     2     3     4     5]
 [    0     0     1 65535 65535     6]
 [    1 65535     2 65535 65535     7]
 [    2 65535     3     4 65535 65535]
 [65535 65535     4     3     2     1]
 [65535 65535 65535     2     1     0]]</pre>
            </div>
          </div>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; f=mmreadgray('maze_bw.tif')</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; g=mmintersec(f,0)</pre>
              <pre class="computer">Warning: Converting input image from int32 to binary uint8.</pre>
              <pre class="user">&gt;&gt;&gt; g=mmdrawv(g,uint16([[2],[2],[6],[6]]),uint16(1),'frect')</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; y=mmgdist(f,g,mmsebox(),'EUCLIDEAN')</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; mmshow(f,g)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; mmdtshow(y,200)</pre>
              <pre class="computer"></pre>
            </div>
            <table class="images">
              <tbody align="center">
                <tr class="image" valign="bottom">
                  <td><img width="176" src="../images/img_mmgdist_001.jpg"></td>
                  <td><img width="176" src="../images/img_mmgdist_002.jpg"></td>
                  <td class="spare"></td>
                </tr>
                <tr class="title" valign="baseline">
                  <td><a href="../images/img_mmgdist_001.jpg">f,g</a></td>
                  <td><a href="../images/img_mmgdist_002.jpg">y,200</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">geodesic distance function using structuring element:</div>
          <div class="eqfig">
            <img src="../images/eq_mmgdist001.png">
          </div>
        </p>
      </div>
    </div>
    <div class="descr">
      <H2>Limitations</H2>
      <div class="H2">
        <p>
                      To generate useful Distance transforms, the structuring elements must be symmetric and with the origin included.
          The Euclidean Distance transform is rounded to the nearest integer, since it is represented in an unsigned integer image. You should use the 
          <code><span class="fun">mmsebox</span></code> structuring element when computing the Euclidean Distance transform.
                  
        </p>
      </div>
    </div>
    <div class="sourcecode">
      <H2>Source Code</H2>
      <div class="H2">
        <pre class="listing">
def mmgdist(f, g, Bc=None, METRIC=None):
    if Bc is None: Bc = mmsecross()
    assert METRIC is None,'Does not support EUCLIDEAN'
    fneg,gneg = mmneg(f),mmneg(g)
    y = mmgray(gneg,'uint16',1)
    ero = mmintersec(y,0)
    aux = y
    i = 1
    while not mmisequal(ero,aux):
        aux = ero
        ero = mmcero(gneg,fneg,Bc,i)
        y = mmaddm(y,mmgray(ero,'uint16',1))
        i = i + 1
    y = mmunion(y,mmgray(ero,'uint16'))
    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/mmdist.html">mmdist</a></td>
              <td class="def">Distance transform.</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/mmsebox.html">mmsebox</a></td>
              <td class="def">Create a box structuring element.</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/mmcero.html">mmcero</a></td>
              <td class="def">Erode an image conditionally.</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <center>
      <table class="botNav">
        <tr>
          <td class="index">
                    [<a href="../morph/mmdist.html"><tt>mmdist</tt></a>]
                
                    [<a href="index.html">Up</a>]
                    
                    [<a href="../morph/mmopentransf.html"><tt>mmopentransf</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>