ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkFastMarchingImageFilterBase.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 __itkFastMarchingImageFilterBase_h
20 #define __itkFastMarchingImageFilterBase_h
21 
22 #include "itkFastMarchingBase.h"
25 #include "itkArray.h"
26 
27 namespace itk
28 {
70 template< class TInput, class TOutput >
72  public FastMarchingBase< TInput, TOutput >
73  {
74 public:
79  typedef typename Superclass::Traits Traits;
81 
83  itkNewMacro(Self);
84 
87 
88 
92 
96  typedef typename OutputImageType::SpacingType OutputSpacingType;
97  typedef typename OutputImageType::SizeType OutputSizeType;
98  typedef typename OutputImageType::RegionType OutputRegionType;
99  typedef typename OutputImageType::PointType OutputPointType;
100  typedef typename OutputImageType::DirectionType OutputDirectionType;
101 
102  typedef typename Traits::NodeType NodeType;
103  typedef typename Traits::NodePairType NodePairType;
104  typedef typename Traits::NodePairContainerType NodePairContainerType;
105  typedef typename Traits::NodePairContainerPointer NodePairContainerPointer;
106  typedef typename Traits::NodePairContainerConstIterator
108 
109  /*
110  typedef typename Superclass::ElementIdentifier ElementIdentifier;
111 
112  typedef typename Superclass::PriorityQueueElementType PriorityQueueElementType;
113 
114  typedef typename Superclass::PriorityQueueType PriorityQueueType;
115  typedef typename Superclass::PriorityQueuePointer PriorityQueuePointer;
116  */
117 
119 
120  itkStaticConstMacro( ImageDimension, unsigned int, Traits::ImageDimension );
121 
124 
128 
131 
132  itkGetObjectMacro( LabelImage, LabelImageType );
133 
134 
142  virtual void SetOutputSize(const OutputSizeType & size)
143  { m_OutputRegion = size; }
145  { return m_OutputRegion.GetSize(); }
146  itkSetMacro(OutputRegion, OutputRegionType);
147  itkGetConstReferenceMacro(OutputRegion, OutputRegionType);
148  itkSetMacro(OutputSpacing, OutputSpacingType);
149  itkGetConstReferenceMacro(OutputSpacing, OutputSpacingType);
150  itkSetMacro(OutputDirection, OutputDirectionType);
151  itkGetConstReferenceMacro(OutputDirection, OutputDirectionType);
152  itkSetMacro(OutputOrigin, OutputPointType);
153  itkGetConstReferenceMacro(OutputOrigin, OutputPointType);
154  itkSetMacro(OverrideOutputInformation, bool);
155  itkGetConstReferenceMacro(OverrideOutputInformation, bool);
156  itkBooleanMacro(OverrideOutputInformation);
158 
159 protected:
160 
163 
166 
167  class InternalNodeStructure;
168 
172 
178 
180  virtual void GenerateOutputInformation();
181 
182  virtual void EnlargeOutputRequestedRegion(DataObject *output);
183 
186 
188 
189  void SetOutputValue( OutputImageType* oDomain,
190  const NodeType& iNode,
191  const OutputPixelType& iValue );
192 
195  const NodeType& iNode ) const;
196 
198  unsigned char
199  GetLabelValueForGivenNode( const NodeType& iNode ) const;
200 
202  void SetLabelValueForGivenNode( const NodeType& iNode,
203  const LabelType& iLabel );
204 
206  virtual void UpdateNeighbors( OutputImageType* oImage,
207  const NodeType& iNode );
208 
210  virtual void UpdateValue( OutputImageType* oImage,
211  const NodeType& iValue );
212 
214  bool CheckTopology( OutputImageType* oImage,
215  const NodeType& iNode );
216  void InitializeOutput( OutputImageType* oImage );
218 
221  const NodeType& iNode,
222  std::vector< InternalNodeStructure >& ioNodesUsed );
223 
225  double Solve( OutputImageType* oImage,
226  const NodeType& iNode,
227  std::vector< InternalNodeStructure >& ioNeighbors ) const;
228 
229  // --------------------------------------------------------------------------
230  // --------------------------------------------------------------------------
231 
236  // Functions/data for the 2-D case
237  void InitializeIndices2D();
238  bool IsChangeWellComposed2D( const NodeType& ) const;
239  bool IsCriticalC1Configuration2D( const std::vector<bool>& ) const;
240  bool IsCriticalC2Configuration2D( const std::vector<bool>& ) const;
241  bool IsCriticalC3Configuration2D( const std::vector<bool>& ) const;
242  bool IsCriticalC4Configuration2D( const std::vector<bool>& ) const;
243 
246 
247  // Functions/data for the 3-D case
248  void InitializeIndices3D();
249  bool IsCriticalC1Configuration3D( const std::vector<bool>& ) const;
250  unsigned int IsCriticalC2Configuration3D( const std::vector<bool>& ) const;
251  bool IsChangeWellComposed3D( const NodeType& ) const;
252 
255 
256  // Functions for both 2D/3D cases
258  bool DoesVoxelChangeViolateStrictTopology( const NodeType& ) const;
259 
260 private:
261 
263  void operator = ( const Self& );
264  };
265 }
266 
267 #include "itkFastMarchingImageFilterBase.hxx"
268 #endif // __itkFastMarchingImageFilterBase_h
269