ITK  5.0.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:
79  ITK_DISALLOW_COPY_AND_ASSIGN(FastMarchingImageFilterBase);
80 
85  using Traits = typename Superclass::Traits;
86 
88  itkNewMacro(Self);
89 
92 
93 
94  using InputImageType = typename Superclass::InputDomainType;
95  using InputImagePointer = typename Superclass::InputDomainPointer;
96  using InputPixelType = typename Superclass::InputPixelType;
97 
98  using OutputImageType = typename Superclass::OutputDomainType;
99  using OutputImagePointer = typename Superclass::OutputDomainPointer;
100  using OutputPixelType = typename Superclass::OutputPixelType;
101  using OutputSpacingType = typename OutputImageType::SpacingType;
106 
107  using NodeType = typename Traits::NodeType;
108  using NodePairType = typename Traits::NodePairType;
109  using NodePairContainerType = typename Traits::NodePairContainerType;
110  using NodePairContainerPointer = typename Traits::NodePairContainerPointer;
111  using NodePairContainerConstIterator = typename Traits::NodePairContainerConstIterator;
112 
113  using LabelType = typename Superclass::LabelType;
114 
115  static constexpr unsigned int ImageDimension = 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  ~FastMarchingImageFilterBase() override = default;
164 
165  void PrintSelf(std::ostream & os, Indent indent) const override;
166 
170 
175  bool m_OverrideOutputInformation{ false };
176 
178  void GenerateOutputInformation() override;
179 
180  void EnlargeOutputRequestedRegion(DataObject *output) override;
181 
184 
185  IdentifierType GetTotalNumberOfNodes() const override;
186 
187  void SetOutputValue( OutputImageType* oDomain,
188  const NodeType& iNode,
189  const OutputPixelType& iValue ) override;
190 
192  const OutputPixelType GetOutputValue( OutputImageType* oImage,
193  const NodeType& iNode ) const override;
194 
196  unsigned char
197  GetLabelValueForGivenNode( const NodeType& iNode ) const override;
198 
200  void SetLabelValueForGivenNode( const NodeType& iNode,
201  const LabelType& iLabel ) override;
202 
204  void UpdateNeighbors( OutputImageType* oImage,
205  const NodeType& iNode ) override;
206 
208  void UpdateValue( OutputImageType* oImage,
209  const NodeType& iValue ) override;
210 
212  bool CheckTopology( OutputImageType* oImage,
213  const NodeType& iNode ) override;
214  void InitializeOutput( OutputImageType* oImage ) 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 
256 
257 private:
258 
259 };
260 } // end namespace itk
261 
262 #ifndef ITK_MANUAL_INSTANTIATION
263 #include "itkFastMarchingImageFilterBase.hxx"
264 #endif
265 
266 #endif // itkFastMarchingImageFilterBase_h
typename Superclass::OutputDomainType OutputImageType
typename Traits::LabelType LabelType
typename Traits::NodeType NodeType
typename OutputImageType::SizeType OutputSizeType
typename Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Apply the Fast Marching method to solve an Eikonal equation on an image.
typename NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
typename ConnectedComponentImageType::Pointer ConnectedComponentImagePointer
typename Traits::OutputPixelType OutputPixelType
typename LabelImageType::Pointer LabelImagePointer
typename OutputImageType::SpacingType OutputSpacingType
typename Traits::NodePairType NodePairType
typename Superclass::InputDomainType InputImageType
typename OutputImageType::PointType OutputPointType
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:51
ConnectedComponentImagePointer m_ConnectedComponentImage
typename OutputImageType::DirectionType OutputDirectionType
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
typename Superclass::OutputDomainPointer OutputImagePointer
typename FastMarchingTraits< TInput, TOutput >::SuperclassType Superclass
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
typename OutputImageType::RegionType OutputRegionType
typename Traits::NodePairContainerType NodePairContainerType
typename Superclass::InputDomainPointer InputImagePointer
typename Superclass::RadiusType RadiusType
typename Traits::InputPixelType InputPixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class traits to be used by the FastMarchingBase.
virtual void SetOutputSize(const OutputSizeType &size)
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
virtual OutputSizeType GetOutputSize() const
typename Traits::NodePairContainerPointer NodePairContainerPointer