Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNarrowBandImageFilterBase.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNarrowBandImageFilterBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:52 $ 00007 Version: $Revision: 1.9 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkNarrowBandImageFilterBase_h_ 00018 #define __itkNarrowBandImageFilterBase_h_ 00019 00020 #include "itkFiniteDifferenceImageFilter.h" 00021 #include "itkMultiThreader.h" 00022 #include "itkNarrowBand.h" 00023 #include "itkBarrier.h" 00024 #include "itkObjectStore.h" 00025 00026 namespace itk { 00027 00065 template <class TInputImage, class TOutputImage> 00066 class NarrowBandImageFilterBase 00067 : public FiniteDifferenceImageFilter<TInputImage, TOutputImage> 00068 { 00069 public: 00071 typedef NarrowBandImageFilterBase Self; 00072 typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass; 00073 typedef SmartPointer<Self> Pointer; 00074 typedef SmartPointer<const Self> ConstPointer; 00075 00077 itkTypeMacro(NarrowBandImageFilterBase, ImageToImageFilter ); 00078 00080 typedef typename Superclass::InputImageType InputImageType; 00081 typedef typename Superclass::OutputImageType OutputImageType; 00082 typedef typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType; 00083 00086 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); 00087 00090 typedef typename Superclass::PixelType PixelType; 00091 00093 typedef typename Superclass::TimeStepType TimeStepType; 00094 00096 typedef typename OutputImageType::IndexType IndexType; 00097 00100 typedef typename OutputImageType::ValueType ValueType; 00101 00103 typedef BandNode<IndexType,PixelType> BandNodeType; 00104 00106 typedef NarrowBand<BandNodeType> NarrowBandType; 00107 typedef typename NarrowBandType::Pointer NarrowBandPointer; 00108 typedef typename NarrowBandType::RegionType RegionType; 00109 00111 itkSetMacro( IsoSurfaceValue, ValueType); 00112 itkGetMacro( IsoSurfaceValue, ValueType); 00113 00115 // itkGetMacro( RMSChange, ValueType); 00116 00121 void InsertNarrowBandNode (BandNodeType &node) 00122 { 00123 m_NarrowBand->PushBack(node); // add new node 00124 this->Modified(); 00125 }; 00126 void InsertNarrowBandNode (IndexType &index) 00127 { 00128 BandNodeType tmpnode; 00129 tmpnode.m_Index = index; 00130 m_NarrowBand->PushBack(tmpnode); 00131 this->Modified(); 00132 }; 00133 void InsertNarrowBandNode (IndexType &index, PixelType &value, signed char &nodestate) 00134 { 00135 BandNodeType tmpnode; 00136 tmpnode.m_Data = value; 00137 tmpnode.m_Index = index; 00138 tmpnode.m_NodeState = nodestate; 00139 00140 m_NarrowBand->PushBack(tmpnode); 00141 this->Modified(); 00142 }; 00143 00148 void SetNarrowBandTotalRadius (float val) 00149 { 00150 if (m_NarrowBand->GetTotalRadius() != val) 00151 { 00152 m_NarrowBand->SetTotalRadius(val); 00153 this->Modified(); 00154 } 00155 } 00156 00158 float GetNarrowBandTotalRadius() 00159 { 00160 return m_NarrowBand->GetTotalRadius(); 00161 } 00162 00167 void SetNarrowBandInnerRadius (float val) 00168 { 00169 if (m_NarrowBand->GetInnerRadius() != val) 00170 { 00171 m_NarrowBand->SetInnerRadius(val); 00172 this->Modified(); 00173 } 00174 } 00175 00177 float GetNarrowBandInnerRadius() 00178 { 00179 return m_NarrowBand->GetInnerRadius(); 00180 } 00181 00187 virtual void CreateNarrowBand (){}; 00188 00189 virtual void SetNarrowBand(NarrowBandType * ptr) 00190 { 00191 00192 if ( m_NarrowBand != ptr ) 00193 { 00194 m_NarrowBand = ptr; 00195 this->Modified(); 00196 } 00197 }; 00198 00199 virtual void CopyInputToOutput (); 00200 00201 protected: 00202 typename NarrowBandType::Pointer m_NarrowBand; 00203 NarrowBandImageFilterBase() 00204 { 00205 m_NarrowBand = NarrowBandType::New(); 00206 m_NarrowBand->SetTotalRadius(4); 00207 m_NarrowBand->SetInnerRadius(2); 00208 m_ReinitializationFrequency = 6; 00209 m_IsoSurfaceValue = 0.0; 00210 m_Step = 0; 00211 m_Touched = false; 00212 m_Barrier = Barrier::New(); 00213 } 00214 00215 virtual ~NarrowBandImageFilterBase() {} 00216 void PrintSelf(std::ostream& os, Indent indent) const; 00217 00220 struct ThreadRegionType 00221 { 00222 typename NarrowBandType::Iterator first; // this is the actual first element 00223 typename NarrowBandType::Iterator last; // this is one past the actual last //element 00224 }; 00225 00228 std::vector<RegionType> m_RegionList; 00229 00232 void GetSplitRegion (int i, ThreadRegionType &splitRegion); 00233 00238 virtual void Initialize(); 00239 00244 virtual void InitializeIteration(); 00245 00248 virtual void PostProcessOutput(); 00249 00250 /* This function clears all pixels from the narrow band */ 00251 void ClearNarrowBand (); 00252 00254 void WaitForAll(); 00255 00259 virtual void GenerateData(); 00260 00261 /* Variables to control reinitialization */ 00262 unsigned int m_ReinitializationFrequency; 00263 unsigned int m_Step; 00264 bool m_Touched; 00265 bool * m_TouchedForThread; 00266 ValueType m_IsoSurfaceValue; 00267 00268 typename Barrier::Pointer m_Barrier; 00269 00270 private: 00271 NarrowBandImageFilterBase(const Self&); //purposely not implemented 00272 void operator=(const Self&); //purposely not implemented 00273 00276 struct NarrowBandImageFilterBaseThreadStruct 00277 { 00278 NarrowBandImageFilterBase *Filter; 00279 TimeStepType TimeStep; 00280 TimeStepType *TimeStepList; 00281 bool *ValidTimeStepList; 00282 }; 00283 00284 /* This class does not use AllocateUpdateBuffer to allocate memory for its 00285 * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode 00286 * functions. This function is here for compatability with the 00287 * FiniteDifferenceSolver framework. 00288 */ 00289 virtual void AllocateUpdateBuffer() {}; 00290 00291 00293 static ITK_THREAD_RETURN_TYPE IterateThreaderCallback( void *arg ); 00294 00298 virtual void ThreadedIterate(void *arg, int threadId); 00299 00303 virtual void ThreadedApplyUpdate(TimeStepType dt, 00304 const ThreadRegionType &regionToProcess, 00305 int threadId); 00306 virtual void ApplyUpdate(TimeStepType){} 00307 00311 virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType &regionToProcess, 00312 int threadId); 00313 virtual TimeStepType CalculateChange() {return 0;} 00314 00315 }; 00316 00317 }// end namespace itk 00318 00319 #ifndef ITK_MANUAL_INSTANTIATION 00320 #include "itkNarrowBandImageFilterBase.txx" 00321 #endif 00322 00323 #endif

Generated at Sat Mar 31 02:25:13 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000