ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConstrainedRegionBasedLevelSetFunctionSharedData.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 __itkConstrainedRegionBasedLevelSetFunctionSharedData_h
00019 #define __itkConstrainedRegionBasedLevelSetFunctionSharedData_h
00020 
00021 #include "itkRegionBasedLevelSetFunctionSharedData.h"
00022 
00023 namespace itk
00024 {
00060 template< class TInputImage, class TFeatureImage, class TSingleData >
00061 class ConstrainedRegionBasedLevelSetFunctionSharedData:
00062   public RegionBasedLevelSetFunctionSharedData< TInputImage, TFeatureImage, TSingleData >
00063 {
00064 public:
00065 
00066   typedef ConstrainedRegionBasedLevelSetFunctionSharedData Self;
00067   typedef RegionBasedLevelSetFunctionSharedData< TInputImage, TFeatureImage, TSingleData >
00068   Superclass;
00069   typedef SmartPointer< Self >       Pointer;
00070   typedef SmartPointer< const Self > ConstPointer;
00071 
00072   itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImage::ImageDimension);
00073 
00075   itkNewMacro(Self);
00076 
00077   itkTypeMacro(ConstrainedRegionBasedLevelSetFunctionSharedData, RegionBasedLevelSetFunctionSharedData);
00078 
00079   typedef TInputImage                                 InputImageType;
00080   typedef typename Superclass::InputImagePointer      InputImagePointer;
00081   typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00082   typedef typename Superclass::InputPixelType         InputPixelType;
00083   typedef typename Superclass::InputRegionType        InputRegionType;
00084   typedef typename Superclass::InputSizeType          InputSizeType;
00085   typedef typename Superclass::InputSizeValueType     InputSizeValueType;
00086   typedef typename Superclass::InputSpacingType       InputSpacingType;
00087   typedef typename Superclass::InputIndexType         InputIndexType;
00088   typedef typename Superclass::InputIndexValueType    InputIndexValueType;
00089   typedef typename Superclass::InputPointType         InputPointType;
00090 
00091   typedef TFeatureImage                                 FeatureImageType;
00092   typedef typename Superclass::FeatureImagePointer      FeatureImagePointer;
00093   typedef typename Superclass::FeatureImageConstPointer FeatureImageConstPointer;
00094   typedef typename Superclass::FeaturePixelType         FeaturePixelType;
00095   typedef typename Superclass::FeatureRegionType        FeatureRegionType;
00096   typedef typename Superclass::FeatureSizeType          FeatureSizeType;
00097   typedef typename Superclass::FeatureSizeValueType     FeatureSizeValueType;
00098   typedef typename Superclass::FeatureSpacingType       FeatureSpacingType;
00099   typedef typename Superclass::FeatureIndexType         FeatureIndexType;
00100   typedef typename Superclass::FeaturePointType         FeaturePointType;
00101 
00102   typedef typename Superclass::ListPixelType         ListPixelType;
00103   typedef typename Superclass::ListImageType         ListImageType;
00104   typedef typename Superclass::ListImagePointer      ListImagePointer;
00105   typedef typename Superclass::ListImageConstPointer ListImageConstPointer;
00106   typedef typename Superclass::ListRegionType        ListRegionType;
00107   typedef typename Superclass::ListSizeType          ListSizeType;
00108   typedef typename Superclass::ListSizeValueType     ListSizeValueType;
00109   typedef typename Superclass::ListSpacingType       ListSpacingType;
00110   typedef typename Superclass::ListIndexType         ListIndexType;
00111   typedef typename Superclass::ListIndexValueType    ListIndexValueType;
00112   typedef typename Superclass::ListPointType         ListPointType;
00113   typedef typename Superclass::ListIteratorType      ListIteratorType;
00114 
00115   typedef typename Superclass::CentroidVectorType CentroidVectorType;
00116   typedef typename Superclass::SampleType         SampleType;
00117   typedef typename Superclass::TreeGeneratorType  TreeGeneratorType;
00118   typedef typename Superclass::TreePointer        TreePointer;
00119   typedef typename Superclass::TreeType           TreeType;
00120   typedef typename Superclass::KdTreePointer      KdTreePointer;
00121 
00122   typedef TSingleData                                            LevelSetDataType;
00123   typedef typename Superclass::LevelSetDataPointer               LevelSetDataPointer;
00124   typedef typename Superclass::LevelSetDataPointerVector         LevelSetDataPointerVector;
00125   typedef typename Superclass::LevelSetDataPointerVectorIterator LevelSetDataPointerVectorIterator;
00126 
00127   void PopulateListImage()
00128   {
00129     ListSpacingType spacing = this->m_NearestNeighborListImage->GetSpacing();
00130 
00131     ListRegionType region = this->m_NearestNeighborListImage->GetLargestPossibleRegion();
00132 
00133     ListIteratorType lIt(this->m_NearestNeighborListImage, region);
00134 
00135     if ( this->m_KdTree.IsNotNull() )
00136       {
00137       for ( lIt.GoToBegin(); !lIt.IsAtEnd(); ++lIt )
00138         {
00139         ListIndexType ind = lIt.GetIndex();
00140 
00141         float queryPoint[ImageDimension];
00142         for ( unsigned int i = 0; i < ImageDimension; i++ )
00143           {
00144           queryPoint[i] = ind[i] * spacing[i];
00145           }
00146 
00147         typename TreeType::InstanceIdentifierVectorType neighbors;
00148         this->m_KdTree->Search(queryPoint, this->m_NumberOfNeighbors, neighbors);
00149 
00150         ListPixelType L;
00151         for ( unsigned int i = 0; i < this->m_NumberOfNeighbors; i++ )
00152           {
00153           if ( this->m_LevelSetDataPointerVector[i]->VerifyInsideRegion(ind) )
00154             {
00155             L.push_back(neighbors[i]);
00156             }
00157           }
00158         lIt.Set(L);
00159         }
00160       }
00161     else
00162       {
00163       for ( lIt.GoToBegin(); !lIt.IsAtEnd(); ++lIt )
00164         {
00165         ListIndexType ind = lIt.GetIndex();
00166         ListPixelType L;
00167         for ( unsigned int i = 0; i < this->m_FunctionCount; i++ )
00168           {
00169           if ( this->m_LevelSetDataPointerVector[i]->VerifyInsideRegion(ind) )
00170             {
00171             L.push_back(i);
00172             }
00173           }
00174         lIt.Set(L);
00175         }
00176       }
00177   }
00178 
00179 protected:
00180   ConstrainedRegionBasedLevelSetFunctionSharedData():Superclass(){}
00181   ~ConstrainedRegionBasedLevelSetFunctionSharedData(){}
00182 private:
00183   ConstrainedRegionBasedLevelSetFunctionSharedData(const Self &); //purposely
00184                                                                   // not
00185                                                                   // implemented
00186   void operator=(const Self &);                                   //purposely
00187                                                                   // not
00188                                                                   // implemented
00189 };
00190 } //end namespace itk
00191 
00192 #endif
00193