00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef __itkImplicitManifoldNormalVectorFilter_h_
00018 #define __itkImplicitManifoldNormalVectorFilter_h_
00019 
00020 #include "itkConstNeighborhoodIterator.h"
00021 #include "itkNormalVectorFunctionBase.h"
00022 #include "itkFiniteDifferenceSparseImageFilter.h"
00023 #include "itkVector.h"
00024 
00025 namespace itk {
00026 
00070 template <class TInputImage, class TSparseOutputImage>
00071 class ImplicitManifoldNormalVectorFilter  
00072   : public FiniteDifferenceSparseImageFilter <TInputImage, TSparseOutputImage>
00073 {
00074 public:  
00076   typedef ImplicitManifoldNormalVectorFilter Self;
00077   typedef FiniteDifferenceSparseImageFilter <TInputImage,
00078                                              TSparseOutputImage> Superclass;
00079   typedef SmartPointer<Self>  Pointer;
00080   typedef SmartPointer<const Self>  ConstPointer;
00081   
00083   itkTypeMacro(ImplicitManifoldNormalVectorFilter,
00084                FiniteDifferenceSparseImageFilter);
00085 
00087   itkNewMacro(Self);
00088 
00090   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00091   
00093   typedef typename Superclass::InputImageType  InputImageType;
00094   typedef typename Superclass::IndexType       IndexType;
00095   typedef typename Superclass::NodeDataType    NormalVectorType;
00096   typedef typename Superclass::NodeValueType   NodeValueType;
00097   typedef typename Superclass::FiniteDifferenceFunctionType
00098   FiniteDifferenceFunctionType;
00099   typedef typename Superclass::SparseOutputImageType SparseOutputImageType;
00100   typedef typename Superclass::OutputNodeType NormalBandNodeType;
00101   typedef typename Superclass::NodeListType NodeListType;
00102   
00104   typedef ConstNeighborhoodIterator <InputImageType> InputImageIteratorType;
00105   
00108   typedef NormalVectorFunctionBase <SparseOutputImageType> NormalFunctionType;
00109   
00111   typedef typename FiniteDifferenceFunctionType::RadiusType RadiusType;    
00112   
00114   void SetNormalFunction( NormalFunctionType *nf );  
00115   
00116   itkSetMacro(MaxIteration, unsigned int);
00117   itkGetMacro(MaxIteration, unsigned int);
00118   itkSetMacro(IsoLevelLow,  NodeValueType);
00119   itkGetMacro(IsoLevelLow,  NodeValueType);
00120   itkSetMacro(IsoLevelHigh, NodeValueType);
00121   itkGetMacro(IsoLevelHigh, NodeValueType);
00122   itkSetMacro(MinVectorNorm, NodeValueType);
00123   itkGetMacro(MinVectorNorm, NodeValueType);
00124   itkSetMacro(UnsharpMaskingFlag, bool);
00125   itkGetMacro(UnsharpMaskingFlag, bool);
00126   itkSetMacro(UnsharpMaskingWeight, NodeValueType);
00127   itkGetMacro(UnsharpMaskingWeight, NodeValueType);
00128  
00129 protected:   
00130   ImplicitManifoldNormalVectorFilter();  
00131   ~ImplicitManifoldNormalVectorFilter() {};
00132   void PrintSelf(std::ostream& os, Indent indent) const;
00133 
00135   virtual void Initialize();
00136 
00138   void SetNormalBand();
00139   
00141   void InitializeNormalBandNode( NormalBandNodeType *node,
00142                                  const InputImageIteratorType &it );
00143   
00146   virtual void CopyInputToOutput() {};
00147     
00148 private:
00149   ImplicitManifoldNormalVectorFilter(const Self&); 
00150   void operator=(const Self&); 
00151     
00153   NormalFunctionType *m_NormalFunction;
00154 
00156   unsigned int m_MaxIteration;
00157 
00160   NodeValueType m_IsoLevelLow, m_IsoLevelHigh;
00161 
00163   NodeValueType m_MinVectorNorm;
00164 
00166   bool m_UnsharpMaskingFlag;
00167 
00170   NodeValueType m_UnsharpMaskingWeight;
00171   
00173   unsigned long m_Indicator [itkGetStaticConstMacro(ImageDimension)];
00174   unsigned int  m_NumVertex;
00175   NodeValueType m_DimConst, m_DimConst2;
00176   RadiusType    m_ManifoldRadius;
00177 
00178 protected:
00180   virtual NormalVectorType DataConstraint( const NormalVectorType &data ) const 
00181   {
00182     return (data / (m_MinVectorNorm + data.GetNorm()));
00183   }
00184 
00188   virtual void PostProcessOutput();
00189   
00190 public:
00193   virtual bool Halt()
00194   {
00195     if (this->GetElapsedIterations()==m_MaxIteration) return true;
00196     else return false;
00197   }
00198 };
00199 
00200 }
00201 
00202 #ifndef ITK_MANUAL_INSTANTIATION
00203 #include "itkImplicitManifoldNormalVectorFilter.txx"
00204 #endif
00205 
00206 #endif