ITK  4.8.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 >
39 {
40 public:
41 
43  typedef TImageType LevelSetImageType;
44 
46  typedef typename LevelSetImageType::PixelType NodeValueType;
47 
49  typedef typename LevelSetImageType::IndexType IndexType;
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 
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 
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 = vnl_math_max (this->GetMinimumNumberOfLayers (), n);
247 
248  if ( nm != this->GetNumberOfLayers() )
249  {
251  this->Modified();
252  }
253  }
254 
257  virtual void InitializeIteration() ITK_OVERRIDE
258  {
260  ValueType rmschange = this->GetRMSChange();
262 
263  if ( ( this->GetElapsedIterations() == 0 )
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 
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 
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 
368  //purposely not implemented
369  void operator=(const Self &); //purposely not implemented
370 };
371 } // end namespace itk
372 
373 #ifndef ITK_MANUAL_INSTANTIATION
374 #include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
375 #endif
376 
377 #endif
Vector< NodeValueType, TImageType::ImageDimension > NodeDataType
void SetLevelSetFunction(LevelSetFunctionType *lsf)
ImplicitManifoldNormalVectorFilter< OutputImageType, SparseImageType > NormalVectorFilterType
void ComputeCurvatureTarget(const OutputImageType *distanceImage, SparseImageType *sparseImage) const
SparseFieldLevelSetImageFilter< TInputImage, TOutputImage > Superclass
virtual void PrintSelf(std::ostream &os, Indent indent) const override
This class implements the filter for computing the normal vectors from a scalar implicit function (i...
SparseImage< NodeType, itkGetStaticConstMacro(ImageDimension) > SparseImageType
Base class for all process objects that output image data.
ValueType ComputeCurvatureFromSparseImageNeighborhood(SparseImageIteratorType &neighborhood) const
unsigned long SizeValueType
Definition: itkIntTypes.h:143
virtual void SetNumberOfLayers(unsigned int _arg)
This class implements a finite difference partial differential equation solver for evolving surfaces ...
NodeDataType m_Flux[TImageType::ImageDimension]
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...
virtual unsigned int GetNumberOfLayers() const
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
virtual void Modified() const
Superclass::NeighborhoodScalesType NeighborhoodScalesType
NodeDataType m_ManifoldNormal[TImageType::ImageDimension]
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
virtual const IdentifierType & GetElapsedIterations() const
#define itkConceptMacro(name, concept)
virtual const double & GetRMSChange() const
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.