ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkMultiphaseSparseFiniteDifferenceImageFilter.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 __itkMultiphaseSparseFiniteDifferenceImageFilter_h
19 #define __itkMultiphaseSparseFiniteDifferenceImageFilter_h
20 
27 
28 #include <vector>
29 
30 namespace itk
31 {
176 template< typename TInputImage, typename TFeatureImage, typename TOutputImage, typename TFunction,
177  typename TIdCell = unsigned int >
179  public MultiphaseFiniteDifferenceImageFilter< TInputImage,
180  TFeatureImage, TOutputImage, TFunction, TIdCell >
181 {
182 public:
183 
186  typedef MultiphaseFiniteDifferenceImageFilter< TInputImage,
187  TFeatureImage, TOutputImage, TFunction, TIdCell > Superclass;
190 
192  itkNewMacro(Self);
193 
196 
197  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
198 
201 
214 
221 
229 
230  typedef typename InputImageType::ValueType ValueType;
232 
237  typedef typename FiniteDifferenceFunctionType::FloatOffsetType
239 
242 
248 
250  typedef std::vector< LayerPointerType > LayerListType;
251  typedef typename LayerListType::iterator LayerListIterator;
252  typedef typename LayerListType::const_iterator LayerListConstIterator;
253 
255  typedef signed char StatusType;
256 
262 
265  typedef typename ZeroCrossingFilterType::Pointer
267 
269 
274 
276  typedef std::vector< ValueType > UpdateBufferType;
277  typedef typename UpdateBufferType::const_iterator UpdateBufferConstIterator;
278 
281 
285  itkSetMacro(NumberOfLayers, unsigned int);
286  itkGetConstMacro(NumberOfLayers, unsigned int);
288 
290  itkSetMacro(IsoSurfaceValue, ValueType);
291  itkGetConstMacro(IsoSurfaceValue, ValueType);
293 
298  itkSetMacro(InterpolateSurfaceLocation, bool);
299  itkGetConstMacro(InterpolateSurfaceLocation, bool);
301 
304  { this->SetInterpolateSurfaceLocation(true); }
306  { this->SetInterpolateSurfaceLocation(false); }
308 
309  void SetFunctionCount(const IdCellType & n)
310  {
312 
313  m_SparseData.resize(this->m_FunctionCount, ITK_NULLPTR);
314 
315  for ( IdCellType i = 0; i < this->m_FunctionCount; i++ )
316  {
317  m_SparseData[i] = new SparseDataStruct(i);
318  }
319  }
320 
321 #ifdef ITK_USE_CONCEPT_CHECKING
322  // Begin concept checking
323  itkConceptMacro( OutputEqualityComparableCheck,
325  itkConceptMacro( DoubleConvertibleToOutputCheck,
327  itkConceptMacro( OutputOStreamWritableCheck,
329  // End concept checking
330 #endif
331 
332 protected:
335  {
336  while ( !m_SparseData.empty() )
337  {
338  delete m_SparseData.back();
339  m_SparseData.pop_back();
340  }
341  }
342 
343  virtual void PrintSelf(std::ostream & os, Indent indent) const;
344 
345  // This data structure is created for each phase
348  {
350  m_LayerNodeStore->SetGrowthStrategyToExponential();
351  m_Index = index;
352  }
353 
359 
362 
365 
369 
371  };
372 
375 
377  std::vector< ValueType > m_PixelDistance;
378 
384  const OutputIndexType & itkNotUsed(idx),
385  const TimeStepType & dt,
386  const ValueType & value,
387  const ValueType & change)
388  {
389  return ( value + dt * change );
390  }
391 
395  virtual void PostProcessOutput();
396 
401  virtual void InitializeBackgroundPixels();
402 
404  void Initialize();
405 
410  void CopyInputToOutput();
411 
414 
417  void ApplyUpdate(TimeStepType dt);
418 
422 
426  void ConstructLayer(SparseDataStruct *sparsePtr, StatusType from, StatusType
427  to);
428 
433  void ConstructActiveLayer();
434 
437 
441 
449  void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from,
450  StatusType to, StatusType promote, int InOrOut);
451 
457 
458  void PropagateFunctionLayerValues(unsigned int functionIndex);
459 
463  void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
464  LayerType *StatusDownList);
465 
467  void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
468  StatusType ChangeToStatus, StatusType SearchForStatus);
469 
471  void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
472 
473  void InitializeIteration();
474 
475  virtual void UpdatePixel( unsigned int itkNotUsed(functionIndex), unsigned int itkNotUsed(idx),
476  NeighborhoodIterator< InputImageType > & itkNotUsed(iterator), ValueType & itkNotUsed(
477  newValue),
478  bool & itkNotUsed(status) ){}
479 
480  itkGetConstMacro(ValueZero, ValueType);
481  itkGetConstMacro(ValueOne, ValueType);
482 
485  static double m_ConstantGradientValue;
486 
488  static const ValueType m_ValueOne;
489 
491  static const ValueType m_ValueZero;
492 
496 
500 
504 
508 
511  static const StatusType m_StatusNull;
512 
513  std::vector< SparseDataStruct * > m_SparseData;
514 
518  unsigned int m_NumberOfLayers;
519 
522 
525 
531 
532 private:
534  void operator=(const Self &); //purposely not implemented
535 
537 
538  double m_RMSSum;
539  unsigned int m_RMSCounter;
540 
544 };
545 } // end namespace itk
546 
547 #ifndef ITK_MANUAL_INSTANTIATION
548 #include "itkMultiphaseSparseFiniteDifferenceImageFilter.hxx"
549 #endif
550 
551 #endif
Image< StatusType, itkGetStaticConstMacro(ImageDimension) > StatusImageType
A convenience class for storing indices which reference neighbor pixels within a neighborhood.
void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from, StatusType to, StatusType promote, int InOrOut)
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< StatusImageType > BFCType
Base class for all process objects that output image data.
The non-const version of the ConstSparseFieldLayerIterator.
virtual void UpdatePixel(unsigned int, unsigned int, NeighborhoodIterator< InputImageType > &, ValueType &, bool &)
void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus)
virtual void SetInterpolateSurfaceLocation(bool _arg)
void ConstructLayer(SparseDataStruct *sparsePtr, StatusType from, StatusType to)
FiniteDifferenceFunctionType::FloatOffsetType FiniteDifferenceFunctionFloatOffsetType
Splits an image into a main region and several &quot;face&quot; regions which are used to handle computations o...
virtual void PrintSelf(std::ostream &os, Indent indent) const
void PropagateFunctionLayerValues(unsigned int functionIndex)
void ProcessStatusList(LayerType *InputList, LayerType *OutputList, StatusType ChangeToStatus, StatusType SearchForStatus)
virtual ValueType CalculateUpdateValue(const OutputIndexType &, const TimeStepType &dt, const ValueType &value, const ValueType &change)
ZeroCrossingImageFilter< InputImageType, InputImageType > ZeroCrossingFilterType
This class implements a finite difference partial differential equation solver for evolving surfaces ...
This filter finds the closest pixel to the zero-crossings (sign changes) in a signed itk::Image...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
MultiphaseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > Superclass
void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList, LayerType *StatusDownList)
SparseFieldCityBlockNeighborList< NeighborhoodIterator< OutputImageType > > NeighborListType
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver...
#define itkConceptMacro(name, concept)
A specialized memory management object for allocating and destroying contiguous blocks of objects...
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Templated n-dimensional image class.
Definition: itkImage.h:75
static Pointer New()