ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkGradientVectorFlowImageFilter.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 __itkGradientVectorFlowImageFilter_h
00019 #define __itkGradientVectorFlowImageFilter_h
00020 
00021 #include "vnl/vnl_matrix_fixed.h"
00022 #include "vnl/vnl_math.h"
00023 #include "itkImage.h"
00024 #include "itkVector.h"
00025 #include "itkLaplacianImageFilter.h"
00026 #include "itkImageRegionIterator.h"
00027 #include "itkImageRegionConstIteratorWithIndex.h"
00028 
00029 namespace itk
00030 {
00042 template< class TInputImage, class TOutputImage, class TInternalPixel = double >
00043 class ITK_EXPORT GradientVectorFlowImageFilter:public ImageToImageFilter< TInputImage, TOutputImage >
00044 {
00045 public:
00047   typedef GradientVectorFlowImageFilter Self;
00048 
00050   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00051 
00053   typedef SmartPointer< Self >       Pointer;
00054   typedef SmartPointer< const Self > ConstPointer;
00055 
00057   itkNewMacro(Self);
00058 
00060   itkTypeMacro(GradientVectorFlowImageFilter, ImageToImageFilter);
00061 
00063   typedef TInputImage  InputImageType;
00064   typedef TOutputImage OutputImageType;
00065 
00066   typedef typename TInputImage::IndexType      IndexType;
00067   typedef typename TInputImage::SizeType       SizeType;
00068   typedef typename TInputImage::PixelType      PixelType;
00069   typedef typename OutputImageType::Pointer    OutputImagePointer;
00070   typedef typename OutputImageType::RegionType RegionType;
00071 
00073 //  typedef ImageRegionConstIterator<InputImageType> InputImageConstIterator;
00074   typedef ImageRegionIterator< InputImageType >               InputImageIterator;
00075   typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIterator;
00076   typedef ImageRegionIterator< OutputImageType >              OutputImageIterator;
00077 
00079   itkStaticConstMacro(ImageDimension, unsigned int,
00080                       TInputImage::ImageDimension);
00081   itkStaticConstMacro(OutputImageDimension, unsigned int,
00082                       TOutputImage::ImageDimension);
00084 
00085   typedef TInternalPixel                                                          InternalPixelType;
00086   typedef itk::Image< InternalPixelType, itkGetStaticConstMacro(ImageDimension) > InternalImageType;
00087   typedef typename InternalImageType::Pointer                                     InternalImagePointer;
00088   typedef ImageRegionIterator< InternalImageType >                                InternalImageIterator;
00089 
00090   typedef LaplacianImageFilter< InternalImageType, InternalImageType > LaplacianFilterType;
00091   typedef typename LaplacianFilterType::Pointer                        LaplacianFilterPointer;
00092 
00095   itkSetMacro(LaplacianFilter, LaplacianFilterPointer);
00096 
00097   itkSetMacro(TimeStep, double);
00098   itkGetConstMacro(TimeStep, double);
00099 
00100   itkSetMacro(NoiseLevel, double);
00101   itkGetConstMacro(NoiseLevel, double);
00102 
00103   itkSetMacro(IterationNum, int);
00104   itkGetConstMacro(IterationNum, int);
00105 
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107 
00108   itkConceptMacro( SameDimensionCheck,
00109                    ( Concept::SameDimension< ImageDimension, OutputImageDimension > ) );
00110   itkConceptMacro( InputHasNumericTraitsCheck,
00111                    ( Concept::HasNumericTraits< typename PixelType::ValueType > ) );
00112   itkConceptMacro( OutputHasNumericTraitsCheck,
00113                    ( Concept::HasNumericTraits< typename TOutputImage::PixelType::ValueType > ) );
00114 
00116 #endif
00117 protected:
00118   GradientVectorFlowImageFilter();
00119   ~GradientVectorFlowImageFilter() {}
00120   void PrintSelf(std::ostream & os, Indent indent) const;
00122 
00123   virtual void GenerateData();
00124 
00125   void InitInterImage();
00126 
00127   void UpdateInterImage();
00128 
00129   void UpdatePixels();
00130 
00131 private:
00132   GradientVectorFlowImageFilter(const Self &); //purposely not implemented
00133   void operator=(const Self &); //purposely not implemented
00134 
00135   // parameters;
00136   double m_TimeStep;                               //the timestep of each
00137                                                    // iteration
00138   double m_Steps[Superclass::InputImageDimension]; // set to be 1 in all
00139                                                    // directions in most cases
00140   double m_NoiseLevel;                             // the noise level of the
00141                                                    // image
00142   int m_IterationNum;                              // the iteration number
00143 
00144   LaplacianFilterPointer m_LaplacianFilter;
00145   typename Superclass::InputImagePointer m_IntermediateImage;
00146 
00147   InternalImagePointer m_InternalImages[Superclass::InputImageDimension];
00148   InternalImagePointer m_BImage;  // store the "b" value for every pixel
00149 
00150   typename Superclass::InputImagePointer m_CImage; // store the $c_i$ value for
00151                                                    // every pixel
00152 };
00153 } // end namespace itk
00154 
00155 #ifndef ITK_MANUAL_INSTANTIATION
00156 #include "itkGradientVectorFlowImageFilter.hxx"
00157 #endif
00158 
00159 #endif
00160