ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkSparseFieldLevelSetImageFilter.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 __itkSparseFieldLevelSetImageFilter_h
19 #define __itkSparseFieldLevelSetImageFilter_h
20 
22 #include "itkMultiThreader.h"
23 #include "itkSparseFieldLayer.h"
24 #include "itkObjectStore.h"
25 #include <vector>
27 
28 namespace itk
29 {
35 template< class TValueType >
37 {
38 public:
39  TValueType m_Value;
42 };
43 
72 template< class TNeighborhoodType >
74 {
75 public:
76  typedef TNeighborhoodType NeighborhoodType;
79  itkStaticConstMacro(Dimension, unsigned int,
80  NeighborhoodType::Dimension);
82 
83  const RadiusType & GetRadius() const
84  { return m_Radius; }
85 
86  const unsigned int & GetArrayIndex(unsigned int i) const
87  { return m_ArrayIndex[i]; }
88 
89  const OffsetType & GetNeighborhoodOffset(unsigned int i) const
90  { return m_NeighborhoodOffset[i]; }
91 
92  const unsigned int & GetSize() const
93  { return m_Size; }
94 
95  int GetStride(unsigned int i)
96  { return m_StrideTable[i]; }
97 
100 
101  void Print(std::ostream & os) const;
102 
103 private:
104  unsigned int m_Size;
106  std::vector< unsigned int > m_ArrayIndex;
107  std::vector< OffsetType > m_NeighborhoodOffset;
108 
112 };
113 
229 template< class TInputImage, class TOutputImage >
231  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
232 {
233 public:
234 
240 
242  typedef typename Superclass::TimeStepType TimeStepType;
243  typedef typename Superclass::RadiusType RadiusType;
244  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
245 
247  itkNewMacro(Self);
248 
251 
253  typedef TInputImage InputImageType;
254  typedef TOutputImage OutputImageType;
256  itkStaticConstMacro(ImageDimension, unsigned int,
257  TOutputImage::ImageDimension);
258 
262 
265 
269 
271  typedef std::vector< LayerPointerType > LayerListType;
272 
274  typedef signed char StatusType;
275 
280 
284 
286  typedef std::vector< ValueType > UpdateBufferType;
287 
291  itkSetMacro(NumberOfLayers, unsigned int);
292  itkGetConstMacro(NumberOfLayers, unsigned int);
294 
296  itkSetMacro(IsoSurfaceValue, ValueType);
297  itkGetConstMacro(IsoSurfaceValue, ValueType);
299 
303  // itkGetConstMacro(RMSChange, ValueType);
304 
310  itkSetMacro(InterpolateSurfaceLocation, bool);
311  itkGetConstMacro(InterpolateSurfaceLocation, bool);
313 
315  void InterpolateSurfaceLocationOn()
316  { this->SetInterpolateSurfaceLocation(true); }
317  void InterpolateSurfaceLocationOff()
318  { this->SetInterpolateSurfaceLocation(false); }
320 
321 #ifdef ITK_USE_CONCEPT_CHECKING
322 
323  itkConceptMacro( OutputEqualityComparableCheck,
325  itkConceptMacro( DoubleConvertibleToOutputCheck,
327  itkConceptMacro( OutputOStreamWritableCheck,
329 
331 #endif
332 
333 protected:
336  virtual void PrintSelf(std::ostream & os, Indent indent) const;
337 
342  inline virtual ValueType CalculateUpdateValue(
343  const IndexType & itkNotUsed(idx),
344  const TimeStepType & dt,
345  const ValueType & value,
346  const ValueType & change)
347  { return ( value + dt * change ); }
348 
352  virtual void PostProcessOutput();
353 
358  virtual void InitializeBackgroundPixels();
359 
361  void Initialize();
362 
367  void CopyInputToOutput();
368 
370  void AllocateUpdateBuffer();
371 
374  void ApplyUpdate(const TimeStepType& dt);
375 
378  TimeStepType CalculateChange();
379 
383  void ConstructLayer(StatusType from, StatusType to);
384 
389  void ConstructActiveLayer();
390 
392  void InitializeActiveLayerValues();
393 
401  void PropagateLayerValues(StatusType from, StatusType to,
402  StatusType promote, int InOrOut);
403 
408  void PropagateAllLayerValues();
409 
413  void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
414  LayerType *StatusDownList);
415 
417  void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
418  StatusType ChangeToStatus, StatusType SearchForStatus);
419 
421  void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
422 
423  itkGetConstMacro(ValueZero, ValueType);
424  itkGetConstMacro(ValueOne, ValueType);
425 
429 
433 
436 
439 
443 
447 
451 
455 
459 
464 
470 
475  unsigned int m_NumberOfLayers;
476 
479 
482 
485 
489 
493  // ValueType m_RMSChange;
494 
500 
503 
504 private:
505  SparseFieldLevelSetImageFilter(const Self &); //purposely not implemented
506  void operator=(const Self &); //purposely not implemented
507 
511 };
512 } // end namespace itk
513 
514 #ifndef ITK_MANUAL_INSTANTIATION
515 #include "itkSparseFieldLevelSetImageFilter.hxx"
516 #endif
517 
518 #endif
519