ITK  4.13.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 #include <bitset>
27 
28 namespace itk
29 {
74 template< typename TInput, typename TOutput >
75 class ITK_TEMPLATE_EXPORT FastMarchingImageFilterBase :
76  public FastMarchingBase< TInput, TOutput >
77  {
78 public:
83  typedef typename Superclass::Traits Traits;
85 
87  itkNewMacro(Self);
88 
91 
92 
94  typedef typename Superclass::InputDomainPointer InputImagePointer;
95  typedef typename Superclass::InputPixelType InputPixelType;
96 
98  typedef typename Superclass::OutputDomainPointer OutputImagePointer;
99  typedef typename Superclass::OutputPixelType OutputPixelType;
100  typedef typename OutputImageType::SpacingType OutputSpacingType;
102  typedef typename OutputImageType::RegionType OutputRegionType;
105 
106  typedef typename Traits::NodeType NodeType;
107  typedef typename Traits::NodePairType NodePairType;
108  typedef typename Traits::NodePairContainerType NodePairContainerType;
109  typedef typename Traits::NodePairContainerPointer NodePairContainerPointer;
110  typedef typename Traits::NodePairContainerConstIterator
112 
113  typedef typename Superclass::LabelType LabelType;
114 
115  itkStaticConstMacro( ImageDimension, unsigned int, Traits::ImageDimension );
116 
117 
120 
124 
127 
128  class InternalNodeStructure;
129 
130 
132 
133  itkGetModifiableObjectMacro(LabelImage, LabelImageType );
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 
162 
163  virtual ~FastMarchingImageFilterBase() ITK_OVERRIDE;
164 
165  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
166 
167  OutputRegionType m_BufferedRegion;
168  NodeType m_StartIndex;
169  NodeType m_LastIndex;
170 
171  OutputRegionType m_OutputRegion;
172  OutputPointType m_OutputOrigin;
173  OutputSpacingType m_OutputSpacing;
174  OutputDirectionType m_OutputDirection;
175  bool m_OverrideOutputInformation;
176 
178  virtual void GenerateOutputInformation() ITK_OVERRIDE;
179 
180  virtual void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
181 
182  LabelImagePointer m_LabelImage;
183  ConnectedComponentImagePointer m_ConnectedComponentImage;
184 
185  IdentifierType GetTotalNumberOfNodes() const ITK_OVERRIDE;
186 
187  void SetOutputValue( OutputImageType* oDomain,
188  const NodeType& iNode,
189  const OutputPixelType& iValue ) ITK_OVERRIDE;
190 
192  const OutputPixelType GetOutputValue( OutputImageType* oImage,
193  const NodeType& iNode ) const ITK_OVERRIDE;
194 
196  unsigned char
197  GetLabelValueForGivenNode( const NodeType& iNode ) const ITK_OVERRIDE;
198 
200  void SetLabelValueForGivenNode( const NodeType& iNode,
201  const LabelType& iLabel ) ITK_OVERRIDE;
202 
204  virtual void UpdateNeighbors( OutputImageType* oImage,
205  const NodeType& iNode ) ITK_OVERRIDE;
206 
208  virtual void UpdateValue( OutputImageType* oImage,
209  const NodeType& iValue ) ITK_OVERRIDE;
210 
212  bool CheckTopology( OutputImageType* oImage,
213  const NodeType& iNode ) ITK_OVERRIDE;
214  void InitializeOutput( OutputImageType* oImage ) ITK_OVERRIDE;
216 
218  void GetInternalNodesUsed( OutputImageType* oImage,
219  const NodeType& iNode,
220  InternalNodeStructureArray& ioNodesUsed );
221 
223  double Solve( OutputImageType* oImage,
224  const NodeType& iNode,
225  InternalNodeStructureArray& ioNeighbors ) const;
226 
227  //
228  // Functions and variables to check for topology changes (2D/3D only).
229  //
230 
231  // Functions/data for the 2-D case
232  void InitializeIndices2D();
233  bool IsChangeWellComposed2D( const NodeType& ) const;
234  bool IsCriticalC1Configuration2D( const std::bitset<9>& ) const;
235  bool IsCriticalC2Configuration2D( const std::bitset<9>& ) const;
236  bool IsCriticalC3Configuration2D( const std::bitset<9>& ) const;
237  bool IsCriticalC4Configuration2D( const std::bitset<9>& ) const;
238 
239  Array<unsigned char> m_RotationIndices[4];
240  Array<unsigned char> m_ReflectionIndices[2];
241 
242  // Functions/data for the 3-D case
243  void InitializeIndices3D();
244  bool IsCriticalC1Configuration3D( const std::bitset<8>& ) const;
245  unsigned int IsCriticalC2Configuration3D( const std::bitset<8>& ) const;
246  bool IsChangeWellComposed3D( const NodeType& ) const;
247 
248  Array<unsigned char> m_C1Indices[12];
249  Array<unsigned char> m_C2Indices[8];
250 
251  // Functions for both 2D/3D cases
252  bool DoesVoxelChangeViolateWellComposedness( const NodeType& ) const;
253  bool DoesVoxelChangeViolateStrictTopology( const NodeType& ) const;
254 
255  const InputImageType* m_InputCache;
256 
257 private:
258 
259  ITK_DISALLOW_COPY_AND_ASSIGN(FastMarchingImageFilterBase);
260 };
261 } // end namespace itk
262 
263 #ifndef ITK_MANUAL_INSTANTIATION
264 #include "itkFastMarchingImageFilterBase.hxx"
265 #endif
266 
267 #endif // itkFastMarchingImageFilterBase_h
Array class with size defined at construction time.
Definition: itkArray.h:50
FixedArray< InternalNodeStructure, ImageDimension > InternalNodeStructureArray
OutputImageType::SpacingType OutputSpacingType
Superclass::InputDomainPointer InputImagePointer
Traits::NodePairContainerType NodePairContainerType
Apply the Fast Marching method to solve an Eikonal equation on an image.
Superclass::OutputDomainPointer OutputImagePointer
Traits::NodePairContainerPointer NodePairContainerPointer
Superclass::OutputDomainType OutputImageType
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:50
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
NeighborhoodIterator< LabelImageType > NeighborhoodIteratorType
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
Image< unsigned char, ImageDimension > LabelImageType
Traits::InputDomainType InputDomainType
Superclass::RadiusType RadiusType
OutputImageType::DirectionType OutputDirectionType
Traits::OutputPixelType OutputPixelType
Image< unsigned int, ImageDimension > ConnectedComponentImageType
Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Control indentation during Print() invocation.
Definition: itkIndent.h:49
NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
Traits::LabelType LabelType
virtual void SetOutputSize(const OutputSizeType &size)
Traits::OutputDomainType OutputDomainType
Base class for all data objects in ITK.
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Templated n-dimensional image class.
Definition: itkImage.h:75
ConnectedComponentImageType::Pointer ConnectedComponentImagePointer
virtual OutputSizeType GetOutputSize() const
FastMarchingBase< TInput, TOutput > Superclass