ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSparseFieldFourthOrderLevelSetImageFilter.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 #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  TImageType ::ImageDimension >;
54 
57 
60 
63 
67  m_ManifoldNormal[TImageType::ImageDimension];
68 
70  NodeDataType m_Flux[TImageType::ImageDimension];
71 
75 
79 
82 
86 };
87 
155 template< typename TInputImage, typename TOutputImage >
157  public SparseFieldLevelSetImageFilter< TInputImage, TOutputImage >
158 {
159 public:
160  ITK_DISALLOW_COPY_AND_ASSIGN(SparseFieldFourthOrderLevelSetImageFilter);
162 
168 
172 
174  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
175 
177  using OutputImageType = typename Superclass::OutputImageType;
180  using LayerType = typename Superclass::LayerType;
181  using RadiusType = typename Superclass::RadiusType;
182  using NeighborhoodScalesType = typename Superclass::NeighborhoodScalesType;
183 
187 
190  Self::ImageDimension >;
191 
194 
197 
199  using NormalVectorFilterType =
201 
204 
206  //using RadiusType = typename NormalVectorFunctionType::RadiusType;
207 
211 
212  itkGetConstReferenceMacro(MaxRefitIteration, unsigned int);
213  itkSetMacro(MaxRefitIteration, unsigned int);
214  itkGetConstReferenceMacro(MaxNormalIteration, unsigned int);
215  itkSetMacro(MaxNormalIteration, unsigned int);
216  itkGetConstReferenceMacro(CurvatureBandWidth, ValueType);
217  itkSetMacro(CurvatureBandWidth, ValueType);
218  itkGetConstReferenceMacro(RMSChangeNormalProcessTrigger, ValueType);
219  itkSetMacro(RMSChangeNormalProcessTrigger, ValueType);
220  itkGetConstReferenceMacro(NormalProcessType, int);
221  itkSetMacro(NormalProcessType, int);
222  itkGetConstReferenceMacro(NormalProcessConductance, ValueType);
223  itkSetMacro(NormalProcessConductance, ValueType);
224  itkSetMacro(NormalProcessUnsharpFlag, bool);
225  itkGetConstReferenceMacro(NormalProcessUnsharpFlag, bool);
226  itkSetMacro(NormalProcessUnsharpWeight, ValueType);
227  itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
228 
231  void SetLevelSetFunction(LevelSetFunctionType *lsf);
232 
236  unsigned int GetMinimumNumberOfLayers() const
237  {
238  return (int)std::ceil( m_CurvatureBandWidth
239  + Self::ImageDimension );
240  }
241 
244  void SetNumberOfLayers(const unsigned int n) override
245  {
246  unsigned int nm = std::max (this->GetMinimumNumberOfLayers (), n);
247 
248  if ( nm != this->GetNumberOfLayers() )
249  {
250  Superclass::SetNumberOfLayers (nm);
251  this->Modified();
252  }
253  }
254 
257  void InitializeIteration() override
258  {
259  Superclass::InitializeIteration();
260  ValueType rmschange = this->GetRMSChange();
262 
263  if ( ( this->GetElapsedIterations() == 0 )
264  || ( m_RefitIteration == m_MaxRefitIteration )
265  || ( rmschange <= m_RMSChangeNormalProcessTrigger )
266  || ( this->ActiveLayerCheckBand() ) )
267  {
268  if ( ( this->GetElapsedIterations() != 0 )
269  && ( rmschange <= m_RMSChangeNormalProcessTrigger )
270  && ( m_RefitIteration <= 1 ) )
271  {
272  m_ConvergenceFlag = true;
273  }
274 
275  m_RefitIteration = 0;
276  ProcessNormals();
277  }
278 
279  m_RefitIteration++;
280  }
281 
282 #ifdef ITK_USE_CONCEPT_CHECKING
283  // Begin concept checking
284  itkConceptMacro( OutputHasNumericTraitsCheck,
286  // End concept checking
287 #endif
288 
289 protected:
291  ~SparseFieldFourthOrderLevelSetImageFilter() override = default;
292  void PrintSelf(std::ostream & os, Indent indent) const override;
293 
296  ValueType ComputeCurvatureFromSparseImageNeighborhood
297  (SparseImageIteratorType & neighborhood) const;
298 
302  void ComputeCurvatureTarget(const OutputImageType *distanceImage,
303  SparseImageType *sparseImage) const;
304 
306  void ProcessNormals();
307 
312  bool ActiveLayerCheckBand() const;
313 
314 private:
317  unsigned int m_RefitIteration;
318 
322  unsigned int m_MaxRefitIteration;
323 
326  unsigned int m_MaxNormalIteration;
327 
332 
336 
340 
346 
350 
354 
358 
362 
365  static const ValueType m_DimConst;
366 
367 };
368 } // end namespace itk
369 
370 #ifndef ITK_MANUAL_INSTANTIATION
371 #include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
372 #endif
373 
374 #endif
typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
This class implements the filter for computing the normal vectors from a scalar implicit function (i...
typename OutputImageType::ValueType ValueType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
This class implements a finite difference partial differential equation solver for evolving surfaces ...
A storage type for sparse image data.
This is a data storage class that can is used as the node type for the SparseImage class...
This class implements the fourth order level set PDE framework.
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
TOutputImage OutputImageType
typename LevelSetImageType::PixelType NodeValueType
This class extends the LevelSetFunction class by adding a grow term based on a target curvature store...
typename LevelSetImageType::IndexType IndexType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename FiniteDifferenceFunctionType::RadiusType RadiusType
#define itkConceptMacro(name, concept)
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.