00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkSparseFieldFourthOrderLevelSetImageFilter_h_
00018 #define _itkSparseFieldFourthOrderLevelSetImageFilter_h_
00019
00020 #include "itkSparseImage.h"
00021 #include "itkNormalVectorDiffusionFunction.h"
00022 #include "itkImplicitManifoldNormalVectorFilter.h"
00023 #include "itkLevelSetFunctionWithRefitTerm.h"
00024 #include "itkSparseFieldLevelSetImageFilter.h"
00025 #include <math.h>
00026
00027 namespace itk {
00028
00036 template <class TImageType>
00037 class NormalBandNode
00038 {
00039 public:
00040
00042 typedef TImageType LevelSetImageType;
00043
00045 typedef typename LevelSetImageType::PixelType NodeValueType;
00046
00048 typedef typename LevelSetImageType::IndexType IndexType;
00049
00051 typedef Vector <NodeValueType,
00052 ::itk::GetImageDimension<TImageType>::ImageDimension>
00053 NodeDataType;
00054
00056 NodeDataType m_Data;
00057
00059 NodeDataType m_InputData;
00060
00062 NodeDataType m_Update;
00063
00066 NodeDataType
00067 m_ManifoldNormal[::itk::GetImageDimension<TImageType>::ImageDimension];
00068
00070 NodeDataType m_Flux [::itk::GetImageDimension<TImageType>::ImageDimension];
00071
00074 NodeValueType m_Curvature;
00075
00078 bool m_CurvatureFlag;
00079
00081 IndexType m_Index;
00082
00084 NormalBandNode *Next;
00085 NormalBandNode *Previous;
00086 };
00087
00154 template <class TInputImage, class TOutputImage>
00155 class ITK_EXPORT SparseFieldFourthOrderLevelSetImageFilter
00156 : public SparseFieldLevelSetImageFilter <TInputImage, TOutputImage>
00157 {
00158 public:
00159
00161 typedef SparseFieldFourthOrderLevelSetImageFilter Self;
00162 typedef SparseFieldLevelSetImageFilter<TInputImage, TOutputImage> Superclass;
00163 typedef SmartPointer<Self> Pointer;
00164 typedef SmartPointer<const Self> ConstPointer;
00165
00167 itkTypeMacro(SparseFieldFourthOrderLevelSetImageFilter,
00168 SparseFieldLevelSetImageFilter);
00169
00171 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00172
00174 typedef typename Superclass::OutputImageType OutputImageType;
00175 typedef typename Superclass::ValueType ValueType;
00176 typedef typename Superclass::IndexType IndexType;
00177 typedef typename Superclass::LayerType LayerType;
00178
00181 typedef NormalBandNode <OutputImageType> NodeType;
00182
00184 typedef SparseImage <NodeType,
00185 itkGetStaticConstMacro(ImageDimension)> SparseImageType;
00186
00188 typedef typename NodeType::NodeDataType NormalVectorType;
00189
00191 typedef NeighborhoodIterator <SparseImageType> SparseImageIteratorType;
00192
00194 typedef ImplicitManifoldNormalVectorFilter <OutputImageType, SparseImageType>
00195 NormalVectorFilterType;
00196
00198 typedef NormalVectorDiffusionFunction <SparseImageType>
00199 NormalVectorFunctionType;
00200
00202
00203
00205 typedef LevelSetFunctionWithRefitTerm <OutputImageType,
00206 SparseImageType> LevelSetFunctionType;
00207
00208 itkGetConstReferenceMacro(MaxRefitIteration,unsigned int);
00209 itkSetMacro(MaxRefitIteration,unsigned int);
00210 itkGetConstReferenceMacro(MaxNormalIteration,unsigned int);
00211 itkSetMacro(MaxNormalIteration,unsigned int);
00212 itkGetConstReferenceMacro(CurvatureBandWidth,ValueType);
00213 itkSetMacro(CurvatureBandWidth,ValueType);
00214 itkGetConstReferenceMacro(RMSChangeNormalProcessTrigger, ValueType);
00215 itkSetMacro(RMSChangeNormalProcessTrigger, ValueType);
00216 itkGetConstReferenceMacro(NormalProcessType, int);
00217 itkSetMacro(NormalProcessType, int);
00218 itkGetConstReferenceMacro(NormalProcessConductance, ValueType);
00219 itkSetMacro(NormalProcessConductance, ValueType);
00220 itkSetMacro(NormalProcessUnsharpFlag, bool);
00221 itkGetConstReferenceMacro(NormalProcessUnsharpFlag, bool);
00222 itkSetMacro(NormalProcessUnsharpWeight, ValueType);
00223 itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
00224
00227 void SetLevelSetFunction( LevelSetFunctionType *lsf );
00228
00232 unsigned int GetMinimumNumberOfLayers() const
00233 {
00234 return (int)vcl_ceil(m_CurvatureBandWidth+
00235 itkGetStaticConstMacro(ImageDimension));
00236 }
00237
00240 virtual void SetNumberOfLayers( const unsigned int n )
00241 {
00242 unsigned int nm = vnl_math_max (this->GetMinimumNumberOfLayers (), n );
00243 if (nm != this->GetNumberOfLayers())
00244 {
00245 Superclass::SetNumberOfLayers (nm);
00246 this->Modified();
00247 }
00248 }
00250
00253 virtual void InitializeIteration()
00254 {
00255 Superclass::InitializeIteration();
00256 ValueType rmschange = this->GetRMSChange();
00258
00259 if ( ( this->GetElapsedIterations()==0 ) ||
00260 ( m_RefitIteration == m_MaxRefitIteration ) ||
00261 ( rmschange <= m_RMSChangeNormalProcessTrigger ) ||
00262 ( this->ActiveLayerCheckBand() ) )
00263 {
00264 if ( ( this->GetElapsedIterations() != 0 ) &&
00265 ( rmschange <= m_RMSChangeNormalProcessTrigger ) &&
00266 ( m_RefitIteration <= 1) )
00267 {
00268 m_ConvergenceFlag = true;
00269 }
00270
00271 m_RefitIteration = 0;
00272 ProcessNormals();
00273 }
00274
00275 m_RefitIteration++;
00276 }
00277
00278 #ifdef ITK_USE_CONCEPT_CHECKING
00279
00280 itkConceptMacro(OutputHasNumericTraitsCheck,
00281 (Concept::HasNumericTraits<ValueType>));
00282
00284 #endif
00285
00286 protected:
00287 SparseFieldFourthOrderLevelSetImageFilter();
00288 ~SparseFieldFourthOrderLevelSetImageFilter() {};
00289 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00290
00291
00294 ValueType ComputeCurvatureFromSparseImageNeighborhood
00295 ( SparseImageIteratorType &neighborhood ) const;
00296
00300 void ComputeCurvatureTarget( const OutputImageType *distanceImage,
00301 SparseImageType *sparseImage ) const;
00302
00304 void ProcessNormals();
00305
00310 bool ActiveLayerCheckBand() const;
00311
00312 private:
00315 unsigned int m_RefitIteration;
00316
00320 unsigned int m_MaxRefitIteration;
00321
00324 unsigned int m_MaxNormalIteration;
00325
00329 ValueType m_RMSChangeNormalProcessTrigger;
00330
00333 bool m_ConvergenceFlag;
00334
00337 LevelSetFunctionType *m_LevelSetFunction;
00338
00343 ValueType m_CurvatureBandWidth;
00344
00347 int m_NormalProcessType;
00348
00351 ValueType m_NormalProcessConductance;
00352
00355 bool m_NormalProcessUnsharpFlag;
00356
00359 ValueType m_NormalProcessUnsharpWeight;
00360
00362 static const unsigned long m_NumVertex;
00363 static const ValueType m_DimConst;
00364
00365 SparseFieldFourthOrderLevelSetImageFilter(const Self&);
00366
00367 void operator=(const Self&);
00368 };
00369
00370 }
00371
00372 #ifndef ITK_MANUAL_INSTANTIATION
00373 #include "itkSparseFieldFourthOrderLevelSetImageFilter.txx"
00374 #endif
00375
00376 #endif
00377