ITK  6.0.0
Insight Toolkit
itkFastMarchingImageFilterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 : public FastMarchingBase<TInput, TOutput>
76 {
77 public:
78  ITK_DISALLOW_COPY_AND_MOVE(FastMarchingImageFilterBase);
79 
84  using typename Superclass::Traits;
85 
87  itkNewMacro(Self);
88 
90  itkOverrideGetNameOfClassMacro(FastMarchingImageFilterBase);
91 
92 
93  using InputImageType = typename Superclass::InputDomainType;
94  using InputImagePointer = typename Superclass::InputDomainPointer;
95  using typename Superclass::InputPixelType;
96 
97  using OutputImageType = typename Superclass::OutputDomainType;
98  using OutputImagePointer = typename Superclass::OutputDomainPointer;
99  using typename Superclass::OutputPixelType;
100  using OutputSpacingType = typename OutputImageType::SpacingType;
105 
106  using NodeType = typename Traits::NodeType;
107  using NodePairType = typename Traits::NodePairType;
108  using NodePairContainerType = typename Traits::NodePairContainerType;
109  using NodePairContainerPointer = typename Traits::NodePairContainerPointer;
110  using NodePairContainerConstIterator = typename Traits::NodePairContainerConstIterator;
111 
112  using typename Superclass::LabelType;
113 
114  static constexpr unsigned int ImageDimension = Traits::ImageDimension;
115 
116 
119 
122 
125 
126  class InternalNodeStructure;
127 
128 
130 
131  itkGetModifiableObjectMacro(LabelImage, LabelImageType);
132 
140  virtual void
142  {
143  m_OutputRegion = size;
144  }
145  virtual OutputSizeType
147  {
148  return m_OutputRegion.GetSize();
149  }
150  itkSetMacro(OutputRegion, OutputRegionType);
151  itkGetConstReferenceMacro(OutputRegion, OutputRegionType);
152  itkSetMacro(OutputSpacing, OutputSpacingType);
153  itkGetConstReferenceMacro(OutputSpacing, OutputSpacingType);
154  itkSetMacro(OutputDirection, OutputDirectionType);
155  itkGetConstReferenceMacro(OutputDirection, OutputDirectionType);
156  itkSetMacro(OutputOrigin, OutputPointType);
157  itkGetConstReferenceMacro(OutputOrigin, OutputPointType);
158  itkSetMacro(OverrideOutputInformation, bool);
159  itkGetConstReferenceMacro(OverrideOutputInformation, bool);
160  itkBooleanMacro(OverrideOutputInformation);
163 protected:
165 
166  ~FastMarchingImageFilterBase() override = default;
167 
168  void
169  PrintSelf(std::ostream & os, Indent indent) const override;
170 
171  OutputRegionType m_BufferedRegion{};
172  NodeType m_StartIndex{};
173  NodeType m_LastIndex{};
174 
175  OutputRegionType m_OutputRegion{};
176  OutputPointType m_OutputOrigin{};
177  OutputSpacingType m_OutputSpacing{};
178  OutputDirectionType m_OutputDirection{};
179  bool m_OverrideOutputInformation{ false };
180 
182  void
183  GenerateOutputInformation() override;
184 
185  void
186  EnlargeOutputRequestedRegion(DataObject * output) override;
187 
188  LabelImagePointer m_LabelImage{};
189  ConnectedComponentImagePointer m_ConnectedComponentImage{};
190 
192  GetTotalNumberOfNodes() const override;
193 
194  void
195  SetOutputValue(OutputImageType * oImage, const NodeType & iNode, const OutputPixelType & iValue) override;
196 
198  const OutputPixelType
199  GetOutputValue(OutputImageType * oImage, const NodeType & iNode) const override;
200 
202  unsigned char
203  GetLabelValueForGivenNode(const NodeType & iNode) const override;
204 
206  void
207  SetLabelValueForGivenNode(const NodeType & iNode, const LabelType & iLabel) override;
208 
210  void
211  UpdateNeighbors(OutputImageType * oImage, const NodeType & iNode) override;
212 
214  void
215  UpdateValue(OutputImageType * oImage, const NodeType & iNode) override;
216 
218  bool
219  CheckTopology(OutputImageType * oImage, const NodeType & iNode) override;
220  void
221  InitializeOutput(OutputImageType * oImage) override;
225  void
226  GetInternalNodesUsed(OutputImageType * oImage, const NodeType & iNode, InternalNodeStructureArray & ioNodesUsed);
227 
229  double
230  Solve(OutputImageType * oImage, const NodeType & iNode, InternalNodeStructureArray & iNeighbors) const;
231 
232  //
233  // Functions and variables to check for topology changes (2D/3D only).
234  //
235 
236  // Functions/data for the 2-D case
237  void
238  InitializeIndices2D();
239  bool
240  IsChangeWellComposed2D(const NodeType &) const;
241  bool
242  IsCriticalC1Configuration2D(const std::bitset<9> &) const;
243  bool
244  IsCriticalC2Configuration2D(const std::bitset<9> &) const;
245  bool
246  IsCriticalC3Configuration2D(const std::bitset<9> &) const;
247  bool
248  IsCriticalC4Configuration2D(const std::bitset<9> &) const;
249 
250  Array<unsigned char> m_RotationIndices[4]{};
251  Array<unsigned char> m_ReflectionIndices[2]{};
252 
253  // Functions/data for the 3-D case
254  void
255  InitializeIndices3D();
256  bool
257  IsCriticalC1Configuration3D(const std::bitset<8> &) const;
258  unsigned int
259  IsCriticalC2Configuration3D(const std::bitset<8> &) const;
260  bool
261  IsChangeWellComposed3D(const NodeType &) const;
262 
263  Array<unsigned char> m_C1Indices[12]{};
264  Array<unsigned char> m_C2Indices[8]{};
265 
266  // Functions for both 2D/3D cases
267  bool
268  DoesVoxelChangeViolateWellComposedness(const NodeType &) const;
269  bool
270  DoesVoxelChangeViolateStrictTopology(const NodeType &) const;
271 
272  const InputImageType * m_InputCache{};
273 
274 private:
275 };
276 } // end namespace itk
277 
278 #ifndef ITK_MANUAL_INSTANTIATION
279 # include "itkFastMarchingImageFilterBase.hxx"
280 #endif
281 
282 #endif // itkFastMarchingImageFilterBase_h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::FastMarchingImageFilterBase::ConnectedComponentImagePointer
typename ConnectedComponentImageType::Pointer ConnectedComponentImagePointer
Definition: itkFastMarchingImageFilterBase.h:121
itkImageRegionConstIteratorWithIndex.h
itk::FastMarchingImageFilterBase::OutputSpacingType
typename OutputImageType::SpacingType OutputSpacingType
Definition: itkFastMarchingImageFilterBase.h:100
itk::FastMarchingImageFilterBase::NeighborhoodRadiusType
typename NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
Definition: itkFastMarchingImageFilterBase.h:124
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itkNeighborhoodIterator.h
itk::FastMarchingImageFilterBase::OutputSizeType
typename OutputImageType::SizeType OutputSizeType
Definition: itkFastMarchingImageFilterBase.h:101
itk::FastMarchingBase::NodePairContainerPointer
typename Traits::NodePairContainerPointer NodePairContainerPointer
Definition: itkFastMarchingBase.h:158
itk::FastMarchingImageFilterBase::InputImageType
typename Superclass::InputDomainType InputImageType
Definition: itkFastMarchingImageFilterBase.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::FastMarchingImageFilterBase::InputImagePointer
typename Superclass::InputDomainPointer InputImagePointer
Definition: itkFastMarchingImageFilterBase.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::FastMarchingBase::NodePairType
typename Traits::NodePairType NodePairType
Definition: itkFastMarchingBase.h:156
itk::SmartPointer< Self >
itk::FastMarchingImageFilterBase::SetOutputSize
virtual void SetOutputSize(const OutputSizeType &size)
Definition: itkFastMarchingImageFilterBase.h:141
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkFastMarchingBase.h
itk::FastMarchingImageFilterBase::LabelImagePointer
typename LabelImageType::Pointer LabelImagePointer
Definition: itkFastMarchingImageFilterBase.h:118
itk::FastMarchingImageFilterBase
Apply the Fast Marching method to solve an Eikonal equation on an image.
Definition: itkFastMarchingImageFilterBase.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::FastMarchingImageFilterBase::GetOutputSize
virtual OutputSizeType GetOutputSize() const
Definition: itkFastMarchingImageFilterBase.h:146
itk::FastMarchingBase::NodePairContainerType
typename Traits::NodePairContainerType NodePairContainerType
Definition: itkFastMarchingBase.h:157
itk::FastMarchingBase::Superclass
typename FastMarchingTraits< TInput, TOutput >::SuperclassType Superclass
Definition: itkFastMarchingBase.h:135
itk::FastMarchingImageFilterBase::OutputRegionType
typename OutputImageType::RegionType OutputRegionType
Definition: itkFastMarchingImageFilterBase.h:102
itk::FastMarchingImageFilterBase::OutputDirectionType
typename OutputImageType::DirectionType OutputDirectionType
Definition: itkFastMarchingImageFilterBase.h:104
itk::FastMarchingBase::NodePairContainerConstIterator
typename Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Definition: itkFastMarchingBase.h:159
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:53
itkArray.h
itk::FastMarchingBase::NodeType
typename Traits::NodeType NodeType
Definition: itkFastMarchingBase.h:153
itk::NeighborhoodIterator
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Definition: itkNeighborhoodIterator.h:212
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::FastMarchingImageFilterBase::OutputImagePointer
typename Superclass::OutputDomainPointer OutputImagePointer
Definition: itkFastMarchingImageFilterBase.h:98
itk::Array< unsigned char >
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::FastMarchingBase
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
Definition: itkFastMarchingBase.h:126
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::FastMarchingImageFilterBase::OutputPointType
typename OutputImageType::PointType OutputPointType
Definition: itkFastMarchingImageFilterBase.h:103
itk::FastMarchingImageFilterBase::OutputImageType
typename Superclass::OutputDomainType OutputImageType
Definition: itkFastMarchingImageFilterBase.h:97
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293