ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkRegionBasedLevelSetFunctionData.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 __itkRegionBasedLevelSetFunctionData_h
00019 #define __itkRegionBasedLevelSetFunctionData_h
00020 
00021 #include "itkLightObject.h"
00022 
00023 #include "itkVector.h"
00024 #include "itkListSample.h"
00025 #include "itkKdTreeGenerator.h"
00026 
00027 #include "itkImageRegionIterator.h"
00028 #include "itkImageRegionIteratorWithIndex.h"
00029 
00030 namespace itk
00031 {
00067 template< class TInputImage, class TFeatureImage >
00068 class RegionBasedLevelSetFunctionData:public LightObject
00069 {
00070 public:
00071 
00072   typedef RegionBasedLevelSetFunctionData Self;
00073   typedef LightObject                     Superclass;
00074   typedef SmartPointer< Self >            Pointer;
00075   typedef SmartPointer< const Self >      ConstPointer;
00076 
00077   itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImage::ImageDimension);
00078 
00080   itkNewMacro(Self);
00081 
00082   itkTypeMacro(RegionBasedLevelSetFunctionData, LightObject);
00083 
00084   typedef TInputImage                             InputImageType;
00085   typedef typename InputImageType::Pointer        InputImagePointer;
00086   typedef typename InputImageType::ConstPointer   InputImageConstPointer;
00087   typedef typename InputImageType::PixelType      InputPixelType;
00088   typedef typename InputImageType::RegionType     InputRegionType;
00089   typedef typename InputImageType::SizeType       InputSizeType;
00090   typedef typename InputSizeType::SizeValueType   InputSizeValueType;
00091   typedef typename InputImageType::SpacingType    InputSpacingType;
00092   typedef typename InputImageType::IndexType      InputIndexType;
00093   typedef typename InputIndexType::IndexValueType InputIndexValueType;
00094   typedef typename InputImageType::PointType      InputPointType;
00095 
00096   typedef TFeatureImage                           FeatureImageType;
00097   typedef typename FeatureImageType::Pointer      FeatureImagePointer;
00098   typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
00099   typedef typename FeatureImageType::PixelType    FeaturePixelType;
00100   typedef typename FeatureImageType::RegionType   FeatureRegionType;
00101   typedef typename FeatureImageType::SizeType     FeatureSizeType;
00102   typedef typename FeatureSizeType::SizeValueType FeatureSizeValueType;
00103   typedef typename FeatureImageType::SpacingType  FeatureSpacingType;
00104   typedef typename FeatureImageType::IndexType    FeatureIndexType;
00105   typedef typename FeatureImageType::PointType    FeaturePointType;
00106 
00107   // Allocates m_HeavisideFunctionOfLevelSetImage to have same origin,
00108   // spacing and size as image. Also sets the m_Start and m_End indices.
00109   void CreateHeavisideFunctionOfLevelSetImage(const InputImageType *image);
00110 
00111   // Checks if the given index lies in the domain of the current
00112   // level-set function. The domain is defined by the start and end indices.
00113   template< class TIndex >
00114   bool VerifyInsideRegion(const TIndex & featureIndex)
00115   {
00116     for ( unsigned int j = 0; j < ImageDimension; j++ )
00117       {
00118       if ( ( featureIndex[j] < static_cast< InputIndexValueType >( this->m_Start[j] ) )
00119            || ( featureIndex[j] > static_cast< InputIndexValueType >( this->m_End[j] ) ) )
00120         {
00121         return false;
00122         }
00123       }
00124     return true;
00125   }
00126 
00127   // Get the index into the domain of the current level-set function
00128   InputIndexType GetIndex(const FeatureIndexType & featureIndex);
00129 
00130   // Get the index in the domain of the feature image
00131   FeatureIndexType GetFeatureIndex(const InputIndexType & inputIndex);
00132 
00133   double m_WeightedNumberOfPixelsInsideLevelSet;
00134   double m_WeightedNumberOfPixelsOutsideLevelSet;
00135 
00136   InputImagePointer m_HeavisideFunctionOfLevelSetImage;
00137   InputIndexType    m_Start;
00138   InputIndexType    m_End;
00139 protected:
00140   RegionBasedLevelSetFunctionData();
00141   virtual ~RegionBasedLevelSetFunctionData() {}
00142 private:
00143   RegionBasedLevelSetFunctionData(const Self &); //purposely not implemented
00144   void operator=(const Self &);                  //purposely not implemented
00145 };
00146 } //end namespace itk
00147 
00148 #ifndef ITK_MANUAL_INSTANTIATION
00149 #include "itkRegionBasedLevelSetFunctionData.hxx"
00150 #endif
00151 #endif
00152