Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > ce1f17e7ec5e62f35dbe9f064c5f74d7 > files > 1158

libtpcimgio-devel-1.5.10-4.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>vol.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">vol.c</div>  </div>
</div>
<div class="contents">
<a href="vol_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/******************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">  Copyright (c) 2003,2004 by Turku PET Centre</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">  vol.c</span>
<a name="l00005"></a>00005 <span class="comment">  </span>
<a name="l00006"></a>00006 <span class="comment">  Procedures for</span>
<a name="l00007"></a>00007 <span class="comment">  - storing and processing 3D PET image volume data (no time information).</span>
<a name="l00008"></a>00008 <span class="comment">  Depends on IMG functions in library.</span>
<a name="l00009"></a>00009 <span class="comment">  </span>
<a name="l00010"></a>00010 <span class="comment">  Version:</span>
<a name="l00011"></a>00011 <span class="comment">  2003-12-18 Vesa Oikonen</span>
<a name="l00012"></a>00012 <span class="comment">    Added 3D structures VOL and SVOL and related functions.</span>
<a name="l00013"></a>00013 <span class="comment">  2004-01-29 VO</span>
<a name="l00014"></a>00014 <span class="comment">    Added functions vol2img() and svol2img.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment">******************************************************************************/</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00022"></a>00022 <span class="comment">/*****************************************************************************/</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;petc99.h&quot;</span>
<a name="l00024"></a>00024 <span class="comment">/*****************************************************************************/</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="img_8h.html">include/img.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="imgmax_8h.html">include/imgmax.h</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="vol_8h.html">include/vol.h</a>&quot;</span>
<a name="l00028"></a>00028 <span class="comment">/*****************************************************************************/</span>
<a name="l00032"></a><a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">00032</a> <span class="keywordtype">char</span> *<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[] = {
<a name="l00033"></a>00033   <span class="comment">/*  0 */</span> <span class="stringliteral">&quot;ok&quot;</span>,
<a name="l00034"></a>00034   <span class="comment">/*  1 */</span> <span class="stringliteral">&quot;fault in calling routine&quot;</span>,
<a name="l00035"></a>00035   <span class="comment">/*  2 */</span> <span class="stringliteral">&quot;out of memory&quot;</span>
<a name="l00036"></a>00036 };
<a name="l00037"></a>00037 <span class="comment">/*****************************************************************************/</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="comment">/*****************************************************************************/</span>
<a name="l00045"></a><a class="code" href="vol_8h.html#a4fcf2277a539c9dd147676fcbb75ae6d">00045</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#a4fcf2277a539c9dd147676fcbb75ae6d">volInit</a>(<a class="code" href="structVOL.html">VOL</a> *vol) {
<a name="l00046"></a>00046   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;volInit()\n&quot;</span>);
<a name="l00047"></a>00047   memset(vol, 0, <span class="keyword">sizeof</span>(<a class="code" href="structVOL.html">VOL</a>));
<a name="l00048"></a>00048   vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>;
<a name="l00049"></a>00049   vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00050"></a>00050   vol-&gt;<a class="code" href="structVOL.html#a50f67a13fbc89a4635b1956fe2806038">orientation</a>=0;
<a name="l00051"></a>00051   vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>=vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>=vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>=0;
<a name="l00052"></a>00052   vol-&gt;<a class="code" href="structVOL.html#a7329324b27a196c42960b9f88f9219c5">sizex</a>=vol-&gt;<a class="code" href="structVOL.html#ad0bdee583448108a89e19fe3bb957835">sizey</a>=vol-&gt;<a class="code" href="structVOL.html#aac853149c1716ad931b2efd5a2f4fe6b">sizez</a>=0;
<a name="l00053"></a>00053   vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>=(<span class="keywordtype">float</span>***)NULL;
<a name="l00054"></a>00054   vol-&gt;<a class="code" href="structVOL.html#a6b6568c99ed3ac9909c110f069f18565">voxel</a>=(<span class="keywordtype">float</span>*)NULL;
<a name="l00055"></a>00055   vol-&gt;<a class="code" href="structVOL.html#a3eacc138c08009889a2c76793610eea5">column</a>=(<span class="keywordtype">float</span>*)NULL;
<a name="l00056"></a>00056   vol-&gt;<a class="code" href="structVOL.html#aab90a7ecaa7c1ecdd11314accc9bf548">row</a>=(<span class="keywordtype">float</span>**)NULL;
<a name="l00057"></a>00057   vol-&gt;<a class="code" href="structVOL.html#a4ccba917d675ceaf84888749e69fd243">plane</a>=(<span class="keywordtype">float</span>***)NULL;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 <span class="comment">/*****************************************************************************/</span>
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="comment">/*****************************************************************************/</span>
<a name="l00068"></a><a class="code" href="vol_8h.html#a24aa1af9ebf7dcdd60fddaa866001e84">00068</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#a24aa1af9ebf7dcdd60fddaa866001e84">svolInit</a>(<a class="code" href="structSVOL.html">SVOL</a> *svol) {
<a name="l00069"></a>00069   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;svolInit()\n&quot;</span>);
<a name="l00070"></a>00070   memset(svol, 0, <span class="keyword">sizeof</span>(<a class="code" href="structSVOL.html">SVOL</a>));
<a name="l00071"></a>00071   svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>;
<a name="l00072"></a>00072   svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00073"></a>00073   svol-&gt;<a class="code" href="structSVOL.html#a29c52139a6e978f2b1c95b6e07be97c5">orientation</a>=0;
<a name="l00074"></a>00074   svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>=svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>=svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>=0;
<a name="l00075"></a>00075   svol-&gt;<a class="code" href="structSVOL.html#ad1d7e0807670f9363c98f2d7513acb7b">sizex</a>=svol-&gt;<a class="code" href="structSVOL.html#a046364e1c8f04480e6e286ed1c6d7964">sizey</a>=svol-&gt;<a class="code" href="structSVOL.html#a685b7ab2ce3f0b3db66f4dbb56077ce4">sizez</a>=0;
<a name="l00076"></a>00076   svol-&gt;<a class="code" href="structSVOL.html#ab9a127085156ad3668b35d405e257f5f">scale_factor</a>=1.0;
<a name="l00077"></a>00077   svol-&gt;<a class="code" href="structSVOL.html#acb310e212f368d5fd5be068f33c1c1ba">v</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>***)NULL;
<a name="l00078"></a>00078   svol-&gt;<a class="code" href="structSVOL.html#a0f6e70cec2ed8845a20656fa85e0268c">voxel</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*)NULL;
<a name="l00079"></a>00079   svol-&gt;<a class="code" href="structSVOL.html#abe73fcc82accb78452aacce8fb6322a0">column</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*)NULL;
<a name="l00080"></a>00080   svol-&gt;<a class="code" href="structSVOL.html#a1bc91ab3ee2c0756ac96112ae5d92166">row</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>**)NULL;
<a name="l00081"></a>00081   svol-&gt;<a class="code" href="structSVOL.html#aad973d4f598f6118c9492c521cedd36b">plane</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>***)NULL;
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083 <span class="comment">/*****************************************************************************/</span>
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 <span class="comment">/*****************************************************************************/</span>
<a name="l00091"></a><a class="code" href="vol_8h.html#ab4e7ca1b78280f9d5573bd8bc34ce899">00091</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#ab4e7ca1b78280f9d5573bd8bc34ce899">volEmpty</a>(<a class="code" href="structVOL.html">VOL</a> *vol) {
<a name="l00092"></a>00092   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;volEmpty()\n&quot;</span>);
<a name="l00093"></a>00093   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>&lt;<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>;
<a name="l00094"></a>00094   <span class="comment">/* Free up memory */</span>
<a name="l00095"></a>00095   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>!=NULL) free(vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>);
<a name="l00096"></a>00096   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#adc41255ec93ec19a7c0e2fab79380807">_col</a>!=NULL) free(vol-&gt;<a class="code" href="structVOL.html#adc41255ec93ec19a7c0e2fab79380807">_col</a>);
<a name="l00097"></a>00097   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>!=NULL) free(vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>);
<a name="l00098"></a>00098   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>!=NULL) free(vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>);
<a name="l00099"></a>00099   <span class="comment">/* Set variables */</span>
<a name="l00100"></a>00100   vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00101"></a>00101   vol-&gt;<a class="code" href="structVOL.html#a50f67a13fbc89a4635b1956fe2806038">orientation</a>=0;
<a name="l00102"></a>00102   vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>=vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>=vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>=0;
<a name="l00103"></a>00103   vol-&gt;<a class="code" href="structVOL.html#a7329324b27a196c42960b9f88f9219c5">sizex</a>=vol-&gt;<a class="code" href="structVOL.html#ad0bdee583448108a89e19fe3bb957835">sizey</a>=vol-&gt;<a class="code" href="structVOL.html#aac853149c1716ad931b2efd5a2f4fe6b">sizez</a>=0;
<a name="l00104"></a>00104   vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>=(<span class="keywordtype">float</span>***)NULL;
<a name="l00105"></a>00105   vol-&gt;<a class="code" href="structVOL.html#a6b6568c99ed3ac9909c110f069f18565">voxel</a>=(<span class="keywordtype">float</span>*)NULL;
<a name="l00106"></a>00106   vol-&gt;<a class="code" href="structVOL.html#a3eacc138c08009889a2c76793610eea5">column</a>=(<span class="keywordtype">float</span>*)NULL;
<a name="l00107"></a>00107   vol-&gt;<a class="code" href="structVOL.html#aab90a7ecaa7c1ecdd11314accc9bf548">row</a>=(<span class="keywordtype">float</span>**)NULL;
<a name="l00108"></a>00108   vol-&gt;<a class="code" href="structVOL.html#a4ccba917d675ceaf84888749e69fd243">plane</a>=(<span class="keywordtype">float</span>***)NULL;
<a name="l00109"></a>00109   <span class="comment">/* Set status */</span>
<a name="l00110"></a>00110   vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>;
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 <span class="comment">/*****************************************************************************/</span>
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 <span class="comment">/*****************************************************************************/</span>
<a name="l00120"></a><a class="code" href="vol_8h.html#a5786ad61a2571e7a22d9e3755c74f2e8">00120</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#a5786ad61a2571e7a22d9e3755c74f2e8">svolEmpty</a>(<a class="code" href="structSVOL.html">SVOL</a> *svol) {
<a name="l00121"></a>00121   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;svolEmpty()\n&quot;</span>);
<a name="l00122"></a>00122   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>&lt;<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>;
<a name="l00123"></a>00123   <span class="comment">/* Free up memory */</span>
<a name="l00124"></a>00124   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>!=NULL) free(svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>);
<a name="l00125"></a>00125   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#a17b39eddcad748b2773d57dd4391cc84">_col</a>!=NULL) free(svol-&gt;<a class="code" href="structSVOL.html#a17b39eddcad748b2773d57dd4391cc84">_col</a>);
<a name="l00126"></a>00126   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>!=NULL) free(svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>);
<a name="l00127"></a>00127   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>!=NULL) free(svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>);
<a name="l00128"></a>00128   <span class="comment">/* Set variables */</span>
<a name="l00129"></a>00129   svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00130"></a>00130   svol-&gt;<a class="code" href="structSVOL.html#a29c52139a6e978f2b1c95b6e07be97c5">orientation</a>=0;
<a name="l00131"></a>00131   svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>=svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>=svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>=0;
<a name="l00132"></a>00132   svol-&gt;<a class="code" href="structSVOL.html#ad1d7e0807670f9363c98f2d7513acb7b">sizex</a>=svol-&gt;<a class="code" href="structSVOL.html#a046364e1c8f04480e6e286ed1c6d7964">sizey</a>=svol-&gt;<a class="code" href="structSVOL.html#a685b7ab2ce3f0b3db66f4dbb56077ce4">sizez</a>=0;
<a name="l00133"></a>00133   svol-&gt;<a class="code" href="structSVOL.html#ab9a127085156ad3668b35d405e257f5f">scale_factor</a>=1.0;
<a name="l00134"></a>00134   svol-&gt;<a class="code" href="structSVOL.html#acb310e212f368d5fd5be068f33c1c1ba">v</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>***)NULL;
<a name="l00135"></a>00135   svol-&gt;<a class="code" href="structSVOL.html#a0f6e70cec2ed8845a20656fa85e0268c">voxel</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*)NULL;
<a name="l00136"></a>00136   svol-&gt;<a class="code" href="structSVOL.html#abe73fcc82accb78452aacce8fb6322a0">column</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*)NULL;
<a name="l00137"></a>00137   svol-&gt;<a class="code" href="structSVOL.html#a1bc91ab3ee2c0756ac96112ae5d92166">row</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>**)NULL;
<a name="l00138"></a>00138   svol-&gt;<a class="code" href="structSVOL.html#aad973d4f598f6118c9492c521cedd36b">plane</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>***)NULL;
<a name="l00139"></a>00139   <span class="comment">/* Set status */</span>
<a name="l00140"></a>00140   svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 <span class="comment">/*****************************************************************************/</span>
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 <span class="comment">/*****************************************************************************/</span>
<a name="l00156"></a><a class="code" href="vol_8h.html#a81ef356e4ce5640eab652ff90f0fb4d5">00156</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#a81ef356e4ce5640eab652ff90f0fb4d5">volAllocate</a>(<a class="code" href="structVOL.html">VOL</a> *vol, <span class="keywordtype">int</span> planes, <span class="keywordtype">int</span> rows, <span class="keywordtype">int</span> columns) {
<a name="l00157"></a>00157   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, ri;
<a name="l00158"></a>00158   <span class="keywordtype">int</span> vxlNr, vi;
<a name="l00159"></a>00159   <span class="keywordtype">float</span> **rptr, *cptr;
<a name="l00160"></a>00160 
<a name="l00161"></a>00161   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;voiAllocate(*vol, %d, %d, %d)\n&quot;</span>, planes, rows, columns);
<a name="l00162"></a>00162   <span class="comment">/* Check arguments */</span>
<a name="l00163"></a>00163   <span class="keywordflow">if</span>(vol==NULL) <span class="keywordflow">return</span>(1); <span class="keywordflow">else</span> vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00164"></a>00164   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>==<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) <span class="keywordflow">return</span>(1);
<a name="l00165"></a>00165   <span class="keywordflow">if</span>(planes&lt;1 || rows&lt;1 || columns&lt;1) <span class="keywordflow">return</span>(2);
<a name="l00166"></a>00166   vxlNr=planes*rows*columns;
<a name="l00167"></a>00167 
<a name="l00168"></a>00168   <span class="comment">/* Check if correct volume size is already allocated */</span>
<a name="l00169"></a>00169   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>&gt;=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) {
<a name="l00170"></a>00170     <span class="keywordflow">if</span>(planes==vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a> &amp;&amp; rows==vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a> &amp;&amp; columns==vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>) {
<a name="l00171"></a>00171       <span class="keywordflow">for</span>(vi=0; vi&lt;vxlNr; vi++) vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>[vi]=0;
<a name="l00172"></a>00172       <span class="keywordflow">return</span>(0); <span class="comment">/* that&#39;s it */</span>
<a name="l00173"></a>00173     } <span class="keywordflow">else</span> {
<a name="l00174"></a>00174       <a class="code" href="vol_8c.html#ab4e7ca1b78280f9d5573bd8bc34ce899">volEmpty</a>(vol);
<a name="l00175"></a>00175     }
<a name="l00176"></a>00176   }
<a name="l00177"></a>00177   <span class="comment">/* Allocate memory for volume data */</span>
<a name="l00178"></a>00178   vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>=(<span class="keywordtype">float</span>***)malloc(planes*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>**));
<a name="l00179"></a>00179   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>==NULL) {
<a name="l00180"></a>00180     <span class="keywordflow">return</span>(5);}
<a name="l00181"></a>00181   vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>=(<span class="keywordtype">float</span>**)malloc(planes*rows*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>*));
<a name="l00182"></a>00182   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>==NULL) {
<a name="l00183"></a>00183     free(vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>); <span class="keywordflow">return</span>(6);}
<a name="l00184"></a>00184   vol-&gt;<a class="code" href="structVOL.html#adc41255ec93ec19a7c0e2fab79380807">_col</a>=vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>=(<span class="keywordtype">float</span>*)calloc(planes*rows*columns, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>));
<a name="l00185"></a>00185   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>==NULL) {
<a name="l00186"></a>00186     free(vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>); free(vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>); <span class="keywordflow">return</span>(8);
<a name="l00187"></a>00187   }
<a name="l00188"></a>00188   <span class="comment">/* Set data pointers */</span>
<a name="l00189"></a>00189   rptr=vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>; cptr=vol-&gt;<a class="code" href="structVOL.html#adc41255ec93ec19a7c0e2fab79380807">_col</a>;
<a name="l00190"></a>00190   <span class="keywordflow">for</span>(zi=0; zi&lt;planes; zi++) {
<a name="l00191"></a>00191     vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>[zi]=rptr;
<a name="l00192"></a>00192     <span class="keywordflow">for</span>(ri=0; ri&lt;rows; ri++) {
<a name="l00193"></a>00193       *rptr++=cptr; cptr+=columns;
<a name="l00194"></a>00194     }
<a name="l00195"></a>00195   }
<a name="l00196"></a>00196   vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>=vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>;
<a name="l00197"></a>00197   vol-&gt;<a class="code" href="structVOL.html#a4ccba917d675ceaf84888749e69fd243">plane</a>=vol-&gt;<a class="code" href="structVOL.html#a5e5aeec0e67431ea24b0f6649b4cf5f6">_pln</a>;
<a name="l00198"></a>00198   vol-&gt;<a class="code" href="structVOL.html#a3eacc138c08009889a2c76793610eea5">column</a>=vol-&gt;<a class="code" href="structVOL.html#adc41255ec93ec19a7c0e2fab79380807">_col</a>;
<a name="l00199"></a>00199   vol-&gt;<a class="code" href="structVOL.html#aab90a7ecaa7c1ecdd11314accc9bf548">row</a>=vol-&gt;<a class="code" href="structVOL.html#a669e758fd84c6ad8f14a918bf5d6580c">_row</a>;
<a name="l00200"></a>00200   vol-&gt;<a class="code" href="structVOL.html#a6b6568c99ed3ac9909c110f069f18565">voxel</a>=vol-&gt;<a class="code" href="structVOL.html#a3bef2dbeba5aa3d953c494da7a8d5de4">_vxl</a>;
<a name="l00201"></a>00201   <span class="comment">/* Ok */</span>
<a name="l00202"></a>00202   vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>=planes; vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>=rows; vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>=columns;
<a name="l00203"></a>00203   vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00204"></a>00204   vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>;
<a name="l00205"></a>00205   <span class="keywordflow">return</span>(0);
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 <span class="comment">/*****************************************************************************/</span>
<a name="l00208"></a>00208 
<a name="l00209"></a>00209 <span class="comment">/*****************************************************************************/</span>
<a name="l00221"></a><a class="code" href="vol_8h.html#a4a18e3bfe8bb42d1abe2eef27d6dfe51">00221</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#a4a18e3bfe8bb42d1abe2eef27d6dfe51">svolAllocate</a>(<a class="code" href="structSVOL.html">SVOL</a> *svol, <span class="keywordtype">int</span> planes, <span class="keywordtype">int</span> rows, <span class="keywordtype">int</span> columns) {
<a name="l00222"></a>00222   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, ri;
<a name="l00223"></a>00223   <span class="keywordtype">int</span> vxlNr, vi;
<a name="l00224"></a>00224   <span class="keywordtype">short</span> <span class="keywordtype">int</span> **rptr, *cptr;
<a name="l00225"></a>00225 
<a name="l00226"></a>00226   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;svoiAllocate(*svol, %d, %d, %d)\n&quot;</span>, planes, rows, columns);
<a name="l00227"></a>00227   <span class="comment">/* Check arguments */</span>
<a name="l00228"></a>00228   <span class="keywordflow">if</span>(svol==NULL) <span class="keywordflow">return</span>(1); <span class="keywordflow">else</span> svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00229"></a>00229   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>==<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) <span class="keywordflow">return</span>(1);
<a name="l00230"></a>00230   <span class="keywordflow">if</span>(planes&lt;1 || rows&lt;1 || columns&lt;1) <span class="keywordflow">return</span>(2);
<a name="l00231"></a>00231   vxlNr=planes*rows*columns;
<a name="l00232"></a>00232 
<a name="l00233"></a>00233   <span class="comment">/* Check if correct volume size is already allocated */</span>
<a name="l00234"></a>00234   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>&gt;=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) {
<a name="l00235"></a>00235     <span class="keywordflow">if</span>(planes==svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a> &amp;&amp; rows==svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a> &amp;&amp; columns==svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>) {
<a name="l00236"></a>00236       <span class="keywordflow">for</span>(vi=0; vi&lt;vxlNr; vi++) svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>[vi]=0;
<a name="l00237"></a>00237       <span class="keywordflow">return</span>(0); <span class="comment">/* that&#39;s it */</span>
<a name="l00238"></a>00238     } <span class="keywordflow">else</span> {
<a name="l00239"></a>00239       <a class="code" href="vol_8c.html#a5786ad61a2571e7a22d9e3755c74f2e8">svolEmpty</a>(svol);
<a name="l00240"></a>00240     }
<a name="l00241"></a>00241   }
<a name="l00242"></a>00242   <span class="comment">/* Allocate memory for volume data */</span>
<a name="l00243"></a>00243   svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>***)malloc(planes*<span class="keyword">sizeof</span>(<span class="keywordtype">short</span> <span class="keywordtype">int</span>**));
<a name="l00244"></a>00244   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>==NULL) {
<a name="l00245"></a>00245     <span class="keywordflow">return</span>(5);}
<a name="l00246"></a>00246   svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>**)malloc(planes*rows*<span class="keyword">sizeof</span>(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*));
<a name="l00247"></a>00247   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>==NULL) {
<a name="l00248"></a>00248     free(svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>); <span class="keywordflow">return</span>(6);}
<a name="l00249"></a>00249   svol-&gt;<a class="code" href="structSVOL.html#a17b39eddcad748b2773d57dd4391cc84">_col</a>=svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>*)calloc(planes*rows*columns, <span class="keyword">sizeof</span>(<span class="keywordtype">short</span> <span class="keywordtype">int</span>));
<a name="l00250"></a>00250   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>==NULL) {
<a name="l00251"></a>00251     free(svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>); free(svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>); <span class="keywordflow">return</span>(8);
<a name="l00252"></a>00252   }
<a name="l00253"></a>00253   <span class="comment">/* Set data pointers */</span>
<a name="l00254"></a>00254   rptr=svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>; cptr=svol-&gt;<a class="code" href="structSVOL.html#a17b39eddcad748b2773d57dd4391cc84">_col</a>;
<a name="l00255"></a>00255   <span class="keywordflow">for</span>(zi=0; zi&lt;planes; zi++) {
<a name="l00256"></a>00256     svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>[zi]=rptr;
<a name="l00257"></a>00257     <span class="keywordflow">for</span>(ri=0; ri&lt;rows; ri++) {
<a name="l00258"></a>00258       *rptr++=cptr; cptr+=columns;
<a name="l00259"></a>00259     }
<a name="l00260"></a>00260   }
<a name="l00261"></a>00261   svol-&gt;<a class="code" href="structSVOL.html#acb310e212f368d5fd5be068f33c1c1ba">v</a>=svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>;
<a name="l00262"></a>00262   svol-&gt;<a class="code" href="structSVOL.html#aad973d4f598f6118c9492c521cedd36b">plane</a>=svol-&gt;<a class="code" href="structSVOL.html#a3a20e5015b0b7c466d948129e0265ef6">_pln</a>;
<a name="l00263"></a>00263   svol-&gt;<a class="code" href="structSVOL.html#abe73fcc82accb78452aacce8fb6322a0">column</a>=svol-&gt;<a class="code" href="structSVOL.html#a17b39eddcad748b2773d57dd4391cc84">_col</a>;
<a name="l00264"></a>00264   svol-&gt;<a class="code" href="structSVOL.html#a1bc91ab3ee2c0756ac96112ae5d92166">row</a>=svol-&gt;<a class="code" href="structSVOL.html#aa1af2c91a23865ddbe3d251099398060">_row</a>;
<a name="l00265"></a>00265   svol-&gt;<a class="code" href="structSVOL.html#a0f6e70cec2ed8845a20656fa85e0268c">voxel</a>=svol-&gt;<a class="code" href="structSVOL.html#a304a8e760c9b0cdca03773b418c73660">_vxl</a>;
<a name="l00266"></a>00266   <span class="comment">/* Ok */</span>
<a name="l00267"></a>00267   svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>=planes; svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>=rows; svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>=columns;
<a name="l00268"></a>00268   svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[0];
<a name="l00269"></a>00269   svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>;
<a name="l00270"></a>00270   <span class="keywordflow">return</span>(0);
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272 <span class="comment">/*****************************************************************************/</span>
<a name="l00273"></a>00273 
<a name="l00274"></a>00274 <span class="comment">/*****************************************************************************/</span>
<a name="l00284"></a><a class="code" href="vol_8h.html#ab8e38cb0c2f98d0b17604f62c8753727">00284</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#ab8e38cb0c2f98d0b17604f62c8753727">img2vol</a>(<a class="code" href="structIMG.html">IMG</a> *img, <a class="code" href="structVOL.html">VOL</a> *vol, <span class="keywordtype">int</span> frame) {
<a name="l00285"></a>00285   <span class="keywordtype">int</span> ret;
<a name="l00286"></a>00286   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, yi, xi, fi;
<a name="l00287"></a>00287 
<a name="l00288"></a>00288   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;img2vol(img, %d, vol)\n&quot;</span>, frame);
<a name="l00289"></a>00289   <span class="comment">/* Check input */</span>
<a name="l00290"></a>00290   <span class="keywordflow">if</span>(vol==NULL) <span class="keywordflow">return</span>(1);
<a name="l00291"></a>00291   vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00292"></a>00292   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00293"></a>00293   <span class="keywordflow">if</span>(frame&lt;1 || img-&gt;dimt&lt;frame) <span class="keywordflow">return</span>(2);
<a name="l00294"></a>00294   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>==<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) <span class="keywordflow">return</span>(1);
<a name="l00295"></a>00295 
<a name="l00296"></a>00296   <span class="comment">/* Allocate memory (if needed) for volume */</span>
<a name="l00297"></a>00297   ret=<a class="code" href="vol_8c.html#a81ef356e4ce5640eab652ff90f0fb4d5">volAllocate</a>(vol, img-&gt;<a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>, img-&gt;<a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>, img-&gt;<a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>);
<a name="l00298"></a>00298   <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span>(ret);
<a name="l00299"></a>00299 
<a name="l00300"></a>00300   <span class="comment">/* Copy data */</span>
<a name="l00301"></a>00301   fi=frame-1;
<a name="l00302"></a>00302   vol-&gt;<a class="code" href="structVOL.html#a50f67a13fbc89a4635b1956fe2806038">orientation</a>=img-&gt;<a class="code" href="structIMG.html#aa25ed90a08d249bc43b076a3c5a30544">orientation</a>;
<a name="l00303"></a>00303   vol-&gt;<a class="code" href="structVOL.html#a7329324b27a196c42960b9f88f9219c5">sizex</a>=img-&gt;<a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; vol-&gt;<a class="code" href="structVOL.html#ad0bdee583448108a89e19fe3bb957835">sizey</a>=img-&gt;<a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>; vol-&gt;<a class="code" href="structVOL.html#aac853149c1716ad931b2efd5a2f4fe6b">sizez</a>=img-&gt;<a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>;
<a name="l00304"></a>00304   <span class="keywordflow">for</span>(zi=0; zi&lt;vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>; zi++)
<a name="l00305"></a>00305     <span class="keywordflow">for</span>(yi=0; yi&lt;vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>; yi++)
<a name="l00306"></a>00306       <span class="keywordflow">for</span>(xi=0; xi&lt;vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>; xi++)
<a name="l00307"></a>00307         vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi]=img-&gt;<a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[zi][yi][xi][fi];
<a name="l00308"></a>00308 
<a name="l00309"></a>00309   <span class="keywordflow">return</span>(0);
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311 <span class="comment">/*****************************************************************************/</span>
<a name="l00312"></a>00312 
<a name="l00313"></a>00313 <span class="comment">/*****************************************************************************/</span>
<a name="l00322"></a><a class="code" href="vol_8h.html#abd08e7e43e4a4d75e14f9857d4a21453">00322</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#abd08e7e43e4a4d75e14f9857d4a21453">img2svol</a>(<a class="code" href="structIMG.html">IMG</a> *img, <a class="code" href="structSVOL.html">SVOL</a> *svol, <span class="keywordtype">int</span> frame) {
<a name="l00323"></a>00323   <span class="keywordtype">int</span> ret;
<a name="l00324"></a>00324   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, yi, xi, fi;
<a name="l00325"></a>00325   <span class="keywordtype">float</span> fmin, fmax, g;
<a name="l00326"></a>00326 
<a name="l00327"></a>00327   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;img2svol(img, %d, svol)\n&quot;</span>, frame);
<a name="l00328"></a>00328   <span class="comment">/* Check input */</span>
<a name="l00329"></a>00329   <span class="keywordflow">if</span>(svol==NULL) <span class="keywordflow">return</span>(1);
<a name="l00330"></a>00330   svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00331"></a>00331   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00332"></a>00332   <span class="keywordflow">if</span>(frame&lt;1 || img-&gt;dimt&lt;frame) <span class="keywordflow">return</span>(2);
<a name="l00333"></a>00333   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>==<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) <span class="keywordflow">return</span>(1);
<a name="l00334"></a>00334 
<a name="l00335"></a>00335   <span class="comment">/* Allocate memory (if needed) for volume */</span>
<a name="l00336"></a>00336   ret=<a class="code" href="vol_8c.html#a4a18e3bfe8bb42d1abe2eef27d6dfe51">svolAllocate</a>(svol, img-&gt;<a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>, img-&gt;<a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>, img-&gt;<a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>);
<a name="l00337"></a>00337   <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span>(ret);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339   <span class="comment">/* Copy data */</span>
<a name="l00340"></a>00340   fi=frame-1;
<a name="l00341"></a>00341   svol-&gt;<a class="code" href="structSVOL.html#a29c52139a6e978f2b1c95b6e07be97c5">orientation</a>=img-&gt;<a class="code" href="structIMG.html#aa25ed90a08d249bc43b076a3c5a30544">orientation</a>;
<a name="l00342"></a>00342   svol-&gt;<a class="code" href="structSVOL.html#ad1d7e0807670f9363c98f2d7513acb7b">sizex</a>=img-&gt;<a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; svol-&gt;<a class="code" href="structSVOL.html#a046364e1c8f04480e6e286ed1c6d7964">sizey</a>=img-&gt;<a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>; svol-&gt;<a class="code" href="structSVOL.html#a685b7ab2ce3f0b3db66f4dbb56077ce4">sizez</a>=img-&gt;<a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>;
<a name="l00343"></a>00343   ret=<a class="code" href="imgmax_8c.html#a4230e721a2c8767cfebe73d48c0d910d">imgFrameMinMax</a>(img, frame, &amp;fmin, &amp;fmax); <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span>(10+ret);
<a name="l00344"></a>00344   <span class="keywordflow">if</span>(fabs(fmin)&gt;fabs(fmax)) g=fabs(fmin); <span class="keywordflow">else</span> g=fabs(fmax);
<a name="l00345"></a>00345   <span class="keywordflow">if</span>(g!=0) g=32766./g; <span class="keywordflow">else</span> g=1.0;
<a name="l00346"></a>00346   <span class="keywordflow">for</span>(zi=0; zi&lt;svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>; zi++)
<a name="l00347"></a>00347     <span class="keywordflow">for</span>(yi=0; yi&lt;svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>; yi++)
<a name="l00348"></a>00348       <span class="keywordflow">for</span>(xi=0; xi&lt;svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>; xi++)
<a name="l00349"></a>00349         svol-&gt;<a class="code" href="structSVOL.html#acb310e212f368d5fd5be068f33c1c1ba">v</a>[zi][yi][xi]=(<span class="keywordtype">short</span> <span class="keywordtype">int</span>)temp_roundf(g*img-&gt;<a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[zi][yi][xi][fi]);
<a name="l00350"></a>00350   svol-&gt;<a class="code" href="structSVOL.html#ab9a127085156ad3668b35d405e257f5f">scale_factor</a>=1.0/g;
<a name="l00351"></a>00351 
<a name="l00352"></a>00352   <span class="keywordflow">return</span>(0);
<a name="l00353"></a>00353 }
<a name="l00354"></a>00354 <span class="comment">/*****************************************************************************/</span>
<a name="l00355"></a>00355 
<a name="l00356"></a>00356 <span class="comment">/*****************************************************************************/</span>
<a name="l00367"></a><a class="code" href="vol_8h.html#ae7f549b3214d93ced7be00aba4c7bd62">00367</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#ae7f549b3214d93ced7be00aba4c7bd62">vol2img</a>(<a class="code" href="structVOL.html">VOL</a> *vol, <a class="code" href="structIMG.html">IMG</a> *img, <span class="keywordtype">int</span> frame) {
<a name="l00368"></a>00368   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, yi, xi, fi;
<a name="l00369"></a>00369 
<a name="l00370"></a>00370   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;vol2img(vol, img, %d)\n&quot;</span>, frame);
<a name="l00371"></a>00371   <span class="comment">/* Check input */</span>
<a name="l00372"></a>00372   <span class="keywordflow">if</span>(vol==NULL || vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00373"></a>00373   vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00374"></a>00374   <span class="keywordflow">if</span>(img==NULL || img-&gt;<a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00375"></a>00375   <span class="keywordflow">if</span>(frame&lt;1 || img-&gt;dimt&lt;frame) <span class="keywordflow">return</span>(2);
<a name="l00376"></a>00376   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>!=vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a> || img-&gt;<a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>!=vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>) <span class="keywordflow">return</span>(3);
<a name="l00377"></a>00377   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>!=vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>) <span class="keywordflow">return</span>(4);
<a name="l00378"></a>00378 
<a name="l00379"></a>00379   <span class="comment">/* Copy data */</span>
<a name="l00380"></a>00380   fi=frame-1;
<a name="l00381"></a>00381   <span class="keywordflow">for</span>(zi=0; zi&lt;vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>; zi++)
<a name="l00382"></a>00382     <span class="keywordflow">for</span>(yi=0; yi&lt;vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>; yi++)
<a name="l00383"></a>00383       <span class="keywordflow">for</span>(xi=0; xi&lt;vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>; xi++)
<a name="l00384"></a>00384         img-&gt;<a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[zi][yi][xi][fi]=vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi];
<a name="l00385"></a>00385 
<a name="l00386"></a>00386   <span class="keywordflow">return</span>(0);
<a name="l00387"></a>00387 }
<a name="l00388"></a>00388 <span class="comment">/*****************************************************************************/</span>
<a name="l00389"></a>00389 
<a name="l00390"></a>00390 <span class="comment">/*****************************************************************************/</span>
<a name="l00401"></a><a class="code" href="vol_8h.html#a7e337783e85d45dbbb1af9b96153d340">00401</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#a7e337783e85d45dbbb1af9b96153d340">svol2img</a>(<a class="code" href="structSVOL.html">SVOL</a> *svol, <a class="code" href="structIMG.html">IMG</a> *img, <span class="keywordtype">int</span> frame) {
<a name="l00402"></a>00402   <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> zi, yi, xi, fi;
<a name="l00403"></a>00403 
<a name="l00404"></a>00404   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;svol2img(svol, img, %d)\n&quot;</span>, frame);
<a name="l00405"></a>00405   <span class="comment">/* Check input */</span>
<a name="l00406"></a>00406   <span class="keywordflow">if</span>(svol==NULL || svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00407"></a>00407   svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>=<a class="code" href="vol_8c.html#a078204a1de94eb6ff6c3504c541f6421">_volStatusMessage</a>[1];
<a name="l00408"></a>00408   <span class="keywordflow">if</span>(img==NULL || img-&gt;<a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00409"></a>00409   <span class="keywordflow">if</span>(frame&lt;1 || img-&gt;dimt&lt;frame) <span class="keywordflow">return</span>(2);
<a name="l00410"></a>00410   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>!=svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a> || img-&gt;<a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>!=svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>) <span class="keywordflow">return</span>(3);
<a name="l00411"></a>00411   <span class="keywordflow">if</span>(img-&gt;<a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>!=svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>) <span class="keywordflow">return</span>(4);
<a name="l00412"></a>00412 
<a name="l00413"></a>00413   <span class="comment">/* Copy data */</span>
<a name="l00414"></a>00414   fi=frame-1;
<a name="l00415"></a>00415   <span class="keywordflow">for</span>(zi=0; zi&lt;svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>; zi++)
<a name="l00416"></a>00416     <span class="keywordflow">for</span>(yi=0; yi&lt;svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>; yi++)
<a name="l00417"></a>00417       <span class="keywordflow">for</span>(xi=0; xi&lt;svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>; xi++)
<a name="l00418"></a>00418         img-&gt;<a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[zi][yi][xi][fi]=(svol-&gt;<a class="code" href="structSVOL.html#ab9a127085156ad3668b35d405e257f5f">scale_factor</a>)*(float)svol-&gt;<a class="code" href="structSVOL.html#acb310e212f368d5fd5be068f33c1c1ba">v</a>[zi][yi][xi];
<a name="l00419"></a>00419 
<a name="l00420"></a>00420   <span class="keywordflow">return</span>(0);
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422 <span class="comment">/*****************************************************************************/</span>
<a name="l00423"></a>00423 
<a name="l00424"></a>00424 <span class="comment">/*****************************************************************************/</span>
<a name="l00431"></a><a class="code" href="vol_8h.html#aa6177bbbeb99b94e46f944c788561e5e">00431</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#aa6177bbbeb99b94e46f944c788561e5e">volInfo</a>(<a class="code" href="structVOL.html">VOL</a> *vol, FILE *fp) {
<a name="l00432"></a>00432   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;volInfo()\n&quot;</span>);
<a name="l00433"></a>00433   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>&lt;=<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) {
<a name="l00434"></a>00434     fprintf(fp, <span class="stringliteral">&quot;Volume data is not initialized.\n&quot;</span>); <span class="keywordflow">return</span>;}
<a name="l00435"></a>00435   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>==<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>) {
<a name="l00436"></a>00436     fprintf(fp, <span class="stringliteral">&quot;Volume data is initialized but empty.\n&quot;</span>); <span class="keywordflow">return</span>;}
<a name="l00437"></a>00437   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>==<a class="code" href="img_8h.html#aed73bfdf4ad84974fe206b683972cb9d">IMG_STATUS_ERROR</a>) fprintf(stdout, <span class="stringliteral">&quot;Volume data has errors.\n&quot;</span>);
<a name="l00438"></a>00438   fprintf(fp, <span class="stringliteral">&quot;Volume status: %s\n&quot;</span>, vol-&gt;<a class="code" href="structVOL.html#a840fbb016748dfaf23001947a3734e51">statmsg</a>);
<a name="l00439"></a>00439   fprintf(fp, <span class="stringliteral">&quot;Patient orientation: %d\n&quot;</span>, vol-&gt;<a class="code" href="structVOL.html#a50f67a13fbc89a4635b1956fe2806038">orientation</a>);
<a name="l00440"></a>00440   fprintf(fp, <span class="stringliteral">&quot;Voxel sizes (x, y, z): %g %g %g mm\n&quot;</span>,
<a name="l00441"></a>00441     vol-&gt;<a class="code" href="structVOL.html#a7329324b27a196c42960b9f88f9219c5">sizex</a>, vol-&gt;<a class="code" href="structVOL.html#ad0bdee583448108a89e19fe3bb957835">sizey</a>, vol-&gt;<a class="code" href="structVOL.html#aac853149c1716ad931b2efd5a2f4fe6b">sizez</a>);
<a name="l00442"></a>00442   fprintf(fp, <span class="stringliteral">&quot;Dimensions (x, y, z): %d %d %d\n&quot;</span>,
<a name="l00443"></a>00443     vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>, vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a>, vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a>);
<a name="l00444"></a>00444   <span class="keywordflow">return</span>;
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446 <span class="comment">/*****************************************************************************/</span>
<a name="l00447"></a>00447 
<a name="l00448"></a>00448 <span class="comment">/*****************************************************************************/</span>
<a name="l00455"></a><a class="code" href="vol_8h.html#ab6c8fe364e495214eb0273a4deac062d">00455</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#ab6c8fe364e495214eb0273a4deac062d">svolInfo</a>(<a class="code" href="structSVOL.html">SVOL</a> *svol, FILE *fp) {
<a name="l00456"></a>00456   <span class="keywordflow">if</span>(<a class="code" href="vol_8h.html#a489a4f8e50534af5cf3981b9ea273c37">VOL_TEST</a>) printf(<span class="stringliteral">&quot;svolInfo()\n&quot;</span>);
<a name="l00457"></a>00457   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>&lt;=<a class="code" href="img_8h.html#aaa022c5022b37f3676f2e888f024f848">IMG_STATUS_UNINITIALIZED</a>) {
<a name="l00458"></a>00458     fprintf(fp, <span class="stringliteral">&quot;Volume data is not initialized.\n&quot;</span>); <span class="keywordflow">return</span>;}
<a name="l00459"></a>00459   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>==<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>) {
<a name="l00460"></a>00460     fprintf(fp, <span class="stringliteral">&quot;Volume data is initialized but empty.\n&quot;</span>); <span class="keywordflow">return</span>;}
<a name="l00461"></a>00461   <span class="keywordflow">if</span>(svol-&gt;<a class="code" href="structSVOL.html#abab75c9bd9db9239446e4992b3306c4e">status</a>==<a class="code" href="img_8h.html#aed73bfdf4ad84974fe206b683972cb9d">IMG_STATUS_ERROR</a>) fprintf(stdout, <span class="stringliteral">&quot;Volume data has errors.\n&quot;</span>);
<a name="l00462"></a>00462   fprintf(fp, <span class="stringliteral">&quot;Volume status: %s\n&quot;</span>, svol-&gt;<a class="code" href="structSVOL.html#ac6e5d2b91b1f95a26830486f70192775">statmsg</a>);
<a name="l00463"></a>00463   fprintf(fp, <span class="stringliteral">&quot;Patient orientation: %d\n&quot;</span>, svol-&gt;<a class="code" href="structSVOL.html#a29c52139a6e978f2b1c95b6e07be97c5">orientation</a>);
<a name="l00464"></a>00464   fprintf(fp, <span class="stringliteral">&quot;Voxel sizes (x, y, z): %g %g %g mm\n&quot;</span>,
<a name="l00465"></a>00465     svol-&gt;<a class="code" href="structSVOL.html#ad1d7e0807670f9363c98f2d7513acb7b">sizex</a>, svol-&gt;<a class="code" href="structSVOL.html#a046364e1c8f04480e6e286ed1c6d7964">sizey</a>, svol-&gt;<a class="code" href="structSVOL.html#a685b7ab2ce3f0b3db66f4dbb56077ce4">sizez</a>);
<a name="l00466"></a>00466   fprintf(fp, <span class="stringliteral">&quot;Dimensions (x, y, z): %d %d %d\n&quot;</span>,
<a name="l00467"></a>00467     svol-&gt;<a class="code" href="structSVOL.html#a0acec3f4ea23bb446fe4ad1d5ed2ad73">dimx</a>, svol-&gt;<a class="code" href="structSVOL.html#a9fbfaaf7cb507fc5b671e7e499aa2889">dimy</a>, svol-&gt;<a class="code" href="structSVOL.html#a26ab4c04267d695d52e0cf0d09b96319">dimz</a>);
<a name="l00468"></a>00468   fprintf(fp, <span class="stringliteral">&quot;Scale factor: %g\n&quot;</span>, svol-&gt;<a class="code" href="structSVOL.html#ab9a127085156ad3668b35d405e257f5f">scale_factor</a>);
<a name="l00469"></a>00469   <span class="keywordflow">return</span>;
<a name="l00470"></a>00470 }
<a name="l00471"></a>00471 <span class="comment">/*****************************************************************************/</span>
<a name="l00472"></a>00472 
<a name="l00473"></a>00473 <span class="comment">/*****************************************************************************/</span>
<a name="l00480"></a><a class="code" href="vol_8h.html#a254213af969bbc3b01b209f8f46a5742">00480</a> <span class="keywordtype">void</span> <a class="code" href="vol_8c.html#a254213af969bbc3b01b209f8f46a5742">volContents</a>(<a class="code" href="structVOL.html">VOL</a> *vol, <a class="code" href="structVOL__RANGE.html">VOL_RANGE</a> r, FILE *fp) {
<a name="l00481"></a>00481   <span class="keywordtype">int</span> zi, yi, xi;
<a name="l00482"></a>00482 
<a name="l00483"></a>00483   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>;
<a name="l00484"></a>00484   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>&lt;1) <span class="keywordflow">return</span>;
<a name="l00485"></a>00485   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>) <span class="keywordflow">return</span>;
<a name="l00486"></a>00486   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>) <span class="keywordflow">return</span>;
<a name="l00487"></a>00487 
<a name="l00488"></a>00488   <span class="keywordflow">for</span>(zi=r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>-1; zi&lt;r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>; zi++) {
<a name="l00489"></a>00489     fprintf(fp, <span class="stringliteral">&quot;pl=%03d &quot;</span>, zi+1);
<a name="l00490"></a>00490     <span class="keywordflow">for</span>(xi=r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>-1; xi&lt;r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>; xi++) fprintf(fp, <span class="stringliteral">&quot; x=%05d&quot;</span>, xi+1);
<a name="l00491"></a>00491     fprintf(fp, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00492"></a>00492     <span class="keywordflow">for</span>(yi=r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>-1; yi&lt;r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>; yi++) {
<a name="l00493"></a>00493       fprintf(fp, <span class="stringliteral">&quot;y=%05d&quot;</span>, yi+1);
<a name="l00494"></a>00494       <span class="keywordflow">for</span>(xi=r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>-1; xi&lt;r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>; xi++)
<a name="l00495"></a>00495         fprintf(fp, <span class="stringliteral">&quot; %7.3f&quot;</span>, vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi]);
<a name="l00496"></a>00496       fprintf(fp, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00497"></a>00497     }
<a name="l00498"></a>00498   }
<a name="l00499"></a>00499 }
<a name="l00500"></a>00500 <span class="comment">/*****************************************************************************/</span>
<a name="l00501"></a>00501 
<a name="l00502"></a>00502 <span class="comment">/*****************************************************************************/</span>
<a name="l00513"></a><a class="code" href="vol_8h.html#a103ff5054657bc65dba9ac5987a694a6">00513</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#a103ff5054657bc65dba9ac5987a694a6">volMax</a>(<a class="code" href="structVOL.html">VOL</a> *vol, <a class="code" href="structVOL__RANGE.html">VOL_RANGE</a> r, <a class="code" href="structVOL__PIXEL.html">VOL_PIXEL</a> *p, <span class="keywordtype">float</span> *maxv) {
<a name="l00514"></a>00514   <span class="keywordtype">int</span> zi, yi, xi;
<a name="l00515"></a>00515 
<a name="l00516"></a>00516   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00517"></a>00517   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>&lt;1) <span class="keywordflow">return</span>(2);
<a name="l00518"></a>00518   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>) <span class="keywordflow">return</span>(3);
<a name="l00519"></a>00519   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>) <span class="keywordflow">return</span>(4);
<a name="l00520"></a>00520 
<a name="l00521"></a>00521   zi=r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>-1; yi=r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>-1; xi=r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>-1; *maxv=vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi];
<a name="l00522"></a>00522   <span class="keywordflow">if</span>(p!=NULL) {p-&gt;<a class="code" href="structVOL__PIXEL.html#a814205b30bea56837e9fee66368b73cd">z</a>=zi+1; p-&gt;<a class="code" href="structVOL__PIXEL.html#a87b52b4e7aa4824c3682eb1f29e9a0fc">y</a>=yi+1; p-&gt;<a class="code" href="structVOL__PIXEL.html#a1d7bbcdb8aaddb38f9c6a5dd3d009958">x</a>=xi+1;}
<a name="l00523"></a>00523   <span class="keywordflow">for</span>(zi=r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>-1; zi&lt;r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>; zi++) {
<a name="l00524"></a>00524     <span class="keywordflow">for</span>(yi=r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>-1; yi&lt;r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>; yi++) {
<a name="l00525"></a>00525       <span class="keywordflow">for</span>(xi=r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>-1; xi&lt;r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>; xi++) <span class="keywordflow">if</span>(*maxv&lt;vol-&gt;v[zi][yi][xi]) {
<a name="l00526"></a>00526         *maxv=vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi];
<a name="l00527"></a>00527         <span class="keywordflow">if</span>(p!=NULL) {p-&gt;<a class="code" href="structVOL__PIXEL.html#a814205b30bea56837e9fee66368b73cd">z</a>=zi+1; p-&gt;<a class="code" href="structVOL__PIXEL.html#a87b52b4e7aa4824c3682eb1f29e9a0fc">y</a>=yi+1; p-&gt;<a class="code" href="structVOL__PIXEL.html#a1d7bbcdb8aaddb38f9c6a5dd3d009958">x</a>=xi+1;}
<a name="l00528"></a>00528       }
<a name="l00529"></a>00529     }
<a name="l00530"></a>00530   }
<a name="l00531"></a>00531   <span class="keywordflow">return</span>(0);
<a name="l00532"></a>00532 }
<a name="l00533"></a>00533 <span class="comment">/*****************************************************************************/</span>
<a name="l00534"></a>00534 
<a name="l00535"></a>00535 <span class="comment">/*****************************************************************************/</span>
<a name="l00545"></a><a class="code" href="vol_8h.html#ac3d6465823646c219a5bcb8b188a5206">00545</a> <span class="keywordtype">int</span> <a class="code" href="vol_8c.html#ac3d6465823646c219a5bcb8b188a5206">volAvg</a>(<a class="code" href="structVOL.html">VOL</a> *vol, <a class="code" href="structVOL__RANGE.html">VOL_RANGE</a> r, <span class="keywordtype">float</span> *avg) {
<a name="l00546"></a>00546   <span class="keywordtype">int</span> zi, yi, xi, n=0;
<a name="l00547"></a>00547 
<a name="l00548"></a>00548   <span class="keywordflow">if</span>(vol-&gt;<a class="code" href="structVOL.html#a16d55152891623fe116ef2fbdebbb65c">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span>(1);
<a name="l00549"></a>00549   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>&lt;1 || r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>&lt;1) <span class="keywordflow">return</span>(2);
<a name="l00550"></a>00550   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&lt;r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>) <span class="keywordflow">return</span>(3);
<a name="l00551"></a>00551   <span class="keywordflow">if</span>(r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a68964cf738d37bfb0d3337bc3b79da1d">dimz</a> || r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a4851bbd6955b0f9962766c2a389f1696">dimy</a> || r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>&gt;vol-&gt;<a class="code" href="structVOL.html#a46cf9dc7416d65e53f69b152ae8f241b">dimx</a>) <span class="keywordflow">return</span>(4);
<a name="l00552"></a>00552 
<a name="l00553"></a>00553   *avg=0.0;
<a name="l00554"></a>00554   <span class="keywordflow">for</span>(zi=r.<a class="code" href="structVOL__RANGE.html#a3e579be42555813b011c48b4246c8a46">z1</a>-1; zi&lt;r.<a class="code" href="structVOL__RANGE.html#a8191b2018985003977741b0044b2ffa0">z2</a>; zi++) {
<a name="l00555"></a>00555     <span class="keywordflow">for</span>(yi=r.<a class="code" href="structVOL__RANGE.html#a48251c3222d1c81a90167677b755b39b">y1</a>-1; yi&lt;r.<a class="code" href="structVOL__RANGE.html#a4e3cd17ed8dcd646ae6bd9872576b4e4">y2</a>; yi++) {
<a name="l00556"></a>00556       <span class="keywordflow">for</span>(xi=r.<a class="code" href="structVOL__RANGE.html#a89f99e41b964f9584d2aba97d3060cd0">x1</a>-1; xi&lt;r.<a class="code" href="structVOL__RANGE.html#a1768f56d43613f8280438838e90bb7d7">x2</a>; xi++) {
<a name="l00557"></a>00557         *avg+=vol-&gt;<a class="code" href="structVOL.html#aac6f7246c5f35e220004929a80226118">v</a>[zi][yi][xi]; n++;
<a name="l00558"></a>00558       }
<a name="l00559"></a>00559     }
<a name="l00560"></a>00560   }
<a name="l00561"></a>00561   <span class="keywordflow">if</span>(n&gt;0) *avg/=(float)n;
<a name="l00562"></a>00562   <span class="keywordflow">return</span>(0);
<a name="l00563"></a>00563 }
<a name="l00564"></a>00564 <span class="comment">/*****************************************************************************/</span>
<a name="l00565"></a>00565 
<a name="l00566"></a>00566 <span class="comment">/*****************************************************************************/</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Aug 8 2011 by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>