ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkWhitakerSparseLevelSetImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
19 #ifndef itkWhitakerSparseLevelSetImage_h
20 #define itkWhitakerSparseLevelSetImage_h
21 
22 #include "itkLevelSetSparseImage.h"
23 #include "itkLabelObject.h"
24 #include "itkLabelMap.h"
25 
26 namespace itk
27 {
40 template< typename TOutput, unsigned int VDimension >
41 class ITK_TEMPLATE_EXPORT WhitakerSparseLevelSetImage :
42  public LevelSetSparseImage< TOutput, VDimension >
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_ASSIGN(WhitakerSparseLevelSetImage);
46 
51 
53  itkNewMacro(Self);
54 
57 
58  static constexpr unsigned int Dimension = VDimension;
59 
60  using InputType = typename Superclass::InputType;
61  using OutputType = typename Superclass::OutputType;
62  using OutputRealType = typename Superclass::OutputRealType;
63  using GradientType = typename Superclass::GradientType;
64  using HessianType = typename Superclass::HessianType;
65  using LevelSetDataType = typename Superclass::LevelSetDataType;
66 
67  using LayerIdType = typename Superclass::LayerIdType;
68  using LabelObjectType = typename Superclass::LabelObjectType;
69  using LabelObjectPointer = typename Superclass::LabelObjectPointer;
70  using LabelObjectLengthType = typename Superclass::LabelObjectLengthType;
71  using LabelObjectLineType = typename Superclass::LabelObjectLineType;
72 
73  using LabelMapType = typename Superclass::LabelMapType;
74  using LabelMapPointer = typename Superclass::LabelMapPointer;
75  using LabelMapConstPointer = typename Superclass::LabelMapConstPointer;
77 
78  using LayerType = typename Superclass::LayerType;
79  using LayerIterator = typename Superclass::LayerIterator;
80  using LayerConstIterator = typename Superclass::LayerConstIterator;
81 
82  using LayerMapType = typename Superclass::LayerMapType;
83  using LayerMapIterator = typename Superclass::LayerMapIterator;
84  using LayerMapConstIterator = typename Superclass::LayerMapConstIterator;
85 
87  using Superclass::Evaluate;
88  OutputType Evaluate( const InputType& inputIndex ) const override;
89 
90 #ifdef ITK_USE_CONCEPT_CHECKING
91  // Begin concept checking
92 
93  itkConceptMacro( DoubleConvertible,
95 
96  // End concept checking
97 #endif // ITK_USE_CONCEPT_CHECKING
98 
99  static inline LayerIdType MinusThreeLayer() { return -3; }
100  static inline LayerIdType MinusTwoLayer() { return -2; }
101  static inline LayerIdType MinusOneLayer() { return -1; }
102  static inline LayerIdType ZeroLayer() { return 0; }
103  static inline LayerIdType PlusOneLayer() { return 1; }
104  static inline LayerIdType PlusTwoLayer() { return 2; }
105  static inline LayerIdType PlusThreeLayer() { return 3; }
106 
108  template< typename TLabel >
111  {
112  using OutputLabelObjectType = LabelObject< TLabel, Dimension >;
113  typename OutputLabelObjectType::Pointer object = OutputLabelObjectType::New();
115 
116  for( LayerIdType status = this->MinusThreeLayer(); status < this->PlusOneLayer(); ++status )
117  {
118  LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject( status );
119 
120  for( SizeValueType i = 0; i < labelObject->GetNumberOfLines(); ++i )
121  {
122  object->AddLine( labelObject->GetLine( i ) );
123  }
124  }
125  object->Optimize();
126 
127  return object;
128  }
129 
130 protected:
132  ~WhitakerSparseLevelSetImage() override = default;
133 
135  void InitializeLayers() override;
136 
137  void InitializeInternalLabelList() override;
138 };
139 }
140 
141 #ifndef ITK_MANUAL_INSTANTIATION
142 #include "itkWhitakerSparseLevelSetImage.hxx"
143 #endif
144 
145 #endif // itkWhitakerSparseLevelSetImage_h
typename LabelObjectType::LengthType LabelObjectLengthType
typename LayerMapType::const_iterator LayerMapConstIterator
typename LabelMapType::RegionType RegionType
std::map< InputType, OutputType, Functor::LexicographicCompare > LayerType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename Superclass::OutputRealType OutputRealType
typename LabelObjectType::Pointer LabelObjectPointer
typename Superclass::HessianType HessianType
LabelObject< TLabel, Dimension >::Pointer GetAsLabelObject()
Base class for the sparse representation of a level-set function on one Image.
typename LayerMapType::iterator LayerMapIterator
typename Superclass::InputType InputType
typename LayerType::iterator LayerIterator
Derived class for the sparse-field representation of level-set function.
typename LayerType::const_iterator LayerConstIterator
std::map< LayerIdType, LayerType > LayerMapType
typename Superclass::OutputType OutputType
typename Superclass::LevelSetDataType LevelSetDataType
The base class for the representation of an labeled binary object in an image.
typename Superclass::GradientType GradientType
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
typename LabelObjectType::LineType LabelObjectLineType
typename LabelMapType::ConstPointer LabelMapConstPointer
typename LabelMapType::Pointer LabelMapPointer
#define itkConceptMacro(name, concept)
Base class for all data objects in ITK.