Sophie

Sophie

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

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

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>mmcmp</title>
    <link href="../tbxdok.css" rel="stylesheet">
  </head>
  <body>
    <table class="topNav">
      <tr>
        <td class="index">
                  [<a href="../morph/mmreadgray.html"><tt>mmreadgray</tt></a>]
              
                  [<a href="index.html">Up</a>]
                  
                  [<a href="../morph/mmis.html"><tt>mmis</tt></a>]
              </td>
        <td class="title">Relations</td>
      </tr>
    </table>
    <h1>mmcmp
      <br>
      <span class="subtitle">Compare two images pixelwisely.
</span>
    </h1>
    <div class="synopsis">
      <H2>Synopsis</H2>
      <div class="H2">
        <div class="prototype">y = 
          <span class="fun">mmcmp</span>(
                  
          <span class="par">f1</span>, 
          <span class="par">oper</span>, 
          <span class="par">f2</span>, 
          <span class="par">oper1</span> = None, 
          <span class="par">f3</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">f1</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">oper</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>relationship from: '==', '~=', '&lt;','&lt;=', '&gt;', '&gt;='.</p></td>
                </tr>
                <tr>
                  <td class="term"><span class="par">f2</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">oper1</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>relationship from: '==', '~=', '&lt;','&lt;=', '&gt;', '&gt;='.</p><p>Default: 
                      <code>None</code>
                    </p></td>
                </tr>
                <tr>
                  <td class="term"><span class="par">f3</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span>          Gray-scale (uint8 or uint16) 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">y</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmImage.html">Image</a></span>          Binary image.
                        </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="descr">
      <H2>Description</H2>
      <div class="H2">
        <p>
                      Apply the relation 
          <code>oper</code> to each pixel of images 
          <code>f1</code> and 
          <code>f2</code>, the result is a binary image with the same size. Optionally, it is possible to make the comparison among three image. It is possible to use a constant value in place of any image, in this case the constant is treated as an image of the same size as the others with all pixels with the value of the constant.
                  
        </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; print mmcmp(uint8([1, 2, 3]),'&lt;', uint8(2))</pre>
              <pre class="computer">[1 0 0]</pre>
              <pre class="user">&gt;&gt;&gt; print mmcmp(uint8([1, 2, 3]),'&lt;', uint8([0, 2, 4]))</pre>
              <pre class="computer">[0 0 1]</pre>
              <pre class="user">&gt;&gt;&gt; print mmcmp(uint8([1, 2, 3]),'==', uint8([1, 1, 3]))</pre>
              <pre class="computer">[1 0 1]</pre>
            </div>
          </div>
          <br>
          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; f=mmreadgray('keyb.tif')</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; fbin=mmcmp(uint8(10), '&lt;', f, '&lt;', uint8(50))</pre>
              <pre class="computer">Warning: Converting input image from int32 to uint16.
Warning: Converting input image from int32 to uint16.</pre>
              <pre class="user">&gt;&gt;&gt; mmshow(f)</pre>
              <pre class="computer"></pre>
              <pre class="user">&gt;&gt;&gt; mmshow(fbin)</pre>
              <pre class="computer"></pre>
            </div>
            <table class="images">
              <tbody align="center">
                <tr class="image" valign="bottom">
                  <td><img width="295" src="../images/img_mmcmp_001.jpg"></td>
                  <td><img width="295" src="../images/img_mmcmp_002.jpg"></td>
                  <td class="spare"></td>
                </tr>
                <tr class="title" valign="baseline">
                  <td><a href="../images/img_mmcmp_001.jpg">f</a></td>
                  <td><a href="../images/img_mmcmp_002.jpg">fbin</a></td>
                  <td class="spare"></td>
                </tr>
              </tbody>
            </table>
          </div>
        </p>
      </div>
    </div>
    <div class="sourcecode">
      <H2>Source Code</H2>
      <div class="H2">
        <pre class="listing">
def mmcmp(f1, oper, f2, oper1=None, f3=None):
    if   oper == '==':    y = (f1==f2)
    elif oper == '~=':    y = (f1!=f2)
    elif oper == '&lt;=':    y = (f1&lt;=f2)
    elif oper == '&gt;=':    y = (f1&gt;=f2)
    elif oper == '&gt;':     y = (f1&gt; f2)
    elif oper == '&lt;':     y = (f1&lt; f2)
    else:
        assert 0, 'oper must be one of: ==, ~=, &gt;, &gt;=, &lt;, &lt;=, it was:'+oper
    if oper1 != None:
        if   oper1 == '==':     y = mmintersec(y, f2==f3)
        elif oper1 == '~=':     y = mmintersec(y, f2!=f3)
        elif oper1 == '&lt;=':     y = mmintersec(y, f2&lt;=f3)
        elif oper1 == '&gt;=':     y = mmintersec(y, f2&gt;=f3)
        elif oper1 == '&gt;':      y = mmintersec(y, f2&gt; f3)
        elif oper1 == '&lt;':      y = mmintersec(y, f2&lt; f3)
        else:
            assert 0, 'oper1 must be one of: ==, ~=, &gt;, &gt;=, &lt;, &lt;=, it was:'+oper1
    y = mmbinary(y)
    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/mmis.html">mmis</a></td>
              <td class="def">Verify if a relationship among images is true or false.</td>
            </tr>
            <tr>
              <td class="term"><a href="../morph/mmthreshad.html">mmthreshad</a></td>
              <td class="def">Threshold (adaptive)</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/mmreadgray.html"><tt>mmreadgray</tt></a>]
                
                    [<a href="index.html">Up</a>]
                    
                    [<a href="../morph/mmis.html"><tt>mmis</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>