ITK  5.2.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  * 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 #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);
160 
166 
169 
171  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
172 
174  using OutputImageType = typename Superclass::OutputImageType;
177  using LayerType = typename Superclass::LayerType;
178  using RadiusType = typename Superclass::RadiusType;
179  using NeighborhoodScalesType = 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  itkSetMacro(NormalProcessUnsharpWeight, ValueType);
221  itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
222 
225  void
226  SetLevelSetFunction(LevelSetFunctionType * lsf);
227 
231  unsigned int
233  {
234  return (int)std::ceil(m_CurvatureBandWidth + Self::ImageDimension);
235  }
236 
239  void
240  SetNumberOfLayers(const unsigned int n) override
241  {
242  unsigned int nm = std::max(this->GetMinimumNumberOfLayers(), n);
243 
244  if (nm != this->GetNumberOfLayers())
245  {
246  Superclass::SetNumberOfLayers(nm);
247  this->Modified();
248  }
249  }
250 
253  void
255  {
256  Superclass::InitializeIteration();
257  ValueType rmschange = this->GetRMSChange();
259 
260  if ((this->GetElapsedIterations() == 0) || (m_RefitIteration == m_MaxRefitIteration) ||
261  (rmschange <= m_RMSChangeNormalProcessTrigger) || (this->ActiveLayerCheckBand()))
262  {
263  if ((this->GetElapsedIterations() != 0) && (rmschange <= m_RMSChangeNormalProcessTrigger) &&
264  (m_RefitIteration <= 1))
265  {
266  m_ConvergenceFlag = true;
267  }
268 
269  m_RefitIteration = 0;
270  ProcessNormals();
271  }
272 
273  m_RefitIteration++;
274  }
275 
276 #ifdef ITK_USE_CONCEPT_CHECKING
277  // Begin concept checking
278  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<ValueType>));
279  // End concept checking
280 #endif
281 
282 protected:
284  ~SparseFieldFourthOrderLevelSetImageFilter() override = default;
285  void
286  PrintSelf(std::ostream & os, Indent indent) const override;
287 
290  ValueType
291  ComputeCurvatureFromSparseImageNeighborhood(SparseImageIteratorType & it) const;
292 
296  void
297  ComputeCurvatureTarget(const OutputImageType * distanceImage, SparseImageType * sparseImage) const;
298 
300  void
301  ProcessNormals();
302 
307  bool
308  ActiveLayerCheckBand() const;
309 
310 private:
313  unsigned int m_RefitIteration;
314 
318  unsigned int m_MaxRefitIteration;
319 
322  unsigned int m_MaxNormalIteration;
323 
328 
332 
336 
342 
346 
350 
354 
358 
361  static const ValueType m_DimConst;
362 };
363 } // end namespace itk
364 
365 #ifndef ITK_MANUAL_INSTANTIATION
366 # include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
367 #endif
368 
369 #endif
itk::NormalBandNode::m_CurvatureFlag
bool m_CurvatureFlag
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:76
itk::SparseFieldFourthOrderLevelSetImageFilter::m_DimConst
static const ValueType m_DimConst
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:361
itk::SparseFieldFourthOrderLevelSetImageFilter::m_NormalProcessUnsharpFlag
bool m_NormalProcessUnsharpFlag
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:353
itk::SparseFieldFourthOrderLevelSetImageFilter::InitializeIteration
void InitializeIteration() override
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:254
itkImplicitManifoldNormalVectorFilter.h
itk::SparseFieldFourthOrderLevelSetImageFilter::m_ConvergenceFlag
bool m_ConvergenceFlag
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:331
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:714
itk::SparseFieldFourthOrderLevelSetImageFilter::LayerType
typename Superclass::LayerType LayerType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:177
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:240
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SparseFieldFourthOrderLevelSetImageFilter::m_MaxRefitIteration
unsigned int m_MaxRefitIteration
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:318
itk::SparseFieldFourthOrderLevelSetImageFilter::ValueType
typename Superclass::ValueType ValueType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:175
itk::NormalBandNode::m_Data
NodeDataType m_Data
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::SparseFieldFourthOrderLevelSetImageFilter::m_LevelSetFunction
LevelSetFunctionType * m_LevelSetFunction
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:335
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::SparseFieldFourthOrderLevelSetImageFilter::m_RefitIteration
unsigned int m_RefitIteration
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:313
itk::SparseFieldFourthOrderLevelSetImageFilter::m_MaxNormalIteration
unsigned int m_MaxNormalIteration
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:322
itk::FiniteDifferenceImageFilter::NeighborhoodScalesType
typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType
Definition: itkFiniteDifferenceImageFilter.h:169
itk::FiniteDifferenceImageFilter::RadiusType
typename FiniteDifferenceFunctionType::RadiusType RadiusType
Definition: itkFiniteDifferenceImageFilter.h:168
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:360
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::SparseFieldFourthOrderLevelSetImageFilter::m_CurvatureBandWidth
ValueType m_CurvatureBandWidth
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:341
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: itkAnnulusOperator.h:24
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:138
itk::NormalBandNode::Next
NormalBandNode * Next
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:82
itk::SparseFieldFourthOrderLevelSetImageFilter::m_NormalProcessUnsharpWeight
ValueType m_NormalProcessUnsharpWeight
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:357
itk::SparseFieldFourthOrderLevelSetImageFilter::m_NormalProcessConductance
ValueType m_NormalProcessConductance
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:349
itk::SparseFieldFourthOrderLevelSetImageFilter::m_RMSChangeNormalProcessTrigger
ValueType m_RMSChangeNormalProcessTrigger
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:327
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:232
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:83
itk::SparseFieldFourthOrderLevelSetImageFilter::IndexType
typename Superclass::IndexType IndexType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:176
itk::SparseFieldFourthOrderLevelSetImageFilter::m_NormalProcessType
int m_NormalProcessType
Definition: itkSparseFieldFourthOrderLevelSetImageFilter.h:345
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90