ITK  4.2.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 <math.h>
26 
27 namespace itk
28 {
37 template< class 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,
55 
58 
61 
64 
69 
72 
76 
80 
83 
87 };
88 
156 template< class TInputImage, class 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;
177  typedef typename Superclass::ValueType ValueType;
178  typedef typename Superclass::IndexType IndexType;
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)vcl_ceil( m_CurvatureBandWidth
239  + itkGetStaticConstMacro(ImageDimension) );
240  }
241 
244  virtual void SetNumberOfLayers(const unsigned int n)
245  {
246  unsigned int nm = vnl_math_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()
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 
284  itkConceptMacro( OutputHasNumericTraitsCheck,
286 
288 #endif
289 protected:
292  virtual void PrintSelf(std::ostream & os, Indent indent) const;
294 
297  ValueType ComputeCurvatureFromSparseImageNeighborhood
298  (SparseImageIteratorType & neighborhood) const;
299 
303  void ComputeCurvatureTarget(const OutputImageType *distanceImage,
304  SparseImageType *sparseImage) const;
305 
307  void ProcessNormals();
308 
313  bool ActiveLayerCheckBand() const;
314 
315 private:
318  unsigned int m_RefitIteration;
319 
323  unsigned int m_MaxRefitIteration;
324 
327  unsigned int m_MaxNormalIteration;
328 
333 
337 
341 
347 
351 
355 
359 
363 
366  static const ValueType m_DimConst;
367 
369  //purposely not implemented
370  void operator=(const Self &); //purposely not implemented
371 };
372 } // end namespace itk
373 
374 #ifndef ITK_MANUAL_INSTANTIATION
375 #include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
376 #endif
377 
378 #endif
379