ITK  4.13.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  typedef TImageType LevelSetImageType;
44 
46  typedef typename LevelSetImageType::PixelType NodeValueType;
47 
50 
52  typedef Vector< NodeValueType,
53  TImageType ::ImageDimension >
55 
58 
61 
64 
68  m_ManifoldNormal[TImageType::ImageDimension];
69 
71  NodeDataType m_Flux[TImageType::ImageDimension];
72 
76 
80 
83 
87 };
88 
156 template< typename TInputImage, typename TOutputImage >
158  public SparseFieldLevelSetImageFilter< TInputImage, TOutputImage >
159 {
160 public:
161 
167 
171 
173  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
174 
176  typedef typename Superclass::OutputImageType OutputImageType;
179  typedef typename Superclass::LayerType LayerType;
180  typedef typename Superclass::RadiusType RadiusType;
181  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
182 
186 
188  typedef SparseImage< NodeType,
189  itkGetStaticConstMacro(ImageDimension) > SparseImageType;
190 
193 
196 
200 
204 
206  //typedef typename NormalVectorFunctionType::RadiusType 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  + itkGetStaticConstMacro(ImageDimension) );
240  }
241 
244  virtual void SetNumberOfLayers(const unsigned int n) ITK_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  virtual void InitializeIteration() ITK_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:
292  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_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  ITK_DISALLOW_COPY_AND_ASSIGN(SparseFieldFourthOrderLevelSetImageFilter);
368 };
369 } // end namespace itk
370 
371 #ifndef ITK_MANUAL_INSTANTIATION
372 #include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
373 #endif
374 
375 #endif
Vector< NodeValueType, TImageType::ImageDimension > NodeDataType
ImplicitManifoldNormalVectorFilter< OutputImageType, SparseImageType > NormalVectorFilterType
SparseFieldLevelSetImageFilter< TInputImage, TOutputImage > Superclass
This class implements the filter for computing the normal vectors from a scalar implicit function (i...
SparseImage< NodeType, itkGetStaticConstMacro(ImageDimension) > SparseImageType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
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.
NormalVectorDiffusionFunction< SparseImageType > NormalVectorFunctionType
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
LevelSetFunctionWithRefitTerm< OutputImageType, SparseImageType > LevelSetFunctionType
This class extends the LevelSetFunction class by adding a grow term based on a target curvature store...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TOutputImage OutputImageType
int ceil(const T x)
Definition: itkMath.h:800
#define itkConceptMacro(name, concept)
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.