ITK  4.12.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;
101  typedef typename OutputImageType::SizeType OutputSizeType;
102  typedef typename OutputImageType::RegionType OutputRegionType;
103  typedef typename OutputImageType::PointType OutputPointType;
104  typedef typename OutputImageType::DirectionType OutputDirectionType;
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 
163 
165  virtual ~FastMarchingImageFilterBase();
166 
170 
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  // --------------------------------------------------------------------------
229 
234  // Functions/data for the 2-D case
235  void InitializeIndices2D();
236  bool IsChangeWellComposed2D( const NodeType& ) const;
237  bool IsCriticalC1Configuration2D( const std::bitset<9>& ) const;
238  bool IsCriticalC2Configuration2D( const std::bitset<9>& ) const;
239  bool IsCriticalC3Configuration2D( const std::bitset<9>& ) const;
240  bool IsCriticalC4Configuration2D( const std::bitset<9>& ) const;
241 
242  Array<unsigned char> m_RotationIndices[4];
243  Array<unsigned char> m_ReflectionIndices[2];
244 
245  // Functions/data for the 3-D case
246  void InitializeIndices3D();
247  bool IsCriticalC1Configuration3D( const std::bitset<8>& ) const;
248  unsigned int IsCriticalC2Configuration3D( const std::bitset<8>& ) const;
249  bool IsChangeWellComposed3D( const NodeType& ) const;
250 
251  Array<unsigned char> m_C1Indices[12];
252  Array<unsigned char> m_C2Indices[8];
253 
254  // Functions for both 2D/3D cases
255  bool DoesVoxelChangeViolateWellComposedness( const NodeType& ) const;
256  bool DoesVoxelChangeViolateStrictTopology( const NodeType& ) const;
257 
258  const InputImageType* m_InputCache;
259 
260 private:
261 
263  void operator = ( const Self& );
264  };
265 }
266 
267 #include "itkFastMarchingImageFilterBase.hxx"
268 #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
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
Base class for all data objects in ITK.
Image< unsigned int, ImageDimension > ConnectedComponentImageType
Traits::NodePairContainerConstIterator NodePairContainerConstIterator
NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
Traits::LabelType LabelType
virtual void SetOutputSize(const OutputSizeType &size)
Traits::OutputDomainType OutputDomainType
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