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
28namespace itk
29{
74template <typename TInput, typename TOutput>
75class ITK_TEMPLATE_EXPORT FastMarchingImageFilterBase : public FastMarchingBase<TInput, TOutput>
76{
77public:
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);
163protected:
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
184
185 void
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
225 void
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
239 bool
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
256 bool
257 IsCriticalC1Configuration3D(const std::bitset<8> &) const;
258 unsigned int
259 IsCriticalC2Configuration3D(const std::bitset<8> &) const;
260 bool
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
269 bool
271
272 const InputImageType * m_InputCache{};
273
274private:
275};
276} // end namespace itk
277
278#ifndef ITK_MANUAL_INSTANTIATION
279# include "itkFastMarchingImageFilterBase.hxx"
280#endif
281
282#endif // itkFastMarchingImageFilterBase_h
Base class for all data objects in ITK.
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
typename FastMarchingTraits< TInput, TOutput >::SuperclassType Superclass
typename Traits::NodePairContainerType NodePairContainerType
typename Traits::NodePairContainerPointer NodePairContainerPointer
typename Traits::NodeType NodeType
typename Traits::NodePairType NodePairType
typename Traits::OutputPixelType OutputPixelType
typename Traits::LabelType LabelType
typename Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Apply the Fast Marching method to solve an Eikonal equation on an image.
void InitializeOutput(OutputImageType *oImage) override
typename OutputImageType::RegionType OutputRegionType
typename Superclass::OutputDomainPointer OutputImagePointer
bool IsCriticalC1Configuration2D(const std::bitset< 9 > &) const
typename Superclass::InputDomainPointer InputImagePointer
typename NeighborhoodIteratorType::RadiusType NeighborhoodRadiusType
~FastMarchingImageFilterBase() override=default
bool IsCriticalC1Configuration3D(const std::bitset< 8 > &) const
IdentifierType GetTotalNumberOfNodes() const override
Get the total number of nodes in the domain.
bool IsChangeWellComposed3D(const NodeType &) const
double Solve(OutputImageType *oImage, const NodeType &iNode, InternalNodeStructureArray &iNeighbors) const
void GetInternalNodesUsed(OutputImageType *oImage, const NodeType &iNode, InternalNodeStructureArray &ioNodesUsed)
unsigned char GetLabelValueForGivenNode(const NodeType &iNode) const override
typename ConnectedComponentImageType::Pointer ConnectedComponentImagePointer
unsigned int IsCriticalC2Configuration3D(const std::bitset< 8 > &) const
void SetLabelValueForGivenNode(const NodeType &iNode, const LabelType &iLabel) override
void SetOutputValue(OutputImageType *oImage, const NodeType &iNode, const OutputPixelType &iValue) override
typename Superclass::InputDomainType InputImageType
typename OutputImageType::PointType OutputPointType
bool IsChangeWellComposed2D(const NodeType &) const
const OutputPixelType GetOutputValue(OutputImageType *oImage, const NodeType &iNode) const override
virtual void SetOutputSize(const OutputSizeType &size)
void PrintSelf(std::ostream &os, Indent indent) const override
void EnlargeOutputRequestedRegion(DataObject *output) override
void UpdateNeighbors(OutputImageType *oImage, const NodeType &iNode) override
typename OutputImageType::DirectionType OutputDirectionType
bool IsCriticalC2Configuration2D(const std::bitset< 9 > &) const
virtual OutputSizeType GetOutputSize() const
typename LabelImageType::Pointer LabelImagePointer
bool IsCriticalC3Configuration2D(const std::bitset< 9 > &) const
bool CheckTopology(OutputImageType *oImage, const NodeType &iNode) override
bool DoesVoxelChangeViolateWellComposedness(const NodeType &) const
void GenerateOutputInformation() override
typename OutputImageType::SizeType OutputSizeType
typename OutputImageType::SpacingType OutputSpacingType
typename Superclass::OutputDomainType OutputImageType
bool IsCriticalC4Configuration2D(const std::bitset< 9 > &) const
void UpdateValue(OutputImageType *oImage, const NodeType &iNode) override
bool DoesVoxelChangeViolateStrictTopology(const NodeType &) const
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:54
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition: itkIntTypes.h:90