<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ITK: itkImageBase.h Source File</title> <link href="DoxygenStyle.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 --> <center> <a href="index.html" class="qindex">Main Page</a> <a href="modules.html" class="qindex">Groups</a> <a href="namespaces.html" class="qindex">Namespace List</a> <a href="hierarchy.html" class="qindex">Class Hierarchy</a> <a href="classes.html" class="qindex">Alphabetical List</a> <a href="annotated.html" class="qindex">Compound List</a> <a href="files.html" class="qindex">File List</a> <a href="namespacemembers.html" class="qindex">Namespace Members</a> <a href="functions.html" class="qindex">Compound Members</a> <a href="globals.html" class="qindex">File Members</a> <a href="pages.html" class="qindex">Concepts</a></center> <!-- Generated by Doxygen 1.5.9 --> <div class="navpath"><a class="el" href="dir_02e23d841c198393a6e961e9a0678fff.html">Code</a> » <a class="el" href="dir_ea7fc529ede9a38b0438cf13831ae873.html">Common</a> </div> <div class="contents"> <h1>itkImageBase.h</h1><a href="itkImageBase_8h.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"></span> <a name="l00003"></a>00003 <span class="comment"> Program: Insight Segmentation & Registration Toolkit</span> <a name="l00004"></a>00004 <span class="comment"> Module: $RCSfile: itkImageBase.h,v $</span> <a name="l00005"></a>00005 <span class="comment"> Language: C++</span> <a name="l00006"></a>00006 <span class="comment"> Date: $Date: 2009-02-18 17:40:55 $</span> <a name="l00007"></a>00007 <span class="comment"> Version: $Revision: 1.76 $</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> Copyright (c) Insight Software Consortium. All rights reserved.</span> <a name="l00010"></a>00010 <span class="comment"> See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> Portions of this code are covered under the VTK copyright.</span> <a name="l00013"></a>00013 <span class="comment"> See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.</span> <a name="l00014"></a>00014 <span class="comment"></span> <a name="l00015"></a>00015 <span class="comment"> This software is distributed WITHOUT ANY WARRANTY; without even</span> <a name="l00016"></a>00016 <span class="comment"> the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</span> <a name="l00017"></a>00017 <span class="comment"> PURPOSE. See the above copyright notices for more information.</span> <a name="l00018"></a>00018 <span class="comment"></span> <a name="l00019"></a>00019 <span class="comment">=========================================================================*/</span> <a name="l00020"></a>00020 <span class="preprocessor">#ifndef __itkImageBase_h</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __itkImageBase_h</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="itkDataObject_8h.html">itkDataObject.h</a>"</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="itkImageRegion_8h.html">itkImageRegion.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="itkIndex_8h.html">itkIndex.h</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="itkObjectFactory_8h.html">itkObjectFactory.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="itkOffset_8h.html">itkOffset.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="itkPoint_8h.html">itkPoint.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="itkSize_8h.html">itkSize.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="itkFixedArray_8h.html">itkFixedArray.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="itkPoint_8h.html">itkPoint.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="itkMatrix_8h.html">itkMatrix.h</a>"</span> <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="itkContinuousIndex_8h.html">itkContinuousIndex.h</a>"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="itkImageHelper_8h.html">itkImageHelper.h</a>"</span> <a name="l00036"></a>00036 <span class="preprocessor">#include <vnl/vnl_matrix_fixed.txx></span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="itkImageRegion_8h.html">itkImageRegion.h</a>"</span> <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="preprocessor">#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING</span> <a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="itkImageTransformHelper_8h.html">itkImageTransformHelper.h</a>"</span> <a name="l00042"></a>00042 <span class="preprocessor">#endif</span> <a name="l00043"></a>00043 <span class="preprocessor"></span> <a name="l00044"></a>00044 <span class="keyword">namespace </span>itk <a name="l00045"></a>00045 { <a name="l00046"></a>00046 <a name="l00053"></a>00053 <span class="keyword">template</span> <<span class="keyword">typename</span> TImage> <a name="l00054"></a><a class="code" href="structitk_1_1GetImageDimension.html">00054</a> <span class="keyword">struct </span><a class="code" href="structitk_1_1GetImageDimension.html">GetImageDimension</a> <a name="l00055"></a>00055 { <a name="l00056"></a>00056 <a class="code" href="structitk_1_1GetImageDimension.html#642e321a08aefb98926e6d345936c91c">itkStaticConstMacro</a>(ImageDimension, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>, TImage::ImageDimension); <a name="l00057"></a>00057 }; <a name="l00058"></a>00058 <a name="l00086"></a>00086 <span class="keyword">template</span><<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> VImageDimension=2> <a name="l00087"></a><a class="code" href="classitk_1_1ImageBase.html">00087</a> <span class="keyword">class </span><a class="code" href="itkWin32Header_8h.html#7d4384322557205d75f0719c012dded6">ITK_EXPORT</a> <a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a> : <span class="keyword">public</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a> <a name="l00088"></a>00088 { <a name="l00089"></a>00089 <span class="keyword">public</span>: <a name="l00091"></a><a class="code" href="classitk_1_1ImageBase.html#e6af5001f8a9bce51c6e538432b248f2">00091</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">Self</a>; <a name="l00092"></a><a class="code" href="classitk_1_1ImageBase.html#82be256a725704bc7a49762ccc84a791">00092</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a> <a class="code" href="classitk_1_1Object.html" title="Base class for most itk classes.">Superclass</a>; <a name="l00093"></a><a class="code" href="classitk_1_1ImageBase.html#aca83d549947da66375e2139014a9d54">00093</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1SmartPointer.html">SmartPointer<Self></a> <a class="code" href="classitk_1_1SmartPointer.html">Pointer</a>; <a name="l00094"></a><a class="code" href="classitk_1_1ImageBase.html#c05e6f583d3d8f1423691c0be64c5551">00094</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1SmartPointer.html">SmartPointer<const Self></a> <a class="code" href="classitk_1_1SmartPointer.html">ConstPointer</a>; <a name="l00095"></a>00095 <a name="l00097"></a>00097 <a class="code" href="itkMacro_8h.html#0fdc15685afa271857c57e7cd482f30c">itkNewMacro</a>(<a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">Self</a>); <a name="l00098"></a>00098 <a name="l00100"></a>00100 <a class="code" href="itkMacro_8h.html#574c1f86661d409dd32c742307a0e96a">itkTypeMacro</a>(<a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a>, <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a>); <a name="l00101"></a>00101 <a name="l00106"></a>00106 <a class="code" href="itkMacro_8h.html#1905cf6b2e88235996fa7ff73b2fb0eb">itkStaticConstMacro</a>(ImageDimension, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>, VImageDimension ); <a name="l00107"></a>00107 <a name="l00109"></a><a class="code" href="classitk_1_1ImageBase.html#3e2f0d09f8bfca4218f6cbc9e55a0b9e">00109</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Index.html">Index<VImageDimension></a> <a class="code" href="classitk_1_1Index.html">IndexType</a>; <a name="l00110"></a><a class="code" href="classitk_1_1ImageBase.html#d471614204f0b309681cf22cbaa7f69c">00110</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> IndexType::IndexValueType IndexValueType; <a name="l00111"></a>00111 <a name="l00114"></a><a class="code" href="classitk_1_1ImageBase.html#44467fcff3166caa04add7c57f241160">00114</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Offset.html" title="Represent the offset between two n-dimensional indexes in a n-dimensional image.">Offset<VImageDimension></a> <a class="code" href="classitk_1_1Offset.html" title="Represent the offset between two n-dimensional indexes in a n-dimensional image.">OffsetType</a>; <a name="l00115"></a><a class="code" href="classitk_1_1ImageBase.html#b9c35eb1d7bf223b607700ef7a43bbf7">00115</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> OffsetType::OffsetValueType OffsetValueType; <a name="l00116"></a>00116 <a name="l00118"></a><a class="code" href="classitk_1_1ImageBase.html#a9439472de9c8ded679937f20106dba2">00118</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Size.html">Size<VImageDimension></a> <a class="code" href="classitk_1_1Size.html">SizeType</a>; <a name="l00119"></a><a class="code" href="classitk_1_1ImageBase.html#9d3402b2050110ffafb20c488bccecb7">00119</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> SizeType::SizeValueType SizeValueType; <a name="l00120"></a>00120 <a name="l00122"></a><a class="code" href="classitk_1_1ImageBase.html#49674493674a56a29d05b4cfbf9cda1a">00122</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">ImageRegion<VImageDimension></a> <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a>; <a name="l00123"></a>00123 <a name="l00128"></a><a class="code" href="classitk_1_1ImageBase.html#b4ebc75302e50db40d755359b616b54a">00128</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Vector.html">Vector<double, VImageDimension></a> <a class="code" href="classitk_1_1Vector.html">SpacingType</a>; <a name="l00129"></a>00129 <a name="l00132"></a><a class="code" href="classitk_1_1ImageBase.html#a5e0d1c7e4d5dcad37cff5c72bffb821">00132</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Point.html">Point<double, VImageDimension></a> <a class="code" href="classitk_1_1Point.html">PointType</a>; <a name="l00133"></a>00133 <a name="l00137"></a><a class="code" href="classitk_1_1ImageBase.html#cffa61ab2d11dc9c228042c286674d75">00137</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Matrix.html">Matrix<double, VImageDimension, VImageDimension></a> <a class="code" href="classitk_1_1Matrix.html">DirectionType</a>; <a name="l00138"></a>00138 <a name="l00140"></a>00140 <span class="keywordtype">void</span> Initialize(); <a name="l00141"></a>00141 <a name="l00143"></a><a class="code" href="classitk_1_1ImageBase.html#e718fb44710e150dd807e78a8bdbe5e3">00143</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structitk_1_1GetImageDimension.html">GetImageDimension</a>() <a name="l00144"></a>00144 { <span class="keywordflow">return</span> VImageDimension; } <a name="l00145"></a>00145 <a name="l00150"></a>00150 <a class="code" href="itkMacro_8h.html#7ebdd33cc5e7d74720ced9099c034faa">itkSetMacro</a>(Origin, PointType); <a name="l00151"></a>00151 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetOrigin( <span class="keyword">const</span> <span class="keywordtype">double</span> origin[VImageDimension] ); <a name="l00152"></a>00152 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetOrigin( <span class="keyword">const</span> <span class="keywordtype">float</span> origin[VImageDimension] ); <a name="l00154"></a>00154 <a name="l00181"></a>00181 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetDirection( <span class="keyword">const</span> DirectionType direction ); <a name="l00182"></a>00182 <a name="l00186"></a>00186 <a class="code" href="itkMacro_8h.html#7d989c13a1a213168db99ae0f84185d4">itkGetConstReferenceMacro</a>(Direction, DirectionType); <a name="l00187"></a>00187 <a name="l00192"></a>00192 <a class="code" href="itkMacro_8h.html#7d989c13a1a213168db99ae0f84185d4">itkGetConstReferenceMacro</a>(Spacing, SpacingType); <a name="l00193"></a>00193 <a name="l00198"></a>00198 <a class="code" href="itkMacro_8h.html#7d989c13a1a213168db99ae0f84185d4">itkGetConstReferenceMacro</a>(Origin, PointType); <a name="l00199"></a>00199 <a name="l00206"></a>00206 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetLargestPossibleRegion(<span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#ed8c4a40607d317c666eb96ea265e126">RegionType</a> &region); <a name="l00207"></a>00207 <a name="l00214"></a><a class="code" href="classitk_1_1ImageBase.html#2ea91d1d08178b6cce7e65a099ea272b">00214</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a>& GetLargestPossibleRegion()<span class="keyword"> const</span> <a name="l00215"></a>00215 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_LargestPossibleRegion;}; <a name="l00216"></a>00216 <a name="l00220"></a>00220 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetBufferedRegion(<span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#ed8c4a40607d317c666eb96ea265e126">RegionType</a> &region); <a name="l00221"></a>00221 <a name="l00225"></a><a class="code" href="classitk_1_1ImageBase.html#bb2a8342cd8793694d77aefade6e32f2">00225</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a>& GetBufferedRegion()<span class="keyword"> const</span> <a name="l00226"></a>00226 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_BufferedRegion;}; <a name="l00227"></a>00227 <a name="l00235"></a>00235 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetRequestedRegion(<span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#ed8c4a40607d317c666eb96ea265e126">RegionType</a> &region); <a name="l00236"></a>00236 <a name="l00244"></a>00244 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetRequestedRegion(<a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a> *data); <a name="l00245"></a>00245 <a name="l00250"></a><a class="code" href="classitk_1_1ImageBase.html#14769ccb89e9830f8128e09bf022b174">00250</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a>& GetRequestedRegion()<span class="keyword"> const</span> <a name="l00251"></a>00251 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_RequestedRegion;}; <a name="l00252"></a>00252 <a name="l00263"></a><a class="code" href="classitk_1_1ImageBase.html#d5f28c77a2cee7e6b131766b6b27caf5">00263</a> <span class="keyword">const</span> OffsetValueType *<a class="code" href="classitk_1_1ImageBase.html#d5f28c77a2cee7e6b131766b6b27caf5">GetOffsetTable</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_OffsetTable; }; <a name="l00265"></a>00265 <a name="l00274"></a>00274 <span class="preprocessor">#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING</span> <a name="l00275"></a>00275 <span class="preprocessor"></span> <span class="keyword">inline</span> OffsetValueType ComputeOffset(<span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> &ind)<span class="keyword"> const</span> <a name="l00276"></a>00276 <span class="keyword"> </span>{ <a name="l00277"></a>00277 OffsetValueType offset = 0; <a name="l00278"></a>00278 <a class="code" href="classitk_1_1ImageHelper.html" title="Fast Index/Offset computation.">ImageHelper<VImageDimension,VImageDimension>::ComputeOffset</a>(this->GetBufferedRegion().GetIndex(), <a name="l00279"></a>00279 ind, <a name="l00280"></a>00280 m_OffsetTable, <a name="l00281"></a>00281 offset); <a name="l00282"></a>00282 <span class="keywordflow">return</span> offset; <a name="l00283"></a>00283 } <a name="l00284"></a>00284 <span class="preprocessor">#else</span> <a name="l00285"></a><a class="code" href="classitk_1_1ImageBase.html#4f5d5eec6ff926db717a59fb63cdf10d">00285</a> <span class="preprocessor"></span> OffsetValueType ComputeOffset(<span class="keyword">const</span> <a class="code" href="classitk_1_1Index.html">IndexType</a> &ind)<span class="keyword"> const</span> <a name="l00286"></a>00286 <span class="keyword"> </span>{ <a name="l00287"></a>00287 <span class="comment">// need to add bounds checking for the region/buffer?</span> <a name="l00288"></a>00288 OffsetValueType offset=0; <a name="l00289"></a>00289 <span class="keyword">const</span> <a class="code" href="classitk_1_1Index.html">IndexType</a> &bufferedRegionIndex = this->GetBufferedRegion().GetIndex(); <a name="l00290"></a>00290 <a name="l00291"></a>00291 <span class="comment">// data is arranged as [][][][slice][row][col]</span> <a name="l00292"></a>00292 <span class="comment">// with Index[0] = col, Index[1] = row, Index[2] = slice</span> <a name="l00293"></a>00293 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=VImageDimension-1; i > 0; i--) <a name="l00294"></a>00294 { <a name="l00295"></a>00295 offset += (ind[i] - bufferedRegionIndex[i])*m_OffsetTable[i]; <a name="l00296"></a>00296 } <a name="l00297"></a>00297 offset += (ind[0] - bufferedRegionIndex[0]); <a name="l00298"></a>00298 <a name="l00299"></a>00299 <span class="keywordflow">return</span> offset; <a name="l00300"></a>00300 } <a name="l00301"></a>00301 <span class="preprocessor">#endif</span> <a name="l00302"></a>00302 <span class="preprocessor"></span> <a name="l00309"></a>00309 <span class="preprocessor">#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING</span> <a name="l00310"></a>00310 <span class="preprocessor"></span> <span class="keyword">inline</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> ComputeIndex(OffsetValueType offset)<span class="keyword"> const</span> <a name="l00311"></a>00311 <span class="keyword"> </span>{ <a name="l00312"></a>00312 <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> index; <a name="l00313"></a>00313 <span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> &bufferedRegionIndex = this->GetBufferedRegion().GetIndex(); <a name="l00314"></a>00314 <a class="code" href="classitk_1_1ImageHelper.html" title="Fast Index/Offset computation.">ImageHelper<VImageDimension,VImageDimension>::ComputeIndex</a>(bufferedRegionIndex, <a name="l00315"></a>00315 offset, <a name="l00316"></a>00316 m_OffsetTable, <a name="l00317"></a>00317 index); <a name="l00318"></a>00318 <span class="keywordflow">return</span> index; <a name="l00319"></a>00319 } <a name="l00320"></a>00320 <span class="preprocessor">#else</span> <a name="l00321"></a><a class="code" href="classitk_1_1ImageBase.html#76d5d3496d21025ded6daa3099cab7bf">00321</a> <span class="preprocessor"></span> <a class="code" href="classitk_1_1Index.html">IndexType</a> ComputeIndex(OffsetValueType offset)<span class="keyword"> const</span> <a name="l00322"></a>00322 <span class="keyword"> </span>{ <a name="l00323"></a>00323 <a class="code" href="classitk_1_1Index.html">IndexType</a> index; <a name="l00324"></a>00324 <span class="keyword">const</span> <a class="code" href="classitk_1_1Index.html">IndexType</a> &bufferedRegionIndex = this->GetBufferedRegion().GetIndex(); <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=VImageDimension-1; i > 0; i--) <a name="l00328"></a>00328 { <a name="l00329"></a>00329 index[i] = <span class="keyword">static_cast<</span>IndexValueType<span class="keyword">></span>(offset / m_OffsetTable[i]); <a name="l00330"></a>00330 offset -= (index[i] * m_OffsetTable[i]); <a name="l00331"></a>00331 index[i] += bufferedRegionIndex[i]; <a name="l00332"></a>00332 } <a name="l00333"></a>00333 index[0] = bufferedRegionIndex[0] + <span class="keyword">static_cast<</span>IndexValueType<span class="keyword">></span>(offset); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordflow">return</span> index; <a name="l00336"></a>00336 } <a name="l00337"></a>00337 <span class="preprocessor">#endif</span> <a name="l00338"></a>00338 <span class="preprocessor"></span> <a name="l00345"></a>00345 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetSpacing (<span class="keyword">const</span> SpacingType & spacing); <a name="l00346"></a>00346 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetSpacing (<span class="keyword">const</span> <span class="keywordtype">double</span> spacing[VImageDimension]); <a name="l00347"></a>00347 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetSpacing (<span class="keyword">const</span> <span class="keywordtype">float</span> spacing[VImageDimension]); <a name="l00349"></a>00349 <a name="l00350"></a>00350 <a name="l00355"></a>00355 <span class="preprocessor">#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING</span> <a name="l00356"></a>00356 <span class="preprocessor"></span> <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00357"></a>00357 <span class="keywordtype">bool</span> TransformPhysicalPointToIndex( <a name="l00358"></a>00358 <span class="keyword">const</span> <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point, <a name="l00359"></a>00359 <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> & index )<span class="keyword"> const</span> <a name="l00360"></a>00360 <span class="keyword"> </span>{ <a name="l00361"></a>00361 <a class="code" href="classitk_1_1ImageTransformHelper.html" title="Fast index/physical index computation.">ImageTransformHelper<VImageDimension,VImageDimension-1,VImageDimension-1>::TransformPhysicalPointToIndex</a>( <a name="l00362"></a>00362 this->m_PhysicalPointToIndex, this->m_Origin, point, index); <a name="l00363"></a>00363 <a name="l00364"></a>00364 <span class="comment">// Now, check to see if the index is within allowed bounds</span> <a name="l00365"></a>00365 <span class="keyword">const</span> <span class="keywordtype">bool</span> isInside = this->GetLargestPossibleRegion().IsInside( index ); <a name="l00366"></a>00366 <span class="keywordflow">return</span> isInside; <a name="l00367"></a>00367 } <a name="l00368"></a>00368 <span class="preprocessor">#else</span> <a name="l00369"></a>00369 <span class="preprocessor"></span> <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00370"></a><a class="code" href="classitk_1_1ImageBase.html#5a22aaf149e153ee865ddb0a7997d5a7">00370</a> <span class="keywordtype">bool</span> TransformPhysicalPointToIndex( <a name="l00371"></a>00371 <span class="keyword">const</span> <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point, <a name="l00372"></a>00372 <a class="code" href="classitk_1_1Index.html">IndexType</a> & index )<span class="keyword"> const</span> <a name="l00373"></a>00373 <span class="keyword"> </span>{ <a name="l00374"></a>00374 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < VImageDimension; i++) <a name="l00375"></a>00375 { <a name="l00376"></a>00376 TCoordRep sum = NumericTraits<TCoordRep>::Zero; <a name="l00377"></a>00377 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j < VImageDimension; j++) <a name="l00378"></a>00378 { <a name="l00379"></a>00379 sum += this->m_PhysicalPointToIndex[i][j] * (point[j] - this->m_Origin[j]); <a name="l00380"></a>00380 } <a name="l00381"></a>00381 index[i] = <span class="keyword">static_cast<</span> IndexValueType<span class="keyword">></span>( sum ); <a name="l00382"></a>00382 } <a name="l00383"></a>00383 <a name="l00384"></a>00384 <span class="comment">// Now, check to see if the index is within allowed bounds</span> <a name="l00385"></a>00385 <span class="keyword">const</span> <span class="keywordtype">bool</span> isInside = this->GetLargestPossibleRegion().IsInside( index ); <a name="l00386"></a>00386 <a name="l00387"></a>00387 <span class="keywordflow">return</span> isInside; <a name="l00388"></a>00388 } <a name="l00389"></a>00389 <span class="preprocessor">#endif</span> <a name="l00390"></a>00390 <span class="preprocessor"></span> <a name="l00395"></a>00395 <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00396"></a><a class="code" href="classitk_1_1ImageBase.html#200afb13c240236faccce0095469e963">00396</a> <span class="keywordtype">bool</span> TransformPhysicalPointToContinuousIndex( <a name="l00397"></a>00397 <span class="keyword">const</span> <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point, <a name="l00398"></a>00398 <a class="code" href="classitk_1_1ContinuousIndex.html" title="A templated class holding a point in n-Dimensional image space.">ContinuousIndex<TCoordRep, VImageDimension></a>& index )<span class="keyword"> const</span> <a name="l00399"></a>00399 <span class="keyword"> </span>{ <a name="l00400"></a>00400 <a class="code" href="classitk_1_1Vector.html">Vector<double, VImageDimension></a> cvector; <a name="l00401"></a>00401 <a name="l00402"></a>00402 <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0; k < VImageDimension; k++ ) <a name="l00403"></a>00403 { <a name="l00404"></a>00404 cvector[k] = point[k] - this->m_Origin[k]; <a name="l00405"></a>00405 } <a name="l00406"></a>00406 cvector = m_PhysicalPointToIndex * cvector; <a name="l00407"></a>00407 <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < VImageDimension; i++ ) <a name="l00408"></a>00408 { <a name="l00409"></a>00409 index[i] = <span class="keyword">static_cast<</span>TCoordRep<span class="keyword">></span>(cvector[i]); <a name="l00410"></a>00410 } <a name="l00411"></a>00411 <a name="l00412"></a>00412 <span class="comment">// Now, check to see if the index is within allowed bounds</span> <a name="l00413"></a>00413 <span class="keyword">const</span> <span class="keywordtype">bool</span> isInside = this->GetLargestPossibleRegion().IsInside( index ); <a name="l00414"></a>00414 <a name="l00415"></a>00415 <span class="keywordflow">return</span> isInside; <a name="l00416"></a>00416 } <a name="l00417"></a>00417 <a name="l00418"></a>00418 <a name="l00423"></a>00423 <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00424"></a><a class="code" href="classitk_1_1ImageBase.html#aeda52e6d38fce7b1d438b34f9e7dff8">00424</a> <span class="keywordtype">void</span> TransformContinuousIndexToPhysicalPoint( <a name="l00425"></a>00425 <span class="keyword">const</span> <a class="code" href="classitk_1_1ContinuousIndex.html" title="A templated class holding a point in n-Dimensional image space.">ContinuousIndex<TCoordRep, VImageDimension></a>& index, <a name="l00426"></a>00426 <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point )<span class="keyword"> const</span> <a name="l00427"></a>00427 <span class="keyword"> </span>{ <a name="l00428"></a>00428 <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> r=0; r<VImageDimension; r++) <a name="l00429"></a>00429 { <a name="l00430"></a>00430 TCoordRep sum = NumericTraits<TCoordRep>::Zero; <a name="l00431"></a>00431 <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> c=0; c<VImageDimension; c++ ) <a name="l00432"></a>00432 { <a name="l00433"></a>00433 sum += this->m_IndexToPhysicalPoint(r,c) * index[c]; <a name="l00434"></a>00434 } <a name="l00435"></a>00435 point[r] = sum + this->m_Origin[r]; <a name="l00436"></a>00436 } <a name="l00437"></a>00437 } <a name="l00439"></a>00439 <a name="l00445"></a>00445 <span class="preprocessor">#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING</span> <a name="l00446"></a>00446 <span class="preprocessor"></span> <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00447"></a>00447 <span class="keywordtype">void</span> TransformIndexToPhysicalPoint( <a name="l00448"></a>00448 <span class="keyword">const</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#be32dc19e71d40322ad9828b9ab40853">IndexType</a> & index, <a name="l00449"></a>00449 <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point )<span class="keyword"> const</span> <a name="l00450"></a>00450 <span class="keyword"> </span>{ <a name="l00451"></a>00451 <a class="code" href="classitk_1_1ImageTransformHelper.html" title="Fast index/physical index computation.">ImageTransformHelper<VImageDimension,VImageDimension-1,VImageDimension-1>::TransformIndexToPhysicalPoint</a>( <a name="l00452"></a>00452 this->m_IndexToPhysicalPoint, this->m_Origin, index, point); <a name="l00453"></a>00453 } <a name="l00454"></a>00454 <span class="preprocessor">#else</span> <a name="l00455"></a>00455 <span class="preprocessor"></span> <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00456"></a><a class="code" href="classitk_1_1ImageBase.html#fc839cf1ab6d1ea3f05d70f175603430">00456</a> <span class="keywordtype">void</span> TransformIndexToPhysicalPoint( <a name="l00457"></a>00457 <span class="keyword">const</span> <a class="code" href="classitk_1_1Index.html">IndexType</a> & index, <a name="l00458"></a>00458 <a class="code" href="classitk_1_1Point.html" title="A templated class holding a geometric point in n-Dimensional space.">Point<TCoordRep, VImageDimension></a>& point )<span class="keyword"> const</span> <a name="l00459"></a>00459 <span class="keyword"> </span>{ <a name="l00460"></a>00460 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < VImageDimension; i++) <a name="l00461"></a>00461 { <a name="l00462"></a>00462 point[i] = this->m_Origin[i]; <a name="l00463"></a>00463 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j < VImageDimension; j++) <a name="l00464"></a>00464 { <a name="l00465"></a>00465 point[i] += m_IndexToPhysicalPoint[i][j] * index[j]; <a name="l00466"></a>00466 } <a name="l00467"></a>00467 } <a name="l00468"></a>00468 } <a name="l00469"></a>00469 <span class="preprocessor">#endif</span> <a name="l00470"></a>00470 <span class="preprocessor"></span> <a name="l00471"></a>00471 <a name="l00472"></a>00472 <a name="l00490"></a>00490 <span class="keyword">template</span><<span class="keyword">class</span> TCoordRep> <a name="l00491"></a><a class="code" href="classitk_1_1ImageBase.html#8ed4009b665f9cffd4314eff820675da">00491</a> <span class="keywordtype">void</span> TransformLocalVectorToPhysicalVector( <a name="l00492"></a>00492 <span class="keyword">const</span> <a class="code" href="classitk_1_1FixedArray.html" title="Simulate a standard C array with copy semnatics.">FixedArray<TCoordRep, VImageDimension></a> & inputGradient, <a name="l00493"></a>00493 <a class="code" href="classitk_1_1FixedArray.html" title="Simulate a standard C array with copy semnatics.">FixedArray<TCoordRep, VImageDimension></a> & outputGradient )<span class="keyword"> const</span> <a name="l00494"></a>00494 <span class="keyword"> </span>{ <a name="l00495"></a>00495 <span class="comment">//</span> <a name="l00496"></a>00496 <span class="comment">// This temporary implementation should be replaced with Template MetaProgramming.</span> <a name="l00497"></a>00497 <span class="comment">// </span> <a name="l00498"></a>00498 <span class="preprocessor">#ifdef ITK_USE_ORIENTED_IMAGE_DIRECTION</span> <a name="l00499"></a>00499 <span class="preprocessor"></span> <span class="keyword">const</span> <a class="code" href="classitk_1_1Matrix.html">DirectionType</a> & direction = this->GetDirection(); <a name="l00500"></a>00500 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < VImageDimension; i++) <a name="l00501"></a>00501 { <a name="l00502"></a>00502 <span class="keyword">typedef</span> <span class="keyword">typename</span> NumericTraits<TCoordRep>::AccumulateType CoordSumType; <a name="l00503"></a>00503 CoordSumType sum = NumericTraits<CoordSumType>::Zero; <a name="l00504"></a>00504 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j < VImageDimension; j++) <a name="l00505"></a>00505 { <a name="l00506"></a>00506 sum += direction[i][j] * inputGradient[j]; <a name="l00507"></a>00507 } <a name="l00508"></a>00508 outputGradient[i] = <span class="keyword">static_cast<</span>TCoordRep<span class="keyword">></span>( sum ); <a name="l00509"></a>00509 } <a name="l00510"></a>00510 <span class="preprocessor">#else</span> <a name="l00511"></a>00511 <span class="preprocessor"></span> <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < VImageDimension; i++) <a name="l00512"></a>00512 { <a name="l00513"></a>00513 outputGradient[i] = inputGradient[i]; <a name="l00514"></a>00514 } <a name="l00515"></a>00515 <span class="preprocessor">#endif</span> <a name="l00516"></a>00516 <span class="preprocessor"></span> } <a name="l00518"></a>00518 <a name="l00528"></a>00528 <span class="keyword">virtual</span> <span class="keywordtype">void</span> CopyInformation(<span class="keyword">const</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a> *data); <a name="l00529"></a>00529 <a name="l00540"></a>00540 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Graft(<span class="keyword">const</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">DataObject</a> *data); <a name="l00541"></a>00541 <a name="l00549"></a>00549 <span class="keyword">virtual</span> <span class="keywordtype">void</span> UpdateOutputInformation(); <a name="l00550"></a>00550 <a name="l00554"></a>00554 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetRequestedRegionToLargestPossibleRegion(); <a name="l00555"></a>00555 <a name="l00565"></a>00565 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> RequestedRegionIsOutsideOfTheBufferedRegion(); <a name="l00566"></a>00566 <a name="l00575"></a>00575 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> VerifyRequestedRegion(); <a name="l00576"></a>00576 <a name="l00593"></a>00593 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetNumberOfComponentsPerPixel() <span class="keyword">const</span>; <a name="l00594"></a>00594 <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetNumberOfComponentsPerPixel( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ); <a name="l00596"></a>00596 <a name="l00597"></a>00597 <span class="keyword">protected</span>: <a name="l00598"></a>00598 <a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a>(); <a name="l00599"></a>00599 ~<a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a>(); <a name="l00600"></a>00600 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="namespaceHardConnectedComponentImageFilter.html#920ae03048a5ad715d803ca2e92b52de">PrintSelf</a>(std::ostream& os, <a class="code" href="classitk_1_1Indent.html" title="Control indentation during Print() invocation.">Indent</a> indent) <span class="keyword">const</span>; <a name="l00601"></a>00601 <a name="l00606"></a>00606 <span class="keywordtype">void</span> ComputeOffsetTable(); <a name="l00607"></a>00607 <a name="l00613"></a>00613 <span class="keyword">virtual</span> <span class="keywordtype">void</span> ComputeIndexToPhysicalPointMatrices(); <a name="l00614"></a>00614 <a name="l00615"></a>00615 <span class="keyword">protected</span>: <a name="l00619"></a><a class="code" href="classitk_1_1ImageBase.html#d29f29882586fd3e604c0ef16449661a">00619</a> <a class="code" href="classitk_1_1Vector.html">SpacingType</a> m_Spacing; <a name="l00620"></a><a class="code" href="classitk_1_1ImageBase.html#25875d37af3d05f237f7483c28050da2">00620</a> <a class="code" href="classitk_1_1Point.html">PointType</a> m_Origin; <a name="l00621"></a><a class="code" href="classitk_1_1ImageBase.html#4ed2eb89e744ab0f454e383d58dc29d3">00621</a> <a class="code" href="classitk_1_1Matrix.html">DirectionType</a> m_Direction; <a name="l00622"></a>00622 <a name="l00625"></a><a class="code" href="classitk_1_1ImageBase.html#3889743d03853bc684b4cd255a7d65ae">00625</a> <a class="code" href="classitk_1_1Matrix.html">DirectionType</a> m_IndexToPhysicalPoint; <a name="l00626"></a><a class="code" href="classitk_1_1ImageBase.html#4f277b9006ff2b6cc000b2ec035e4864">00626</a> <a class="code" href="classitk_1_1Matrix.html">DirectionType</a> m_PhysicalPointToIndex; <a name="l00627"></a>00627 <a name="l00632"></a>00632 <span class="keyword">virtual</span> <span class="keywordtype">void</span> InitializeBufferedRegion(<span class="keywordtype">void</span>); <a name="l00633"></a>00633 <a name="l00634"></a>00634 <span class="keyword">private</span>: <a name="l00635"></a>00635 <a class="code" href="classitk_1_1ImageBase.html" title="Base class for templated image classes.">ImageBase</a>(<span class="keyword">const</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">Self</a>&); <span class="comment">//purposely not implemented</span> <a name="l00636"></a>00636 <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <a class="code" href="classitk_1_1DataObject.html" title="Base class for all data objects in ITK.">Self</a>&); <span class="comment">//purposely not implemented</span> <a name="l00637"></a>00637 <a name="l00638"></a>00638 OffsetValueType m_OffsetTable[VImageDimension+1]; <a name="l00639"></a>00639 <a name="l00640"></a>00640 <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a> m_LargestPossibleRegion; <a name="l00641"></a>00641 <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a> m_RequestedRegion; <a name="l00642"></a>00642 <a class="code" href="classitk_1_1ImageRegion.html" title="An image region represents a structured region of data.">RegionType</a> m_BufferedRegion; <a name="l00643"></a>00643 <a name="l00644"></a>00644 }; <a name="l00645"></a>00645 <a name="l00646"></a>00646 } <span class="comment">// end namespace itk</span> <a name="l00647"></a>00647 <a name="l00648"></a>00648 <span class="comment">// Define instantiation macro for this template.</span> <a name="l00649"></a><a class="code" href="itkImageBase_8h.html#7cf7ed035591d5217dda6206efd27280">00649</a> <span class="preprocessor">#define ITK_TEMPLATE_ImageBase(_, EXPORT, x, y) namespace itk { \</span> <a name="l00650"></a>00650 <span class="preprocessor"> _(1(class EXPORT ImageBase< ITK_TEMPLATE_1 x >)) \</span> <a name="l00651"></a>00651 <span class="preprocessor"> namespace Templates { typedef ImageBase< ITK_TEMPLATE_1 x > ImageBase##y; } \</span> <a name="l00652"></a>00652 <span class="preprocessor"> }</span> <a name="l00653"></a>00653 <span class="preprocessor"></span> <a name="l00654"></a>00654 <span class="preprocessor">#if ITK_TEMPLATE_EXPLICIT</span> <a name="l00655"></a>00655 <span class="preprocessor"></span><span class="preprocessor"># include "Templates/itkImageBase+-.h"</span> <a name="l00656"></a>00656 <span class="preprocessor">#endif</span> <a name="l00657"></a>00657 <span class="preprocessor"></span> <a name="l00658"></a>00658 <span class="preprocessor">#if ITK_TEMPLATE_TXX</span> <a name="l00659"></a>00659 <span class="preprocessor"></span><span class="preprocessor"># include "itkImageBase.txx"</span> <a name="l00660"></a>00660 <span class="preprocessor">#endif</span> <a name="l00661"></a>00661 <span class="preprocessor"></span> <a name="l00662"></a>00662 <span class="preprocessor">#endif</span> <a name="l00663"></a>00663 <span class="preprocessor"></span> </pre></div></div> <hr><address><small> Generated at Thu May 7 23:01:32 2009 for ITK by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53> </a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2000</small></address> </body> </html>