Sophie

Sophie

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

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

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>mmfreedom</title>
    <link href="../tbxdok.css" rel="stylesheet">
  </head>
  <body>
    <table class="topNav">
      <tr>
        <td class="index">
                  [<a href="../morph/mmbinary.html"><tt>mmbinary</tt></a>]
              
                  [<a href="index.html">Up</a>]
                  
                  [<a href="../morph/mmgray.html"><tt>mmgray</tt></a>]
              </td>
        <td class="title">Data Type Conversion</td>
      </tr>
    </table>
    <h1>mmfreedom
      <br>
      <span class="subtitle">Control automatic data type conversion.
</span>
    </h1>
    <div class="synopsis">
      <H2>Synopsis</H2>
      <div class="H2">
        <div class="prototype">Y = 
          <span class="fun">mmfreedom</span>(
                  
          <span class="par">L</span> = 5
                  )
        </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">L</span></td>
                  <td class="def"><span class="type"><a href="../mmtypes/mmDouble.html">Double</a></span><p>level of FREEDOM: 0, 1 or 2. If the input parameter is omitted, the current level is returned.</p><p>Default: 
                      <code>5</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/mmDouble.html">Double</a></span><p>current  FREEDOM  level</p></td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="descr">
      <H2>Description</H2>
      <div class="H2">
        <p>
          <span class="fun">mmfreedom</span> controls the automatic data type conversion. There are 3 possible levels, called FREEDOM levels, for automatic conversion: 0 - image type conversion is not allowed;  1- image type conversion is allowed, but a warning is sent for each conversion;  2- image type conversion is allowed without warning.  The FREEDOM  levels are set or inquired by 
          <span class="fun">mmfreedom</span>.
          If an image is not in the required datatype, than it should be converted to the maximum and nearest pymorph Morphology Toolbox datatype.   For example, if an image is in int32 and a morphological gray-scale processing that accepts only binary, uint8 or uint16 images, is required, it will be converted to uint16.  Another example, if a binary image should be added to a uint8  image, the binary image will be converted to uint8.

          <br>In cases of operators that have as parameters an image and a constant, the type of the image should be  kept as reference, while the type of the constant should be converted, if necessary.
                  
        </p>
      </div>
    </div>
    <div class="examples">
      <H2>Examples</H2>
      <div class="H2">
        <p>
          <br>In the following code, both images are gray-scale images, the first image is double and the second is uint8. The nearest image type supported by the toolbox is int32. Both images are converted to int32 and then subtracted. The result is in int32 datatype.

          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; a=mmsubm([4., 2., 1.],uint8([3, 2, 0]))</pre>
              <pre class="computer">Warning: Converting input image from double to int32.
Warning: Converting input image from uint8 to int32.</pre>
              <pre class="user">&gt;&gt;&gt; print a</pre>
              <pre class="computer">[1 0 1]</pre>
              <pre class="user">&gt;&gt;&gt; print mmdatatype(a)</pre>
              <pre class="computer">int32</pre>
            </div>
          </div>
          <br>The first image is gray-scale double and the second is binary double. The nearest image type supported by the toolbox is gray-scale int32. The second image is binary and when converted to gray-scale int32 will become int32([1 1 0]).

          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; a=mmsubm([4., 2., 1], mmbinary([3, 2, 0]))</pre>
              <pre class="computer">Warning: Converting input image from double to int32.
Warning: Converting input image from binary uint8 to int32.</pre>
              <pre class="user">&gt;&gt;&gt; print a</pre>
              <pre class="computer">[3 1 1]</pre>
              <pre class="user">&gt;&gt;&gt; print mmdatatype(a)</pre>
              <pre class="computer">int32</pre>
            </div>
          </div>
          <br>Although the image is uint8 and the constant is int32 the predominant type is given for the image and the constant will be converted to uint8.

          <div class="example">
            <div class="listing">
              <pre class="user">&gt;&gt;&gt; a=mmsubm(uint8([4, 3, 2, 1]), 1)</pre>
              <pre class="computer">Warning: Converting input image from int32 to uint8.</pre>
              <pre class="user">&gt;&gt;&gt; print a</pre>
              <pre class="computer">[3 2 1 0]</pre>
              <pre class="user">&gt;&gt;&gt; print mmdatatype(a)</pre>
              <pre class="computer">uint8</pre>
            </div>
          </div>
          <br>
        </p>
      </div>
    </div>
    <div class="sourcecode">
      <H2>Source Code</H2>
      <div class="H2">
        <pre class="listing">
def mmfreedom(L=5):
    Y = -1
    return Y
    </pre>
      </div>
    </div>
    <div class="seealso">
      <H2>See also</H2>
      <div class="H2">
        <table class="deflist">
          <tbody valign="baseline"></tbody>
        </table>
      </div>
    </div>
    <center>
      <table class="botNav">
        <tr>
          <td class="index">
                    [<a href="../morph/mmbinary.html"><tt>mmbinary</tt></a>]
                
                    [<a href="index.html">Up</a>]
                    
                    [<a href="../morph/mmgray.html"><tt>mmgray</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>