ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkWarpHarmonicEnergyCalculator.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 __itkWarpHarmonicEnergyCalculator_h
00019 #define __itkWarpHarmonicEnergyCalculator_h
00020 
00021 #include "itkObject.h"
00022 #include "itkObjectFactory.h"
00023 #include "itkConstNeighborhoodIterator.h"
00024 #include "itkVector.h"
00025 
00026 namespace itk
00027 {
00044 template< class TInputImage >
00045 class ITK_EXPORT WarpHarmonicEnergyCalculator:public Object
00046 {
00047 public:
00049   typedef WarpHarmonicEnergyCalculator Self;
00050   typedef Object                       Superclass;
00051   typedef SmartPointer< Self >         Pointer;
00052   typedef SmartPointer< const Self >   ConstPointer;
00053 
00055   itkNewMacro(Self);
00056 
00058   itkTypeMacro(WarpHarmonicEnergyCalculator, Object);
00059 
00061   typedef TInputImage ImageType;
00062 
00064   typedef typename TInputImage::Pointer ImagePointer;
00065 
00067   typedef typename TInputImage::ConstPointer ImageConstPointer;
00068 
00070   typedef typename TInputImage::PixelType PixelType;
00071 
00073   typedef typename TInputImage::IndexType IndexType;
00074 
00076   typedef typename TInputImage::RegionType RegionType;
00077 
00079   itkStaticConstMacro(ImageDimension, unsigned int,
00080                       TInputImage::ImageDimension);
00081 
00083   itkStaticConstMacro(VectorDimension, unsigned int,
00084                       PixelType::Dimension);
00085 
00088   typedef ConstNeighborhoodIterator< ImageType >             ConstNeighborhoodIteratorType;
00089   typedef typename ConstNeighborhoodIteratorType::RadiusType RadiusType;
00090 
00094   void SetUseImageSpacingOn()
00095   {
00096     this->SetUseImageSpacing(true);
00097   }
00098 
00102   void SetUseImageSpacingOff()
00103   {
00104     this->SetUseImageSpacing(false);
00105   }
00106 
00109   void SetUseImageSpacing(bool);
00110 
00111   itkGetConstMacro(UseImageSpacing, bool);
00112 
00113   typedef FixedArray< double, ImageDimension > WeightsType;
00114 
00117   itkSetMacro(DerivativeWeights, WeightsType);
00118   itkGetConstReferenceMacro(DerivativeWeights, WeightsType);
00120 
00122   itkSetConstObjectMacro(Image, ImageType);
00123 
00125   void Compute(void);
00126 
00128   itkGetConstMacro(HarmonicEnergy, double);
00129 
00131   void SetRegion(const RegionType & region);
00132 
00133 protected:
00134   WarpHarmonicEnergyCalculator();
00135   virtual ~WarpHarmonicEnergyCalculator() {}
00136   void PrintSelf(std::ostream & os, Indent indent) const;
00137 
00139   itkGetConstReferenceMacro(NeighborhoodRadius, RadiusType);
00140   itkSetMacro(NeighborhoodRadius, RadiusType);
00142 
00143   double EvaluateAtNeighborhood(ConstNeighborhoodIteratorType & it) const;
00144 
00145 private:
00146   WarpHarmonicEnergyCalculator(const Self &); //purposely not implemented
00147   void operator=(const Self &);               //purposely not implemented
00148 
00149   double            m_HarmonicEnergy;
00150   ImageConstPointer m_Image;
00151 
00152   RegionType m_Region;
00153   bool       m_RegionSetByUser;
00154 
00155   bool m_UseImageSpacing;
00156 
00158   WeightsType m_DerivativeWeights;
00159 
00160   RadiusType m_NeighborhoodRadius;
00161 };
00162 } // end namespace itk
00163 
00164 #ifndef ITK_MANUAL_INSTANTIATION
00165 #include "itkWarpHarmonicEnergyCalculator.hxx"
00166 #endif
00167 
00168 #endif /* __itkWarpHarmonicEnergyCalculator_h */
00169