Seg3D  2.4
Seg3D is a free volume segmentation and processing tool developed by the NIH Center for Integrative Biomedical Computing at the University of Utah Scientific Computing and Imaging (SCI) Institute.
itkLiveWireImageFunction.h
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkLiveWireImageFunction.h,v $
5  Language: C++
6  Date: $Date: $
7  Version: $Revision: $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkLiveWireImageFunction_h
18 #define __itkLiveWireImageFunction_h
19 
20 #include "itkImageFunction.h"
21 
22 #include "itkGradientImageFilter.h"
23 #include "itkPolyLineParametricPath.h"
24 #include "itkPriorityQueueContainer.h"
25 
26 #include <vector>
27 #include <queue>
28 
29 namespace itk
30 {
31 
45 template <class TInputImage>
46 class ITK_EXPORT LiveWireImageFunction
47 : public ImageFunction<TInputImage, typename itk::PolyLineParametricPath< TInputImage::ImageDimension >::Pointer >
48 {
49 
50 public:
52  itkStaticConstMacro( ImageDimension, unsigned int,
53  TInputImage::ImageDimension );
54 
57 
58  typedef PolyLineParametricPath<
59  itkGetStaticConstMacro( ImageDimension )> OutputType;
60  typedef ImageFunction<TInputImage,
61  typename OutputType::Pointer> Superclass;
62  typedef SmartPointer<Self> Pointer;
63  typedef SmartPointer<const Self> ConstPointer;
64 
66  itkTypeMacro( LiveWireImageFunction, ImageFunction );
67 
69  itkNewMacro(Self);
70 
72  typedef TInputImage InputImageType;
73  typedef typename InputImageType::Pointer InputImagePointer;
74  typedef typename InputImageType::ConstPointer InputImageConstPointer;
75  typedef typename InputImageType::RegionType InputImageRegionType;
76  typedef typename InputImageType::PixelType InputImagePixelType;
77 
78  typedef typename Superclass::IndexType IndexType;
79  typedef typename Superclass::PointType PointType;
80  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
81 
82  typedef typename OutputType::VertexType VertexType;
83 
84  typedef float RealType;
85  typedef Image<RealType,
86  itkGetStaticConstMacro( ImageDimension )> RealImageType;
87  typedef GradientImageFilter<InputImageType, RealType,
88  RealType> GradientFilterType;
89  typedef typename GradientFilterType::OutputImageType GradientImageType;
90  typedef Image<typename InputImageType::OffsetType,
91  itkGetStaticConstMacro( ImageDimension )> OffsetImageType;
92  typedef Image<int,
93  itkGetStaticConstMacro( ImageDimension )> MaskImageType;
94  typedef typename MaskImageType::PixelType MaskPixelType;
95 
96 
100  typedef MinPriorityQueueElementWrapper
101  <IndexType, RealType> PriorityQueueElementType;
102  typedef PriorityQueueContainer<
103  PriorityQueueElementType,
104  PriorityQueueElementType,
105  RealType, long> PriorityQueueType;
106 
107 
112  virtual void SetInputImage( const InputImageType * ptr );
113 
115  virtual typename OutputType::Pointer Evaluate( const PointType &point ) const
116  {
117  IndexType index;
118  this->ConvertPointToNearestIndex( point, index );
119  return this->EvaluateAtIndex( index );
120  }
121 
124  virtual typename OutputType::Pointer
125  EvaluateAtContinuousIndex( const ContinuousIndexType &cindex ) const
126  {
127  IndexType index;
128  this->ConvertContinuousIndexToNearestIndex( cindex, index );
129  return this->EvaluateAtIndex( index );
130  }
131 
134  virtual typename OutputType::Pointer
135  EvaluateAtIndex( const IndexType &index ) const;
136 
137  itkSetClampMacro( GradientMagnitudeWeight, RealType,
138  0, NumericTraits<RealType>::max() );
139  itkGetConstMacro( GradientMagnitudeWeight, RealType );
140 
141  itkSetClampMacro( GradientDirectionWeight, RealType,
142  0, NumericTraits<RealType>::max() );
143  itkGetConstMacro( GradientDirectionWeight, RealType );
144 
145  itkSetClampMacro( ZeroCrossingWeight, RealType, 0,
146  NumericTraits<RealType>::max() );
147  itkGetConstMacro( ZeroCrossingWeight, RealType );
148 
149  itkSetMacro( ZeroCrossingImage, typename RealImageType::Pointer );
150  itkGetConstMacro( ZeroCrossingImage, typename RealImageType::Pointer );
151 
152  itkSetMacro( MaskImage, typename MaskImageType::Pointer );
153  itkGetConstMacro( MaskImage, typename MaskImageType::Pointer );
154 
155  itkSetMacro( InsidePixelValue, MaskPixelType );
156  itkGetConstMacro( InsidePixelValue, MaskPixelType );
157 
158  virtual void SetAnchorSeed( IndexType index )
159  {
160  itkDebugMacro( "setting AnchorSeed to " << index );
161  if ( this->m_AnchorSeed != index )
162  {
163  this->m_AnchorSeed = index;
164  if ( this->GetInputImage() != nullptr )
165  {
166  this->GeneratePathDirectionImage();
167  }
168  this->Modified();
169  }
170  }
171  itkGetConstMacro( AnchorSeed, IndexType );
172 
173  itkSetMacro( UseFaceConnectedness, bool );
174  itkGetConstMacro( UseFaceConnectedness, bool );
175  itkBooleanMacro( UseFaceConnectedness );
176 
177  itkSetMacro( UseImageSpacing, bool );
178  itkGetConstMacro( UseImageSpacing, bool );
179  itkBooleanMacro( UseImageSpacing );
180 
181 protected:
182 
183  LiveWireImageFunction();
184  virtual ~LiveWireImageFunction();
185  void PrintSelf(std::ostream& os, Indent indent) const;
186 
187 private:
188  LiveWireImageFunction(const Self&); //purposely not implemented
189  void operator=(const Self&); //purposely not implemented
190 
191  void GeneratePathDirectionImage();
192 
193  RealType m_GradientMagnitudeWeight;
194  RealType m_ZeroCrossingWeight;
195  RealType m_GradientDirectionWeight;
196 
197  typename GradientImageType::Pointer m_GradientImage;
198  typename RealImageType::Pointer m_GradientMagnitudeImage;
199  typename RealImageType::Pointer m_RescaledGradientMagnitudeImage;
200  typename RealImageType::Pointer m_ZeroCrossingImage;
201 
202  typename OffsetImageType::Pointer m_PathDirectionImage;
203 
204  typename MaskImageType::Pointer m_MaskImage;
205  MaskPixelType m_InsidePixelValue;
206 
207  IndexType m_AnchorSeed;
208 
209  bool m_UseFaceConnectedness;
210  bool m_UseImageSpacing;
211 };
212 
213 } // end namespace itk
214 
215 #ifndef ITK_MANUAL_INSTANTIATION
216 #include "itkLiveWireImageFunction.hxx"
217 #endif
218 
219 #endif
220 
MinPriorityQueueElementWrapper< IndexType, RealType > PriorityQueueElementType
Definition: itkLiveWireImageFunction.h:101
Implements livewire image segmentation of Barret and Mortensen.
Definition: itkLiveWireImageFunction.h:46
TInputImage InputImageType
Definition: itkLiveWireImageFunction.h:72
Definition: itkNormalizeImageFilterWithMask.h:48
LiveWireImageFunction Self
Definition: itkLiveWireImageFunction.h:56
virtual OutputType::Pointer Evaluate(const PointType &point) const
Definition: itkLiveWireImageFunction.h:115
virtual OutputType::Pointer EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const
Definition: itkLiveWireImageFunction.h:125