ITK  4.13.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 
200  typedef typename Superclass::TimeStepType TimeStepType;
201 
203  typedef typename Superclass::InputImageType InputImageType;
204  typedef typename Superclass::InputImagePointer InputImagePointer;
205  typedef typename Superclass::InputRegionType InputRegionType;
206  typedef typename Superclass::InputSizeType InputSizeType;
207  typedef typename Superclass::InputSizeValueType InputSizeValueType;
208  typedef typename Superclass::InputIndexType InputIndexType;
209  typedef typename Superclass::InputIndexValueType InputIndexValueType;
210  typedef typename Superclass::InputPixelType InputPixelType;
211  typedef typename Superclass::InputPointType InputPointType;
212  typedef typename Superclass::InputSpacingType InputSpacingType;
213  typedef typename Superclass::InputOffsetValueType InputOffsetValueType;
214 
215  typedef typename Superclass::FeatureImageType FeatureImageType;
216  typedef typename Superclass::FeatureSizeType FeatureSizeType;
217  typedef typename Superclass::FeatureImagePointer FeatureImagePointer;
218  typedef typename Superclass::FeatureRegionType FeatureRegionType;
219  typedef typename Superclass::FeatureSpacingType FeatureSpacingType;
220  typedef typename Superclass::FeaturePointType FeaturePointType;
221 
222  typedef typename Superclass::OutputImageType OutputImageType;
223  typedef typename Superclass::OutputImagePointer OutputImagePointer;
224  typedef typename Superclass::OutputRegionType OutputRegionType;
225  typedef typename Superclass::OutputSizeType OutputSizeType;
226  typedef typename Superclass::OutputIndexType OutputIndexType;
227  typedef typename Superclass::OutputIndexValueType OutputIndexValueType;
228  typedef typename Superclass::OutputPixelType OutputPixelType;
229 
230  typedef typename InputImageType::ValueType ValueType;
231  typedef typename Superclass::IdCellType IdCellType;
232 
233  typedef typename Superclass::FiniteDifferenceFunctionType
235  typedef typename Superclass::FiniteDifferenceFunctionPointer
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  {
311  this->Superclass::SetFunctionCount(n);
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 ITK_OVERRIDE;
344 
345  // This data structure is created for each phase
348  {
349  m_LayerNodeStore = LayerNodeStorageType::New();
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() ITK_OVERRIDE;
396 
401  virtual void InitializeBackgroundPixels();
402 
404  void Initialize() ITK_OVERRIDE;
405 
410  void CopyInputToOutput() ITK_OVERRIDE;
411 
413  void AllocateUpdateBuffer() ITK_OVERRIDE {}
414 
417  void ApplyUpdate(TimeStepType dt) ITK_OVERRIDE;
418 
421  TimeStepType CalculateChange() ITK_OVERRIDE;
422 
426  void ConstructLayer(SparseDataStruct *sparsePtr, StatusType from, StatusType
427  to);
428 
433  void ConstructActiveLayer();
434 
436  void InitializeActiveLayerValues();
437 
440  void InitializeBackgroundConstants();
441 
449  void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from,
450  StatusType to, StatusType promote, int InOrOut);
451 
456  void PropagateAllLayerValues();
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() ITK_OVERRIDE;
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:
533  ITK_DISALLOW_COPY_AND_ASSIGN(MultiphaseSparseFiniteDifferenceImageFilter);
534 
535  unsigned int m_CurrentFunctionIndex;
536 
537  double m_RMSSum;
538  unsigned int m_RMSCounter;
539 
543 };
544 } // end namespace itk
545 
546 #ifndef ITK_MANUAL_INSTANTIATION
547 #include "itkMultiphaseSparseFiniteDifferenceImageFilter.hxx"
548 #endif
549 
550 #endif
Image< StatusType, itkGetStaticConstMacro(ImageDimension) > StatusImageType
A convenience class for storing indices which reference neighbor pixels within a neighborhood.
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< StatusImageType > BFCType
Base class for all process objects that output image data.
The non-const version of the ConstSparseFieldLayerIterator.
FiniteDifferenceFunctionType::FloatOffsetType FiniteDifferenceFunctionFloatOffsetType
Splits an image into a main region and several &quot;face&quot; regions which are used to handle computations o...
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
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