<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmunion</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmsymdif.html"><tt>mmsymdif</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmimg2se.html"><tt>mmimg2se</tt></a>] </td> <td class="title">Operations</td> </tr> </table> <h1>mmunion <br> <span class="subtitle">Union of images. </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">y = <span class="fun">mmunion</span>( <span class="par">f1</span>, <span class="par">f2</span>, <span class="par">f3</span> = None, <span class="par">f4</span> = None, <span class="par">f5</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">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. <p>Or constant</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>Or constant.</p><p>Default: <code>None</code> </p></td> </tr> <tr> <td class="term"><span class="par">f4</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>Or constant.</p><p>Default: <code>None</code> </p></td> </tr> <tr> <td class="term"><span class="par">f5</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>Or constant.</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></td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> <span class="fun">mmunion</span> creates the image <code>y</code> by taking the pixelwise maximum between the images <code>f1, f2, f3, f4,</code> and <code>f5</code>. When <code>f1, f2, f3, f4,</code> and <code>f5</code> are binary images, <code>y</code> represents the union of them. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="bridge">Numerical example:</div> <div class="example"> <div class="listing"> <pre class="user">>>> f=uint8([255, 255, 0, 10, 0, 255, 250])</pre> <pre class="computer"></pre> <pre class="user">>>> print 'f=',f</pre> <pre class="computer">f= [255 255 0 10 0 255 250]</pre> <pre class="user">>>> g=uint8([ 0, 40, 80, 140, 250, 10, 30])</pre> <pre class="computer"></pre> <pre class="user">>>> print 'g=',g</pre> <pre class="computer">g= [ 0 40 80 140 250 10 30]</pre> <pre class="user">>>> print mmunion(f, g)</pre> <pre class="computer">[255 255 80 140 250 255 250]</pre> <pre class="user">>>> print mmunion(f, 255)</pre> <pre class="computer">Warning: Converting input image from int32 to uint8. [255 255 255 255 255 255 255]</pre> </div> </div> <div class="bridge">Binary image</div> <div class="example"> <div class="listing"> <pre class="user">>>> a = mmreadgray('form-ok.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> b = mmreadgray('form-1.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> c = mmunion(a,b)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(a)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(b)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(c)</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="320" src="../images/img_mmunion_001.jpg"></td> <td><img width="320" src="../images/img_mmunion_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_001.jpg">a</a></td> <td><a href="../images/img_mmunion_002.jpg">b</a></td> <td class="spare"></td> </tr> </tbody> </table> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="320" src="../images/img_mmunion_003.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_003.jpg">c</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> <div class="bridge">Binary with gray-scale image:</div> <div class="example"> <div class="listing"> <pre class="user">>>> d = mmreadgray('danaus.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> e = mmcmp(d,'<',80)</pre> <pre class="computer"></pre> <pre class="user">>>> f = mmunion(d,mmgray(e))</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(d)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(e)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f)</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="256" src="../images/img_mmunion_004.jpg"></td> <td><img width="256" src="../images/img_mmunion_005.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_004.jpg">d</a></td> <td><a href="../images/img_mmunion_005.jpg">e</a></td> <td class="spare"></td> </tr> </tbody> </table> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="256" src="../images/img_mmunion_006.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_006.jpg">f</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> <div class="bridge">Gray scale image:</div> <div class="example"> <div class="listing"> <pre class="user">>>> g = mmreadgray('tplayer1.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> h = mmreadgray('tplayer2.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> i = mmreadgray('tplayer3.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> j = mmunion(g,h,i)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(g)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(h)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(i)</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(j)</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="212" src="../images/img_mmunion_007.jpg"></td> <td><img width="212" src="../images/img_mmunion_008.jpg"></td> <td><img width="212" src="../images/img_mmunion_009.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_007.jpg">g</a></td> <td><a href="../images/img_mmunion_008.jpg">h</a></td> <td><a href="../images/img_mmunion_009.jpg">i</a></td> <td class="spare"></td> </tr> </tbody> </table> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="212" src="../images/img_mmunion_010.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmunion_010.jpg">j</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">union:</div> <div class="eqfig"> <img src="../images/eq_mmunion001.png"> </div> <div class="bridge">generalized union:</div> <div class="eqfig"> <img src="../images/eq_mmunion002.png"> </div> </p> </div> </div> <div class="sourcecode"> <H2>Source Code</H2> <div class="H2"> <pre class="listing"> def mmunion(f1, f2, f3=None, f4=None, f5=None): from Numeric import maximum y = maximum(f1,f2) if f3: y = maximum(y,f3) if f4: y = maximum(y,f4) if f5: y = maximum(y,f5) y = y.astype(f1.typecode()) 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/mmfreedom.html">mmfreedom</a></td> <td class="def">Control automatic data type conversion.</td> </tr> <tr> <td class="term"><a href="../morph/mmintersec.html">mmintersec</a></td> <td class="def">Intersection of images.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmsymdif.html"><tt>mmsymdif</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmimg2se.html"><tt>mmimg2se</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>