<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmconcat</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../morph/mmtext.html"><tt>mmtext</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmlimits.html"><tt>mmlimits</tt></a>] </td> <td class="title">Image Information and Manipulation</td> </tr> </table> <h1>mmconcat <br> <span class="subtitle">Concatenate two or more images along width, height or depth. </span> </h1> <div class="synopsis"> <H2>Synopsis</H2> <div class="H2"> <div class="prototype">Y = <span class="fun">mmconcat</span>( <span class="par">DIM</span>, <span class="par">X1</span>, <span class="par">X2</span>, <span class="par">X3</span> = None, <span class="par">X4</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">DIM</span></td> <td class="def"><span class="type"><a href="../mmtypes/mmString.html">String</a></span><p>Dimension to concatenate. 'WIDTH' or 'W', 'HEIGHT' or 'H', or ' DEPTH' or 'D'.</p></td> </tr> <tr> <td class="term"><span class="par">X1</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">X2</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">X3</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> <tr> <td class="term"><span class="par">X4</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> Gray-scale (uint8 or uint16) or binary image. </td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> Concatenate two or more images in any of the dimensions: width, height or depth. If the images do not match the dimension, a larger image is create with zero pixels to accommodate them. The images must have the same datatype. </p> </div> </div> <div class="examples"> <H2>Examples</H2> <div class="H2"> <p> <div class="example"> <div class="listing"> <pre class="user">>>> f1=mmreadgray('cameraman.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> f2=mmreadgray('blob.tif')</pre> <pre class="computer"></pre> <pre class="user">>>> g=mmconcat('W',f1,mmgray(mmneg(f2)))</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(g);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="320" src="../images/img_mmconcat_001.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmconcat_001.jpg">g</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 mmconcat(DIM, X1, X2, X3=None, X4=None): from Numeric import NewAxis, sum, zeros aux = 'NewAxis,' d = len(X1.shape) if d < 3: X1 = eval('X1[' + (3-d)*aux + ':]') d1,h1,w1 = X1.shape d = len(X2.shape) if d < 3: X2 = eval('X2[' + (3-d)*aux + ':]') d2,h2,w2 = X2.shape h3 = w3 = d3 = h4 = w4 = d4 = 0 if X3: d = len(X3.shape) if d < 3: X3 = eval('X3[' + (3-d)*aux + ':]') d3,h3,w3 = X3.shape if X4: d = len(X4.shape) if d < 3: X4 = eval('X4[' + (3-d)*aux + ':]') d4,h4,w4 = X4.shape h = [h1, h2, h3, h4] w = [w1, w2, w3, w4] d = [d1, d2, d3, d4] if DIM in ['WIDTH', 'W', 'w', 'width']: hy, wy, dy = max(h), sum(w), max(d) Y = zeros((dy,hy,wy)) Y[0:d1, 0:h1, 0 :w1 ] = X1 Y[0:d2, 0:h2, w1:w1+w2] = X2 if X3: Y[0:d3, 0:h3, w1+w2:w1+w2+w3] = X3 if X4: Y[0:d4, 0:h4, w1+w2+w3::] = X4 elif DIM in ['HEIGHT', 'H', 'h', 'height']: hy, wy, dy = sum(h), max(w), max(d) Y = zeros((dy,hy,wy)) Y[0:d1, 0 :h1 , 0:w1] = X1 Y[0:d2, h1:h1+h2, 0:w2] = X2 if X3: Y[0:d3, h1+h2:h1+h2+h3, 0:w3] = X3 if X4: Y[0:d4, h1+h2+h3::, 0:w4] = X4 elif DIM in ['DEPTH', 'D', 'd', 'depth']: hy, wy, dy = max(h), max(w), sum(d) Y = zeros((dy,hy,wy)) Y[0:d1 , 0:h1, 0:w1 ] = X1 Y[d1:d1+d2, 0:h2, 0:w2] = X2 if X3: Y[d1+d2:d1+d2+d3, 0:h3, 0:w3] = X3 if X4: Y[d1+d2+d3::, 0:h4, 0:w4] = X4 if Y.shape[0] == 1: # adjustment Y = Y[0,:,:] 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/mmshow.html">mmshow</a></td> <td class="def">Display binary or gray-scale images and optionally overlay it with binary images.</td> </tr> </tbody> </table> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../morph/mmtext.html"><tt>mmtext</tt></a>] [<a href="index.html">Up</a>] [<a href="../morph/mmlimits.html"><tt>mmlimits</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>