ITK  6.0.0
Insight Toolkit
itkSparseFieldFourthOrderLevelSetImageFilter.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 #ifndef itkSparseFieldFourthOrderLevelSetImageFilter_h
19 #define itkSparseFieldFourthOrderLevelSetImageFilter_h
20 
25 #include <cmath>
26 
27 namespace itk
28 {
37 template <typename TImageType>
38 class ITK_TEMPLATE_EXPORT NormalBandNode
39 {
40 public:
41 
43  using LevelSetImageType = TImageType;
44 
46  using NodeValueType = typename LevelSetImageType::PixelType;
47 
50 
53 
56 
59 
62 
65  NodeDataType m_ManifoldNormal[TImageType::ImageDimension];
66 
68  NodeDataType m_Flux[TImageType::ImageDimension];
69 
73 
77 
80 
84 };
85 
153 template <typename TInputImage, typename TOutputImage>
155  : public SparseFieldLevelSetImageFilter<TInputImage, TOutputImage>
156 {
157 public:
158  ITK_DISALLOW_COPY_AND_MOVE(SparseFieldFourthOrderLevelSetImageFilter);
166 
168  itkOverrideGetNameOfClassMacro(SparseFieldFourthOrderLevelSetImageFilter);
169 
171  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
172 
174  using typename Superclass::OutputImageType;
175  using typename Superclass::ValueType;
176  using typename Superclass::IndexType;
177  using typename Superclass::LayerType;
178  using typename Superclass::RadiusType;
179  using typename Superclass::NeighborhoodScalesType;
180 
184 
187 
190 
193 
196 
199 
201  // using RadiusType = typename NormalVectorFunctionType::RadiusType;
202 
205 
206  itkGetConstReferenceMacro(MaxRefitIteration, unsigned int);
207  itkSetMacro(MaxRefitIteration, unsigned int);
208  itkGetConstReferenceMacro(MaxNormalIteration, unsigned int);
209  itkSetMacro(MaxNormalIteration, unsigned int);
210  itkGetConstReferenceMacro(CurvatureBandWidth, ValueType);
211  itkSetMacro(CurvatureBandWidth, ValueType);
212  itkGetConstReferenceMacro(RMSChangeNormalProcessTrigger, ValueType);
213  itkSetMacro(RMSChangeNormalProcessTrigger, ValueType);
214  itkGetConstReferenceMacro(NormalProcessType, int);
215  itkSetMacro(NormalProcessType, int);
216  itkGetConstReferenceMacro(NormalProcessConductance, ValueType);
217  itkSetMacro(NormalProcessConductance, ValueType);
218  itkSetMacro(NormalProcessUnsharpFlag, bool);
219  itkGetConstReferenceMacro(NormalProcessUnsharpFlag, bool);
220  itkBooleanMacro(NormalProcessUnsharpFlag);
221  itkSetMacro(NormalProcessUnsharpWeight, ValueType);
222  itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
223 
226  void
227  SetLevelSetFunction(LevelSetFunctionType * lsf);
228 
232  unsigned int
234  {
235  return static_cast<int>(std::ceil(m_CurvatureBandWidth + Self::ImageDimension));
236  }
237 
240  void
241  SetNumberOfLayers(const unsigned int n) override
242  {
243  const unsigned int nm = std::max(this->GetMinimumNumberOfLayers(), n);
244 
245  if (nm != this->GetNumberOfLayers())
246  {
247  Superclass::SetNumberOfLayers(nm);
248  this->Modified();
249  }
250  }
251 
254  void
256  {
257  Superclass::InitializeIteration();
258  const ValueType rmschange = this->GetRMSChange();
261  if ((this->GetElapsedIterations() == 0) || (m_RefitIteration == m_MaxRefitIteration) ||
262  (rmschange <= m_RMSChangeNormalProcessTrigger) || (this->ActiveLayerCheckBand()))
263  {
264  if ((this->GetElapsedIterations() != 0) && (rmschange <= m_RMSChangeNormalProcessTrigger) &&
265  (m_RefitIteration <= 1))
266  {
267  m_ConvergenceFlag = true;
268  }
269 
270  m_RefitIteration = 0;
271  ProcessNormals();
272  }
273 
274  ++m_RefitIteration;
275  }
276 
277 #ifdef ITK_USE_CONCEPT_CHECKING
278  // Begin concept checking
279  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<ValueType>));
280  // End concept checking
281 #endif
282 
283 protected:
285  ~SparseFieldFourthOrderLevelSetImageFilter() override = default;
286  void
287  PrintSelf(std::ostream & os, Indent indent) const override;
288 
291  ValueType
292  ComputeCurvatureFromSparseImageNeighborhood(SparseImageIteratorType & it) const;
293 
297  void
298  ComputeCurvatureTarget(const OutputImageType * distanceImage, SparseImageType * sparseImage) const;
299 
301  void
302  ProcessNormals();
303 
308  bool
309  ActiveLayerCheckBand() const;
310 
311 private:
314  unsigned int m_RefitIteration{};
315 
319  unsigned int m_MaxRefitIteration{};
320 
323  unsigned int m_MaxNormalIteration{};
324 
328  ValueType m_RMSChangeNormalProcessTrigger{};
329 
332  bool m_ConvergenceFlag{};
333 
336  LevelSetFunctionType * m_LevelSetFunction{};
337 
342  ValueType m_CurvatureBandWidth{};
343 
346  int m_NormalProcessType{};
347 
350  ValueType m_NormalProcessConductance{};
351 
354  bool m_NormalProcessUnsharpFlag{};
355 
358  ValueType m_NormalProcessUnsharpWeight{};
359 
362  static const ValueType m_DimConst;
363 };
364 } // end namespace itk
365 
366 #ifndef ITK_MANUAL_INSTANTIATION
367 # include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
368 #endif
369 
370 #endif
itk::NormalBandNode::m_CurvatureFlag
bool m_CurvatureFlag
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:76
itk::SparseFieldFourthOrderLevelSetImageFilter::m_DimConst
static const ValueType m_DimConst
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:362
itk::SparseFieldFourthOrderLevelSetImageFilter::InitializeIteration
void InitializeIteration() override
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:255
itkImplicitManifoldNormalVectorFilter.h
itk::SparseFieldLevelSetImageFilter
This class implements a finite difference partial differential equation solver for evolving surfaces ...
Definition: itkSparseFieldLevelSetImageFilter.h:244
itkLevelSetFunctionWithRefitTerm.h
itk::NormalBandNode
This is a data storage class that can is used as the node type for the SparseImage class.
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:38
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::NormalBandNode::IndexType
typename LevelSetImageType::IndexType IndexType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:49
itk::Vector< NodeValueType, TImageType::ImageDimension >
itk::NormalBandNode::Previous
NormalBandNode * Previous
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:83
itk::SparseFieldFourthOrderLevelSetImageFilter::SetNumberOfLayers
void SetNumberOfLayers(const unsigned int n) override
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:241
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NormalBandNode::m_Data
NodeDataType m_Data
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LevelSetFunctionWithRefitTerm
This class extends the LevelSetFunction class by adding a grow term based on a target curvature store...
Definition: itkLevelSetFunctionWithRefitTerm.h:52
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::NormalBandNode::m_InputData
NodeDataType m_InputData
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:58
itk::NormalBandNode::m_Index
IndexType m_Index
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:79
itk::NormalVectorDiffusionFunction
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
Definition: itkNormalVectorDiffusionFunction.h:60
itk::SparseFieldFourthOrderLevelSetImageFilter::m_NumVertex
static const SizeValueType m_NumVertex
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:361
itk::SparseFieldFourthOrderLevelSetImageFilter::NormalVectorType
typename NodeType::NodeDataType NormalVectorType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:189
itk::NormalBandNode::m_Curvature
NodeValueType m_Curvature
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:72
itk::NormalBandNode::m_Update
NodeDataType m_Update
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:61
itk::SparseImage
A storage type for sparse image data.
Definition: itkSparseImage.h:67
itk::NeighborhoodIterator
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Definition: itkNeighborhoodIterator.h:212
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::NormalBandNode::LevelSetImageType
TImageType LevelSetImageType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:43
itk::SparseFieldLevelSetImageFilter::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkSparseFieldLevelSetImageFilter.h:274
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::NormalBandNode::Next
NormalBandNode * Next
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:82
itk::SparseFieldFourthOrderLevelSetImageFilter
This class implements the fourth order level set PDE framework.
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:154
itk::SparseFieldFourthOrderLevelSetImageFilter::GetMinimumNumberOfLayers
unsigned int GetMinimumNumberOfLayers() const
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:233
itkSparseFieldLevelSetImageFilter.h
itkNormalVectorDiffusionFunction.h
itk::ImplicitManifoldNormalVectorFilter
This class implements the filter for computing the normal vectors from a scalar implicit function (i....
Definition: itkImplicitManifoldNormalVectorFilter.h:73
itk::NormalBandNode::NodeValueType
typename LevelSetImageType::PixelType NodeValueType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:46
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86