ITK  4.8.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 {
71 template< typename TInput, typename TOutput >
73  public FastMarchingBase< TInput, TOutput >
74  {
75 public:
80  typedef typename Superclass::Traits Traits;
82 
84  itkNewMacro(Self);
85 
88 
89 
93 
97  typedef typename OutputImageType::SpacingType OutputSpacingType;
98  typedef typename OutputImageType::SizeType OutputSizeType;
99  typedef typename OutputImageType::RegionType OutputRegionType;
100  typedef typename OutputImageType::PointType OutputPointType;
101  typedef typename OutputImageType::DirectionType OutputDirectionType;
102 
103  typedef typename Traits::NodeType NodeType;
104  typedef typename Traits::NodePairType NodePairType;
105  typedef typename Traits::NodePairContainerType NodePairContainerType;
106  typedef typename Traits::NodePairContainerPointer NodePairContainerPointer;
107  typedef typename Traits::NodePairContainerConstIterator
109 
111 
112  itkStaticConstMacro( ImageDimension, unsigned int, Traits::ImageDimension );
113 
114 
117 
121 
124 
125  class InternalNodeStructure;
126 
127 
129 
130  itkGetModifiableObjectMacro(LabelImage, LabelImageType );
131 
139  virtual void SetOutputSize(const OutputSizeType & size)
140  { m_OutputRegion = size; }
142  { return m_OutputRegion.GetSize(); }
143  itkSetMacro(OutputRegion, OutputRegionType);
144  itkGetConstReferenceMacro(OutputRegion, OutputRegionType);
145  itkSetMacro(OutputSpacing, OutputSpacingType);
146  itkGetConstReferenceMacro(OutputSpacing, OutputSpacingType);
147  itkSetMacro(OutputDirection, OutputDirectionType);
148  itkGetConstReferenceMacro(OutputDirection, OutputDirectionType);
149  itkSetMacro(OutputOrigin, OutputPointType);
150  itkGetConstReferenceMacro(OutputOrigin, OutputPointType);
151  itkSetMacro(OverrideOutputInformation, bool);
152  itkGetConstReferenceMacro(OverrideOutputInformation, bool);
153  itkBooleanMacro(OverrideOutputInformation);
155 
156 protected:
157 
160 
163 
167 
173 
175  virtual void GenerateOutputInformation() ITK_OVERRIDE;
176 
177  virtual void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
178 
181 
182  IdentifierType GetTotalNumberOfNodes() const ITK_OVERRIDE;
183 
184  void SetOutputValue( OutputImageType* oDomain,
185  const NodeType& iNode,
186  const OutputPixelType& iValue ) ITK_OVERRIDE;
187 
190  const NodeType& iNode ) const ITK_OVERRIDE;
191 
193  unsigned char
194  GetLabelValueForGivenNode( const NodeType& iNode ) const ITK_OVERRIDE;
195 
197  void SetLabelValueForGivenNode( const NodeType& iNode,
198  const LabelType& iLabel ) ITK_OVERRIDE;
199 
201  virtual void UpdateNeighbors( OutputImageType* oImage,
202  const NodeType& iNode ) ITK_OVERRIDE;
203 
205  virtual void UpdateValue( OutputImageType* oImage,
206  const NodeType& iValue ) ITK_OVERRIDE;
207 
209  bool CheckTopology( OutputImageType* oImage,
210  const NodeType& iNode ) ITK_OVERRIDE;
211  void InitializeOutput( OutputImageType* oImage ) ITK_OVERRIDE;
213 
216  const NodeType& iNode,
217  InternalNodeStructureArray& ioNodesUsed );
218 
220  double Solve( OutputImageType* oImage,
221  const NodeType& iNode,
222  InternalNodeStructureArray& ioNeighbors ) const;
223 
224  // --------------------------------------------------------------------------
225  // --------------------------------------------------------------------------
226 
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
253  bool DoesVoxelChangeViolateStrictTopology( const NodeType& ) const;
254 
256 
257 private:
258 
260  void operator = ( const Self& );
261  };
262 }
263 
264 #include "itkFastMarchingImageFilterBase.hxx"
265 #endif // itkFastMarchingImageFilterBase_h
Array class with size defined at construction time.
Definition: itkArray.h:50
FixedArray< InternalNodeStructure, ImageDimension > InternalNodeStructureArray
bool DoesVoxelChangeViolateStrictTopology(const NodeType &) const
OutputImageType::SpacingType OutputSpacingType
Superclass::InputDomainPointer InputImagePointer
Traits::NodePairContainerType NodePairContainerType
bool IsCriticalC3Configuration2D(const std::bitset< 9 > &) const
bool IsCriticalC1Configuration2D(const std::bitset< 9 > &) const
unsigned int IsCriticalC2Configuration3D(const std::bitset< 8 > &) const
Superclass::OutputDomainPointer OutputImagePointer
Traits::NodePairContainerPointer NodePairContainerPointer
bool IsCriticalC1Configuration3D(const std::bitset< 8 > &) const
virtual void GenerateOutputInformation() override
Superclass::OutputDomainType OutputImageType
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:50
void InitializeOutput(OutputImageType *oImage) override
ConnectedComponentImagePointer m_ConnectedComponentImage
bool IsCriticalC4Configuration2D(const std::bitset< 9 > &) const
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
NeighborhoodIterator< LabelImageType > NeighborhoodIteratorType
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
bool IsChangeWellComposed2D(const NodeType &) const
Traits::OutputDomainPointer OutputDomainPointer
bool IsCriticalC2Configuration2D(const std::bitset< 9 > &) const
void GetInternalNodesUsed(OutputImageType *oImage, const NodeType &iNode, InternalNodeStructureArray &ioNodesUsed)
Image< unsigned char, ImageDimension > LabelImageType
Traits::InputDomainType InputDomainType
Traits::InputPixelType InputPixelType
double Solve(OutputImageType *oImage, const NodeType &iNode, InternalNodeStructureArray &ioNeighbors) const
Superclass::RadiusType RadiusType
OutputImageType::DirectionType OutputDirectionType
Traits::OutputPixelType OutputPixelType
unsigned char GetLabelValueForGivenNode(const NodeType &iNode) const override
Image< unsigned int, ImageDimension > ConnectedComponentImageType
Traits::NodePairContainerConstIterator NodePairContainerConstIterator
FastMarchingTraits< TInput, TOutput > Traits
bool CheckTopology(OutputImageType *oImage, const NodeType &iNode) override
virtual void EnlargeOutputRequestedRegion(DataObject *output) override
void SetOutputValue(OutputImageType *oDomain, const NodeType &iNode, const OutputPixelType &iValue) override
Set the output value (front value) for a given node.
bool IsChangeWellComposed3D(const NodeType &) const
bool DoesVoxelChangeViolateWellComposedness(const NodeType &) const
void SetLabelValueForGivenNode(const NodeType &iNode, const LabelType &iLabel) override
IdentifierType GetTotalNumberOfNodes() const override
Get the total number of nodes in the domain.
NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
virtual void UpdateNeighbors(OutputImageType *oImage, const NodeType &iNode) override
Traits::LabelType LabelType
virtual void SetOutputSize(const OutputSizeType &size)
Traits::OutputDomainType OutputDomainType
Base class for all data objects in ITK.
Traits::InputDomainPointer InputDomainPointer
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
const OutputPixelType GetOutputValue(OutputImageType *oImage, const NodeType &iNode) const override
FastMarchingBase< TInput, TOutput > Superclass
virtual void UpdateValue(OutputImageType *oImage, const NodeType &iValue) override