ITK  4.2.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 >
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;
64 
70 
74 
75  typedef typename Superclass::LayerType LayerType;
78 
82 
85  virtual OutputType Evaluate( const InputType& iP ) const;
86 
87 #ifdef ITK_USE_CONCEPT_CHECKING
88 
90  itkConceptMacro( DoubleConvertible,
92 
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< class 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:
128 
131 
133  virtual void InitializeLayers();
134 
135  virtual void InitializeInternalLabelList();
136 
137 private:
138 
139  WhitakerSparseLevelSetImage( const Self& ); // purposely not implemented
140  void operator = ( const Self& ); // purposely not implemented
141 };
142 }
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "itkWhitakerSparseLevelSetImage.hxx"
146 #endif
147 
148 #endif // __itkWhitakerSparseLevelSetImage_h
149