ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkFastMarchingUpwindGradientImageFilter.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 __itkFastMarchingUpwindGradientImageFilter_h
00019 #define __itkFastMarchingUpwindGradientImageFilter_h
00020 
00021 #include "itkFastMarchingImageFilter.h"
00022 #include "itkImage.h"
00023 
00024 namespace itk
00025 {
00058 template<
00059   class TLevelSet,
00060   class TSpeedImage = Image< float, ::itk::GetImageDimension< TLevelSet >::ImageDimension > >
00061 class ITK_EXPORT FastMarchingUpwindGradientImageFilter:
00062   public FastMarchingImageFilter< TLevelSet, TSpeedImage >
00063 {
00064 public:
00066   typedef FastMarchingUpwindGradientImageFilter             Self;
00067   typedef FastMarchingImageFilter< TLevelSet, TSpeedImage > Superclass;
00068   typedef SmartPointer< Self >                              Pointer;
00069   typedef SmartPointer< const Self >                        ConstPointer;
00070 
00072   itkNewMacro(Self);
00073 
00075   itkTypeMacro(FastMarchingUpwindGradientImageFilter, FastMarchingImageFilter);
00076 
00078   typedef typename Superclass::LevelSetType           LevelSetType;
00079   typedef typename Superclass::SpeedImageType         SpeedImageType;
00080   typedef typename Superclass::LevelSetImageType      LevelSetImageType;
00081   typedef typename Superclass::LevelSetPointer        LevelSetPointer;
00082   typedef typename Superclass::SpeedImageConstPointer SpeedImageConstPointer;
00083   typedef typename Superclass::LabelImageType         LabelImageType;
00084   typedef typename Superclass::PixelType              PixelType;
00085   typedef typename Superclass::AxisNodeType           AxisNodeType;
00086   typedef typename Superclass::NodeType               NodeType;
00087   typedef typename Superclass::NodeContainer          NodeContainer;
00088   typedef typename Superclass::NodeContainerPointer   NodeContainerPointer;
00089 
00090   typedef typename Superclass::IndexType         IndexType;
00091   typedef typename Superclass::OutputSpacingType OutputSpacingType;
00092   typedef typename Superclass::LevelSetIndexType LevelSetIndexType;
00093 
00094   typedef typename Superclass::OutputPointType PointType;
00095 
00097   itkStaticConstMacro(SetDimension, unsigned int, Superclass::SetDimension);
00098 
00102   void SetTargetPoints(NodeContainer *points)
00103   {
00104     m_TargetPoints = points;
00105     this->Modified();
00106   }
00108 
00110   NodeContainerPointer GetTargetPoints()
00111   { return m_TargetPoints; }
00112 
00114   NodeContainerPointer GetReachedTargetPoints()
00115   { return m_ReachedTargetPoints; }
00116 
00118   typedef CovariantVector< PixelType,
00119                            itkGetStaticConstMacro(SetDimension) > GradientPixelType;
00120 
00122   typedef Image< GradientPixelType,
00123                  itkGetStaticConstMacro(SetDimension) > GradientImageType;
00124 
00126   typedef typename GradientImageType::Pointer GradientImagePointer;
00127 
00129   GradientImagePointer GetGradientImage() const
00130   { return m_GradientImage; }
00131 
00134   itkSetMacro(GenerateGradientImage, bool);
00135 
00137   itkGetConstReferenceMacro(GenerateGradientImage, bool);
00138   itkBooleanMacro(GenerateGradientImage);
00140 
00144   itkSetMacro(TargetOffset, double);
00145 
00147   itkGetConstReferenceMacro(TargetOffset, double);
00148 
00152   itkSetMacro(TargetReachedMode, int);
00153   itkGetConstReferenceMacro(TargetReachedMode, int);
00154   void SetTargetReachedModeToNoTargets()
00155   { this->SetTargetReachedMode(NoTargets); }
00156   void SetTargetReachedModeToOneTarget()
00157   { this->SetTargetReachedMode(OneTarget); }
00158   void SetTargetReachedModeToSomeTargets(SizeValueType numberOfTargets)
00159   {
00160     this->SetTargetReachedMode(SomeTargets);
00161     m_NumberOfTargets = numberOfTargets;
00162   }
00164 
00165   void SetTargetReachedModeToAllTargets()
00166   { this->SetTargetReachedMode(AllTargets); }
00167 
00169   itkGetConstReferenceMacro(NumberOfTargets, SizeValueType);
00170 
00175   itkGetConstReferenceMacro(TargetValue, double);
00176 
00177   enum {
00178     NoTargets,
00179     OneTarget,
00180     SomeTargets,
00181     AllTargets
00182     };
00183 
00184 #ifdef ITK_USE_CONCEPT_CHECKING
00185 
00186   itkConceptMacro( LevelSetDoubleDivisionOperatorsCheck,
00187                    ( Concept::DivisionOperators< typename TLevelSet::PixelType, double > ) );
00188   itkConceptMacro( LevelSetDoubleDivisionAndAssignOperatorsCheck,
00189                    ( Concept::DivisionAndAssignOperators< typename TLevelSet::PixelType, double > ) );
00190 
00192 #endif
00193 protected:
00194   FastMarchingUpwindGradientImageFilter();
00195   ~FastMarchingUpwindGradientImageFilter(){}
00196   void PrintSelf(std::ostream & os, Indent indent) const;
00198 
00199   virtual void Initialize(LevelSetImageType *);
00200 
00201   void GenerateData();
00202 
00203   virtual void UpdateNeighbors(const IndexType & index,
00204                                const SpeedImageType *, LevelSetImageType *);
00205 
00206   virtual void ComputeGradient(const IndexType & index,
00207                                const LevelSetImageType *output,
00208                                const LabelImageType *labelImage,
00209                                GradientImageType *gradientImage);
00210 
00211 private:
00212   FastMarchingUpwindGradientImageFilter(const Self &); //purposely not
00213                                                        // implemented
00214   void operator=(const Self &);                        //purposely not
00215                                                        // implemented
00216 
00217   NodeContainerPointer m_TargetPoints;
00218   NodeContainerPointer m_ReachedTargetPoints;
00219 
00220   GradientImagePointer m_GradientImage;
00221 
00222   bool m_GenerateGradientImage;
00223 
00224   double m_TargetOffset;
00225 
00226   int m_TargetReachedMode;
00227 
00228   double m_TargetValue;
00229 
00230   SizeValueType m_NumberOfTargets;
00231 };
00232 } // namespace itk
00233 
00234 #ifndef ITK_MANUAL_INSTANTIATION
00235 #include "itkFastMarchingUpwindGradientImageFilter.hxx"
00236 #endif
00237 
00238 #endif
00239