ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImplicitManifoldNormalVectorFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkImplicitManifoldNormalVectorFilter_h
00019 #define __itkImplicitManifoldNormalVectorFilter_h
00020 
00021 #include "itkConstNeighborhoodIterator.h"
00022 #include "itkNormalVectorFunctionBase.h"
00023 #include "itkFiniteDifferenceSparseImageFilter.h"
00024 #include "itkVector.h"
00025 
00026 namespace itk
00027 {
00072 template< class TInputImage, class TSparseOutputImage >
00073 class ITK_EXPORT ImplicitManifoldNormalVectorFilter:
00074   public FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >
00075 {
00076 public:
00077 
00079   typedef ImplicitManifoldNormalVectorFilter Self;
00080   typedef FiniteDifferenceSparseImageFilter<
00081     TInputImage,
00082     TSparseOutputImage >                      Superclass;
00083 
00084   typedef SmartPointer< Self >       Pointer;
00085   typedef SmartPointer< const Self > ConstPointer;
00086 
00088   itkTypeMacro(ImplicitManifoldNormalVectorFilter,
00089                FiniteDifferenceSparseImageFilter);
00090 
00092   itkNewMacro(Self);
00093 
00095   itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
00096 
00098   typedef typename Superclass::InputImageType InputImageType;
00099   typedef typename Superclass::IndexType      IndexType;
00100   typedef typename Superclass::NodeDataType   NormalVectorType;
00101   typedef typename Superclass::NodeValueType  NodeValueType;
00102   typedef typename Superclass::FiniteDifferenceFunctionType
00103   FiniteDifferenceFunctionType;
00104 
00105   typedef typename Superclass::SparseOutputImageType SparseOutputImageType;
00106   typedef typename Superclass::OutputNodeType        NormalBandNodeType;
00107   typedef typename Superclass::NodeListType          NodeListType;
00108 
00110   typedef ConstNeighborhoodIterator< InputImageType > InputImageIteratorType;
00111 
00114   typedef NormalVectorFunctionBase< SparseOutputImageType > NormalFunctionType;
00115 
00117   typedef typename FiniteDifferenceFunctionType::RadiusType RadiusType;
00118 
00120   void SetNormalFunction(NormalFunctionType *nf);
00121 
00122   itkSetMacro(MaxIteration, unsigned int);
00123   itkGetConstMacro(MaxIteration, unsigned int);
00124   itkSetMacro(IsoLevelLow,  NodeValueType);
00125   itkGetConstMacro(IsoLevelLow,  NodeValueType);
00126   itkSetMacro(IsoLevelHigh, NodeValueType);
00127   itkGetConstMacro(IsoLevelHigh, NodeValueType);
00128   itkSetMacro(MinVectorNorm, NodeValueType);
00129   itkGetConstMacro(MinVectorNorm, NodeValueType);
00130   itkSetMacro(UnsharpMaskingFlag, bool);
00131   itkGetConstMacro(UnsharpMaskingFlag, bool);
00132   itkSetMacro(UnsharpMaskingWeight, NodeValueType);
00133   itkGetConstMacro(UnsharpMaskingWeight, NodeValueType);
00134 protected:
00135   ImplicitManifoldNormalVectorFilter();
00136   ~ImplicitManifoldNormalVectorFilter() {}
00137   void PrintSelf(std::ostream & os, Indent indent) const;
00138 
00140   virtual void Initialize();
00141 
00143   void SetNormalBand();
00144 
00147   void InitializeNormalBandNode(NormalBandNodeType *node,
00148                                 const InputImageIteratorType & it);
00149 
00152   virtual void CopyInputToOutput() {}
00153 
00156   virtual bool Halt()
00157   {
00158     if ( this->GetElapsedIterations() == m_MaxIteration )
00159       {
00160       return true;
00161       }
00162     else
00163       {
00164       return false;
00165       }
00166   }
00168 
00169 protected:
00171   virtual NormalVectorType DataConstraint(const NormalVectorType & data) const
00172   {
00173     return ( data / ( m_MinVectorNorm + data.GetNorm() ) );
00174   }
00175 
00179   virtual void PostProcessOutput();
00180 
00181 private:
00182   ImplicitManifoldNormalVectorFilter(const Self &); //purposely not implemented
00183   void operator=(const Self &);                     //purposely not implemented
00184 
00186   NormalFunctionType *m_NormalFunction;
00187 
00189   unsigned int m_MaxIteration;
00190 
00193   NodeValueType m_IsoLevelLow, m_IsoLevelHigh;
00194 
00196   NodeValueType m_MinVectorNorm;
00197 
00199   bool m_UnsharpMaskingFlag;
00200 
00203   NodeValueType m_UnsharpMaskingWeight;
00204 
00206   unsigned long m_Indicator[itkGetStaticConstMacro(ImageDimension)];
00207   unsigned int  m_NumVertex;
00208   NodeValueType m_DimConst;
00209   NodeValueType m_DimConst2;
00210   RadiusType    m_ManifoldRadius;
00211 };
00212 } // end namespace itk
00213 
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkImplicitManifoldNormalVectorFilter.hxx"
00216 #endif
00217 
00218 #endif
00219