ITK  5.3.0
Insight Toolkit
itkRegionBasedLevelSetFunctionData.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkRegionBasedLevelSetFunctionData_h
19 #define itkRegionBasedLevelSetFunctionData_h
20 
21 #include "itkLightObject.h"
22 
23 #include "itkVector.h"
24 #include "itkListSample.h"
25 #include "itkKdTreeGenerator.h"
26 
27 #include "itkImageRegionIterator.h"
29 
30 namespace itk
31 {
67 template <typename TInputImage, typename TFeatureImage>
68 class ITK_TEMPLATE_EXPORT RegionBasedLevelSetFunctionData : public LightObject
69 {
70 public:
71  ITK_DISALLOW_COPY_AND_MOVE(RegionBasedLevelSetFunctionData);
72 
77 
78  static constexpr unsigned int ImageDimension = TFeatureImage::ImageDimension;
79 
81  itkNewMacro(Self);
82 
84 
85  using InputImageType = TInputImage;
86  using InputImagePointer = typename InputImageType::Pointer;
87  using InputImageConstPointer = typename InputImageType::ConstPointer;
88  using InputPixelType = typename InputImageType::PixelType;
92  using InputSpacingType = typename InputImageType::SpacingType;
96 
97  using FeatureImageType = TFeatureImage;
98  using FeatureImagePointer = typename FeatureImageType::Pointer;
99  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
100  using FeaturePixelType = typename FeatureImageType::PixelType;
104  using FeatureSpacingType = typename FeatureImageType::SpacingType;
107 
108  // Allocates m_HeavisideFunctionOfLevelSetImage to have same origin,
109  // spacing and size as image. Also sets the m_Start and m_End indices.
110  void
111  CreateHeavisideFunctionOfLevelSetImage(const InputImageType * image);
112 
113  // Checks if the given index lies in the domain of the current
114  // level-set function. The domain is defined by the start and end indices.
115  template <typename TIndex>
116  bool
117  VerifyInsideRegion(const TIndex & featureIndex)
118  {
119  for (unsigned int j = 0; j < ImageDimension; ++j)
120  {
121  if ((featureIndex[j] < static_cast<InputIndexValueType>(this->m_Start[j])) ||
122  (featureIndex[j] > static_cast<InputIndexValueType>(this->m_End[j])))
123  {
124  return false;
125  }
126  }
127  return true;
128  }
129 
130  // Get the index into the domain of the current level-set function
131  InputIndexType
132  GetIndex(const FeatureIndexType & featureIndex);
133 
134  // Get the index in the domain of the feature image
135  FeatureIndexType
136  GetFeatureIndex(const InputIndexType & inputIndex);
137 
140 
144 
145 protected:
147  ~RegionBasedLevelSetFunctionData() override = default;
148 };
149 } // end namespace itk
150 
151 #ifndef ITK_MANUAL_INSTANTIATION
152 # include "itkRegionBasedLevelSetFunctionData.hxx"
153 #endif
154 #endif
itk::RegionBasedLevelSetFunctionData::InputSizeValueType
typename InputSizeType::SizeValueType InputSizeValueType
Definition: itkRegionBasedLevelSetFunctionData.h:91
itk::RegionBasedLevelSetFunctionData::InputIndexValueType
typename InputIndexType::IndexValueType InputIndexValueType
Definition: itkRegionBasedLevelSetFunctionData.h:94
itk::RegionBasedLevelSetFunctionData::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkRegionBasedLevelSetFunctionData.h:87
itk::RegionBasedLevelSetFunctionData::m_HeavisideFunctionOfLevelSetImage
InputImagePointer m_HeavisideFunctionOfLevelSetImage
Definition: itkRegionBasedLevelSetFunctionData.h:141
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::RegionBasedLevelSetFunctionData::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkRegionBasedLevelSetFunctionData.h:98
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::RegionBasedLevelSetFunctionData::m_Start
InputIndexType m_Start
Definition: itkRegionBasedLevelSetFunctionData.h:142
itk::RegionBasedLevelSetFunctionData::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkRegionBasedLevelSetFunctionData.h:88
itk::SmartPointer< Self >
itkImageRegionIterator.h
itkImageRegionIteratorWithIndex.h
itk::RegionBasedLevelSetFunctionData::FeatureRegionType
typename FeatureImageType::RegionType FeatureRegionType
Definition: itkRegionBasedLevelSetFunctionData.h:101
itk::RegionBasedLevelSetFunctionData::m_WeightedNumberOfPixelsOutsideLevelSet
double m_WeightedNumberOfPixelsOutsideLevelSet
Definition: itkRegionBasedLevelSetFunctionData.h:139
itk::RegionBasedLevelSetFunctionData::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkRegionBasedLevelSetFunctionData.h:97
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::RegionBasedLevelSetFunctionData::FeaturePixelType
typename FeatureImageType::PixelType FeaturePixelType
Definition: itkRegionBasedLevelSetFunctionData.h:100
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::RegionBasedLevelSetFunctionData::FeatureSpacingType
typename FeatureImageType::SpacingType FeatureSpacingType
Definition: itkRegionBasedLevelSetFunctionData.h:104
itk::RegionBasedLevelSetFunctionData::InputPointType
typename InputImageType::PointType InputPointType
Definition: itkRegionBasedLevelSetFunctionData.h:95
itk::RegionBasedLevelSetFunctionData::m_End
InputIndexType m_End
Definition: itkRegionBasedLevelSetFunctionData.h:143
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::RegionBasedLevelSetFunctionData::VerifyInsideRegion
bool VerifyInsideRegion(const TIndex &featureIndex)
Definition: itkRegionBasedLevelSetFunctionData.h:117
itk::RegionBasedLevelSetFunctionData::FeatureIndexType
typename FeatureImageType::IndexType FeatureIndexType
Definition: itkRegionBasedLevelSetFunctionData.h:105
itk::RegionBasedLevelSetFunctionData::FeaturePointType
typename FeatureImageType::PointType FeaturePointType
Definition: itkRegionBasedLevelSetFunctionData.h:106
itkListSample.h
itk::RegionBasedLevelSetFunctionData::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkRegionBasedLevelSetFunctionData.h:93
itk::RegionBasedLevelSetFunctionData
Helper class used to share data in the ScalarChanAndVeseLevelSetFunction.
Definition: itkRegionBasedLevelSetFunctionData.h:68
itk::RegionBasedLevelSetFunctionData::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkRegionBasedLevelSetFunctionData.h:90
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::RegionBasedLevelSetFunctionData::InputImageType
TInputImage InputImageType
Definition: itkRegionBasedLevelSetFunctionData.h:85
itkVector.h
itk::RegionBasedLevelSetFunctionData::FeatureSizeType
typename FeatureImageType::SizeType FeatureSizeType
Definition: itkRegionBasedLevelSetFunctionData.h:102
itkKdTreeGenerator.h
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::RegionBasedLevelSetFunctionData::FeatureSizeValueType
typename FeatureSizeType::SizeValueType FeatureSizeValueType
Definition: itkRegionBasedLevelSetFunctionData.h:103
itk::RegionBasedLevelSetFunctionData::InputRegionType
typename InputImageType::RegionType InputRegionType
Definition: itkRegionBasedLevelSetFunctionData.h:89
itk::RegionBasedLevelSetFunctionData::InputSpacingType
typename InputImageType::SpacingType InputSpacingType
Definition: itkRegionBasedLevelSetFunctionData.h:92
itk::RegionBasedLevelSetFunctionData::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkRegionBasedLevelSetFunctionData.h:86
itk::RegionBasedLevelSetFunctionData::m_WeightedNumberOfPixelsInsideLevelSet
double m_WeightedNumberOfPixelsInsideLevelSet
Definition: itkRegionBasedLevelSetFunctionData.h:138
itk::RegionBasedLevelSetFunctionData::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkRegionBasedLevelSetFunctionData.h:99
itkLightObject.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83