Sophie

Sophie

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

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

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>mmmat2set</title>
    <link href="../tbxdok.css" rel="stylesheet">
  </head>
  <body>
    <table class="topNav">
      <tr>
        <td class="index">
                  [<a href="../morph/mmdatatype.html"><tt>mmdatatype</tt></a>]
              
                  [<a href="index.html">Up</a>]
                  
                  [<a href="../morph/mmset2mat.html"><tt>mmset2mat</tt></a>]
              </td>
        <td class="title">Image Information and Manipulation</td>
      </tr>
    </table>
    <h1>mmmat2set
      <br>
      <span class="subtitle">Converts image representation from matrix to set
</span>
    </h1>
    <div class="synopsis">
      <H2>Synopsis</H2>
      <div class="H2">
        <div class="prototype">CV = 
          <span class="fun">mmmat2set</span>(
                  
          <span class="par">A</span>
                  )
        </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">A</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span><p>Image in matrix format, where the origin (0,0) is at the center of the matrix.</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">CV</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span><p>Tuple with array of pixel coordinates and array of corresponding pixel values</p></td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="descr">
      <H2>Description</H2>
      <div class="H2">
        <p>
                      Return tuple with array of pixel coordinates and array of corresponding pixel values. The input image is in the matrix format, like the structuring element, where the origin (0,0) is at the center of the matrix.
                  
        </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=uint8([[1,2,3],[4,5,6],[7,8,9]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; i,v=mmmat2set(f)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print i</pre>
              <pre class="computer">[[-1 -1]
 [-1  0]
 [-1  1]
 [ 0 -1]
 [ 0  0]
 [ 0  1]
 [ 1 -1]
 [ 1  0]
 [ 1  1]]</pre>
              <pre class="user">&gt;&gt;&gt; print v</pre>
              <pre class="computer">[1 2 3 4 5 6 7 8 9]</pre>
            </div>
          </div>When image size is even, the origin is at the nearest top-left neighbor pixel of the center of the matrix

          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; f=uint8([[1,2,3,4],[5,6,7,8]])</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; i,v=mmmat2set(f)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; print i</pre>
              <pre class="computer">[[ 0 -1]
 [ 0  0]
 [ 0  1]
 [ 0  2]
 [ 1 -1]
 [ 1  0]
 [ 1  1]
 [ 1  2]]</pre>
              <pre class="user">&gt;&gt;&gt; print v</pre>
              <pre class="computer">[1 2 3 4 5 6 7 8]</pre>
            </div>
          </div>
        </p>
      </div>
    </div>
    <div class="sourcecode">
      <H2>Source Code</H2>
      <div class="H2">
        <pre class="listing">
def mmmat2set(A):
    from Numeric import take, ravel, nonzero, transpose, NewAxis
    if len(A.shape) == 1: A = A[NewAxis,:]
    offsets = nonzero(ravel(A) - mmlimits(A)[0])
    if len(offsets) == 0: return ([],[])
    (h,w) = A.shape
    x = range(2)
    x[0] = offsets/w - (h-1)/2
    x[1] = offsets%w - (w-1)/2
    x = transpose(x)
    CV = x,take(ravel(A),offsets)
    return CV
    </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/mmset2mat.html">mmset2mat</a></td>
              <td class="def">Converts image representation from set to matrix</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>
          </tbody>
        </table>
      </div>
    </div>
    <center>
      <table class="botNav">
        <tr>
          <td class="index">
                    [<a href="../morph/mmdatatype.html"><tt>mmdatatype</tt></a>]
                
                    [<a href="index.html">Up</a>]
                    
                    [<a href="../morph/mmset2mat.html"><tt>mmset2mat</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>