ITK  6.0.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  * https://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 {
64 template <typename TInputImage, typename TFeatureImage>
65 class ITK_TEMPLATE_EXPORT RegionBasedLevelSetFunctionData : public LightObject
66 {
67 public:
68  ITK_DISALLOW_COPY_AND_MOVE(RegionBasedLevelSetFunctionData);
69 
74 
75  static constexpr unsigned int ImageDimension = TFeatureImage::ImageDimension;
76 
78  itkNewMacro(Self);
79 
80  itkOverrideGetNameOfClassMacro(RegionBasedLevelSetFunctionData);
81 
82  using InputImageType = TInputImage;
85  using InputPixelType = typename InputImageType::PixelType;
89  using InputSpacingType = typename InputImageType::SpacingType;
93 
94  using FeatureImageType = TFeatureImage;
97  using FeaturePixelType = typename FeatureImageType::PixelType;
101  using FeatureSpacingType = typename FeatureImageType::SpacingType;
104 
105  // Allocates m_HeavisideFunctionOfLevelSetImage to have same origin,
106  // spacing and size as image. Also sets the m_Start and m_End indices.
107  void
108  CreateHeavisideFunctionOfLevelSetImage(const InputImageType * image);
109 
110  // Checks if the given index lies in the domain of the current
111  // level-set function. The domain is defined by the start and end indices.
112  template <typename TIndex>
113  bool
114  VerifyInsideRegion(const TIndex & featureIndex)
115  {
116  for (unsigned int j = 0; j < ImageDimension; ++j)
117  {
118  if ((featureIndex[j] < static_cast<InputIndexValueType>(this->m_Start[j])) ||
119  (featureIndex[j] > static_cast<InputIndexValueType>(this->m_End[j])))
120  {
121  return false;
122  }
123  }
124  return true;
125  }
126 
127  // Get the index into the domain of the current level-set function
128  InputIndexType
129  GetIndex(const FeatureIndexType & featureIndex);
130 
131  // Get the index in the domain of the feature image
132  FeatureIndexType
133  GetFeatureIndex(const InputIndexType & inputIndex);
134 
135  double m_WeightedNumberOfPixelsInsideLevelSet{};
136  double m_WeightedNumberOfPixelsOutsideLevelSet{};
137 
138  InputImagePointer m_HeavisideFunctionOfLevelSetImage{};
139  InputIndexType m_Start{};
140  InputIndexType m_End{};
141 
142 protected:
144  ~RegionBasedLevelSetFunctionData() override = default;
145 };
146 } // end namespace itk
147 
148 #ifndef ITK_MANUAL_INSTANTIATION
149 # include "itkRegionBasedLevelSetFunctionData.hxx"
150 #endif
151 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::RegionBasedLevelSetFunctionData::InputSizeValueType
typename InputSizeType::SizeValueType InputSizeValueType
Definition: itkRegionBasedLevelSetFunctionData.h:88
itk::RegionBasedLevelSetFunctionData::InputIndexValueType
typename InputIndexType::IndexValueType InputIndexValueType
Definition: itkRegionBasedLevelSetFunctionData.h:91
itk::RegionBasedLevelSetFunctionData::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkRegionBasedLevelSetFunctionData.h:84
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::RegionBasedLevelSetFunctionData::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkRegionBasedLevelSetFunctionData.h:95
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::RegionBasedLevelSetFunctionData::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkRegionBasedLevelSetFunctionData.h:85
itk::SmartPointer< Self >
itkImageRegionIterator.h
itkImageRegionIteratorWithIndex.h
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::RegionBasedLevelSetFunctionData::FeatureRegionType
typename FeatureImageType::RegionType FeatureRegionType
Definition: itkRegionBasedLevelSetFunctionData.h:98
itk::RegionBasedLevelSetFunctionData::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkRegionBasedLevelSetFunctionData.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::RegionBasedLevelSetFunctionData::FeaturePixelType
typename FeatureImageType::PixelType FeaturePixelType
Definition: itkRegionBasedLevelSetFunctionData.h:97
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::RegionBasedLevelSetFunctionData::FeatureSpacingType
typename FeatureImageType::SpacingType FeatureSpacingType
Definition: itkRegionBasedLevelSetFunctionData.h:101
itk::RegionBasedLevelSetFunctionData::InputPointType
typename InputImageType::PointType InputPointType
Definition: itkRegionBasedLevelSetFunctionData.h:92
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::RegionBasedLevelSetFunctionData::VerifyInsideRegion
bool VerifyInsideRegion(const TIndex &featureIndex)
Definition: itkRegionBasedLevelSetFunctionData.h:114
itk::RegionBasedLevelSetFunctionData::FeatureIndexType
typename FeatureImageType::IndexType FeatureIndexType
Definition: itkRegionBasedLevelSetFunctionData.h:102
itk::RegionBasedLevelSetFunctionData::FeaturePointType
typename FeatureImageType::PointType FeaturePointType
Definition: itkRegionBasedLevelSetFunctionData.h:103
itkListSample.h
itk::RegionBasedLevelSetFunctionData::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkRegionBasedLevelSetFunctionData.h:90
itk::RegionBasedLevelSetFunctionData
Helper class used to share data in the ScalarChanAndVeseLevelSetFunction.
Definition: itkRegionBasedLevelSetFunctionData.h:65
itk::RegionBasedLevelSetFunctionData::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkRegionBasedLevelSetFunctionData.h:87
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:82
itkVector.h
itk::RegionBasedLevelSetFunctionData::FeatureSizeType
typename FeatureImageType::SizeType FeatureSizeType
Definition: itkRegionBasedLevelSetFunctionData.h:99
itkKdTreeGenerator.h
itk::RegionBasedLevelSetFunctionData::FeatureSizeValueType
typename FeatureSizeType::SizeValueType FeatureSizeValueType
Definition: itkRegionBasedLevelSetFunctionData.h:100
itk::RegionBasedLevelSetFunctionData::InputRegionType
typename InputImageType::RegionType InputRegionType
Definition: itkRegionBasedLevelSetFunctionData.h:86
itk::RegionBasedLevelSetFunctionData::InputSpacingType
typename InputImageType::SpacingType InputSpacingType
Definition: itkRegionBasedLevelSetFunctionData.h:89
itk::RegionBasedLevelSetFunctionData::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkRegionBasedLevelSetFunctionData.h:83
itk::RegionBasedLevelSetFunctionData::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkRegionBasedLevelSetFunctionData.h:96
itkLightObject.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86