Orfeo Toolbox  4.0
itkFastMarchingImageFilter.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 __itkFastMarchingImageFilter_h
19 #define __itkFastMarchingImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
23 #include "itkLevelSet.h"
24 #include "vnl/vnl_math.h"
25 
26 #include <functional>
27 #include <queue>
28 
29 namespace itk
30 {
102 template<
103  typename TLevelSet,
104  typename TSpeedImage = Image< float, TLevelSet ::ImageDimension > >
106  public ImageToImageFilter< TSpeedImage, TLevelSet >
107 {
108 public:
114 
116  itkNewMacro(Self);
117 
120 
130  typedef typename LevelSetImageType::SizeType OutputSizeType;
131  typedef typename LevelSetImageType::RegionType OutputRegionType;
132  typedef typename LevelSetImageType::SpacingType OutputSpacingType;
133  typedef typename LevelSetImageType::DirectionType OutputDirectionType;
134  typedef typename LevelSetImageType::PointType OutputPointType;
135 
136  class AxisNodeType:public NodeType
137  {
138 public:
139  int GetAxis() const { return m_Axis; }
140  void SetAxis(int axis) { m_Axis = axis; }
141  const AxisNodeType & operator=(const NodeType & node)
142  { this->NodeType::operator=(node); return *this; }
143 
144 private:
145  int m_Axis;
146  };
147 
149  typedef TSpeedImage SpeedImageType;
150 
152  typedef typename SpeedImageType::Pointer SpeedImagePointer;
153  typedef typename SpeedImageType::ConstPointer SpeedImageConstPointer;
154 
156  itkStaticConstMacro(SetDimension, unsigned int,
158  itkStaticConstMacro(SpeedImageDimension, unsigned int,
159  SpeedImageType::ImageDimension);
160 
163 
170 
173 
176 
177  template< typename TPixel >
179  {
180  typedef Image< TPixel, SetDimension > InternalImageType;
182  InternalRegionIterator;
183  InternalRegionIterator b_it( iImage, iImage->GetLargestPossibleRegion() );
184  b_it.GoToBegin();
185 
186  TPixel zero_value = NumericTraits< TPixel >::Zero;
187  size_t NumberOfPoints = 0;
188 
189  NodeType node;
190  node.SetValue( 0. );
191 
192  while( !b_it.IsAtEnd() )
193  {
194  if( b_it.Get() == zero_value )
195  {
196  if( NumberOfPoints == 0 )
197  {
199  }
200  node.SetIndex( b_it.GetIndex() );
201  m_OutsidePoints->InsertElement( NumberOfPoints++, node );
202 
203  }
204  ++b_it;
205  }
206  this->Modified();
207  }
208 
211  {
212  m_OutsidePoints = points;
213  this->Modified();
214  }
215 
219  {
220  m_AlivePoints = points;
221  this->Modified();
222  }
223 
226  {
227  return m_AlivePoints;
228  }
229 
233  {
234  m_TrialPoints = points;
235  this->Modified();
236  }
237 
240  {
241  return m_TrialPoints;
242  }
243 
246  {
247  return m_LabelImage;
248  }
249 
253  void SetSpeedConstant(double value)
254  {
255  m_SpeedConstant = value;
256  m_InverseSpeed = -1.0 * vnl_math_sqr(1.0 / m_SpeedConstant);
257  this->Modified();
258  }
259 
261  itkGetConstReferenceMacro(SpeedConstant, double);
262 
267  itkSetMacro(NormalizationFactor, double);
268  itkGetConstMacro(NormalizationFactor, double);
269 
273  itkSetMacro(StoppingValue, double);
274 
276  itkGetConstReferenceMacro(StoppingValue, double);
277 
282  itkSetMacro(CollectPoints, bool);
283 
285  itkGetConstReferenceMacro(CollectPoints, bool);
286  itkBooleanMacro(CollectPoints);
287 
293  {
294  return m_ProcessedPoints;
295  }
296 
303  virtual void SetOutputSize(const OutputSizeType & size)
304  { m_OutputRegion = size; }
306  { return m_OutputRegion.GetSize(); }
307  itkSetMacro(OutputRegion, OutputRegionType);
308  itkGetConstReferenceMacro(OutputRegion, OutputRegionType);
309  itkSetMacro(OutputSpacing, OutputSpacingType);
310  itkGetConstReferenceMacro(OutputSpacing, OutputSpacingType);
311  itkSetMacro(OutputDirection, OutputDirectionType);
312  itkGetConstReferenceMacro(OutputDirection, OutputDirectionType);
313  itkSetMacro(OutputOrigin, OutputPointType);
314  itkGetConstReferenceMacro(OutputOrigin, OutputPointType);
315  itkSetMacro(OverrideOutputInformation, bool);
316  itkGetConstReferenceMacro(OverrideOutputInformation, bool);
317  itkBooleanMacro(OverrideOutputInformation);
318 
319 #ifdef ITK_USE_CONCEPT_CHECKING
320  // Begin concept checking
321  itkConceptMacro( SameDimensionCheck,
323  itkConceptMacro( SpeedConvertibleToDoubleCheck,
325  itkConceptMacro( DoubleConvertibleToLevelSetCheck,
327  itkConceptMacro( LevelSetOStreamWritableCheck,
329  // End concept checking
330 #endif
331 
332 protected:
335  void PrintSelf(std::ostream & os, Indent indent) const;
336 
337  virtual void Initialize(LevelSetImageType *);
338 
339  virtual void UpdateNeighbors(const IndexType & index,
340  const SpeedImageType *, LevelSetImageType *);
341 
342  virtual double UpdateValue(const IndexType & index,
343  const SpeedImageType *, LevelSetImageType *);
344 
345  const AxisNodeType & GetNodeUsedInCalculation(unsigned int idx) const
346  { return m_NodesUsed[idx]; }
347 
348  void GenerateData();
349 
351  virtual void GenerateOutputInformation();
352 
353  virtual void EnlargeOutputRequestedRegion(DataObject *output);
354 
359  itkGetConstReferenceMacro(LargeValue, PixelType);
360 
362  typedef typename LevelSetImageType::IndexType LevelSetIndexType;
365 
366  itkGetConstReferenceMacro(StartIndex, LevelSetIndexType);
367  itkGetConstReferenceMacro(LastIndex, LevelSetIndexType);
368 
369 private:
370  FastMarchingImageFilter(const Self &); //purposely not implemented
371  void operator=(const Self &); //purposely not implemented
372 
376 
378 
382 
385 
391 
392  typename LevelSetImageType::PixelType m_LargeValue;
394 
398  typedef std::vector< AxisNodeType > HeapContainer;
399  typedef std::greater< AxisNodeType > NodeComparer;
400  typedef std::priority_queue< AxisNodeType, HeapContainer, NodeComparer >
402 
404 
406 };
407 } // namespace itk
408 
409 #ifndef ITK_MANUAL_INSTANTIATION
411 #endif
412 
413 #endif

Generated at Sat Mar 8 2014 14:36:09 for Orfeo Toolbox with doxygen 1.8.3.1