ITK  4.13.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:
49 
51  itkNewMacro(Self);
52 
55 
56  itkStaticConstMacro ( Dimension, unsigned int, VDimension );
57 
58  typedef typename Superclass::InputType InputType;
59  typedef typename Superclass::OutputType OutputType;
61  typedef typename Superclass::GradientType GradientType;
62  typedef typename Superclass::HessianType HessianType;
63  typedef typename Superclass::LevelSetDataType LevelSetDataType;
64 
66  typedef typename Superclass::LabelObjectType LabelObjectType;
67  typedef typename Superclass::LabelObjectPointer LabelObjectPointer;
68  typedef typename Superclass::LabelObjectLengthType LabelObjectLengthType;
69  typedef typename Superclass::LabelObjectLineType LabelObjectLineType;
70 
71  typedef typename Superclass::LabelMapType LabelMapType;
72  typedef typename Superclass::LabelMapPointer LabelMapPointer;
73  typedef typename Superclass::RegionType RegionType;
74 
75  typedef typename Superclass::LayerType LayerType;
76  typedef typename Superclass::LayerIterator LayerIterator;
77  typedef typename Superclass::LayerConstIterator LayerConstIterator;
78 
79  typedef typename Superclass::LayerMapType LayerMapType;
80  typedef typename Superclass::LayerMapIterator LayerMapIterator;
81  typedef typename Superclass::LayerMapConstIterator LayerMapConstIterator;
82 
84  using Superclass::Evaluate;
85  virtual OutputType Evaluate( const InputType& inputIndex ) const ITK_OVERRIDE;
86 
87 #ifdef ITK_USE_CONCEPT_CHECKING
88  // Begin concept checking
89 
90  itkConceptMacro( DoubleConvertible,
92 
93  // End concept checking
94 #endif // ITK_USE_CONCEPT_CHECKING
95 
96  static inline LayerIdType MinusThreeLayer() { return -3; }
97  static inline LayerIdType MinusTwoLayer() { return -2; }
98  static inline LayerIdType MinusOneLayer() { return -1; }
99  static inline LayerIdType ZeroLayer() { return 0; }
100  static inline LayerIdType PlusOneLayer() { return 1; }
101  static inline LayerIdType PlusTwoLayer() { return 2; }
102  static inline LayerIdType PlusThreeLayer() { return 3; }
103 
105  template< typename TLabel >
108  {
109  typedef LabelObject< TLabel, Dimension > OutputLabelObjectType;
110  typename OutputLabelObjectType::Pointer object = OutputLabelObjectType::New();
112 
113  for( LayerIdType status = this->MinusThreeLayer(); status < this->PlusOneLayer(); ++status )
114  {
115  LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject( status );
116 
117  for( SizeValueType i = 0; i < labelObject->GetNumberOfLines(); ++i )
118  {
119  object->AddLine( labelObject->GetLine( i ) );
120  }
121  }
122  object->Optimize();
123 
124  return object;
125  }
126 
127 protected:
129  virtual ~WhitakerSparseLevelSetImage() ITK_OVERRIDE;
130 
132  virtual void InitializeLayers() ITK_OVERRIDE;
133 
134  virtual void InitializeInternalLabelList() ITK_OVERRIDE;
135 
136 private:
137  ITK_DISALLOW_COPY_AND_ASSIGN(WhitakerSparseLevelSetImage);
138 
139 };
140 }
141 
142 #ifndef ITK_MANUAL_INSTANTIATION
143 #include "itkWhitakerSparseLevelSetImage.hxx"
144 #endif
145 
146 #endif // itkWhitakerSparseLevelSetImage_h
std::map< InputType, OutputType, Functor::IndexLexicographicCompare< VDimension > > LayerType
LevelSetSparseImage< TOutput, VDimension > Superclass
Superclass::LabelObjectLengthType LabelObjectLengthType
LabelObject< TLabel, Dimension >::Pointer GetAsLabelObject()
Superclass::LayerConstIterator LayerConstIterator
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Superclass::LayerMapConstIterator LayerMapConstIterator
Base class for the sparse representation of a level-set function on one Image.
Derived class for the sparse-field representation of level-set function.
Superclass::LevelSetDataType LevelSetDataType
Superclass::OutputRealType OutputRealType
Superclass::LabelObjectLineType LabelObjectLineType
Superclass::LayerMapIterator LayerMapIterator
Superclass::OutputType OutputType
The base class for the representation of an labeled binary object in an image.
Superclass::LabelObjectPointer LabelObjectPointer
#define itkConceptMacro(name, concept)
Base class for all data objects in ITK.