ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkSegmentationLevelSetImageFilter.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 __itkSegmentationLevelSetImageFilter_h
19 #define __itkSegmentationLevelSetImageFilter_h
20 
23 
24 namespace itk
25 {
142 template< class TInputImage,
143  class TFeatureImage,
144  class TOutputPixelType = float >
146  public SparseFieldLevelSetImageFilter< TInputImage, Image< TOutputPixelType,
147  TInputImage::ImageDimension > >
148 {
149 public:
150 
153 
154  //itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
155 
158 
163 
165  typedef typename Superclass::ValueType ValueType;
166  typedef typename Superclass::IndexType IndexType;
167  typedef typename Superclass::TimeStepType TimeStepType;
168  typedef typename Superclass::InputImageType InputImageType;
169 
171  typedef TFeatureImage FeatureImageType;
172 
176 
180 
183 
186  void SetMaximumIterations(unsigned int i)
187  {
188  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
189  this->SetNumberOfIterations(i);
190  }
192 
193  unsigned int GetMaximumIterations()
194  {
195  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
196  return this->GetNumberOfIterations();
197  }
198 
201  virtual void SetFeatureImage(const FeatureImageType *f)
202  {
203  this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >( f ) );
204  m_SegmentationFunction->SetFeatureImage(f);
205  }
207 
208  virtual FeatureImageType * GetFeatureImage()
209  { return ( static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) ) ); }
210 
213  virtual void SetInitialImage(InputImageType *f)
214  {
215  this->SetInput(f);
216  }
217 
219  void SetInput2(const FeatureImageType *input)
220  {
221  this->SetFeatureImage(input);
222  }
223 
227  void SetSpeedImage(SpeedImageType *s)
228  { m_SegmentationFunction->SetSpeedImage(s); }
229 
233  void SetAdvectionImage(VectorImageType *v)
234  { m_SegmentationFunction->SetAdvectionImage(v); }
235 
238  virtual const SpeedImageType * GetSpeedImage() const
239  { return m_SegmentationFunction->GetSpeedImage(); }
240 
243  virtual const VectorImageType * GetAdvectionImage() const
244  { return m_SegmentationFunction->GetAdvectionImage(); }
245 
249  void SetUseNegativeFeaturesOn()
250  {
251  itkWarningMacro(
252  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
253  this->ReverseExpansionDirectionOn();
254  }
256 
257  void SetUseNegativeFeaturesOff()
258  {
259  itkWarningMacro(
260  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
261  this->ReverseExpansionDirectionOff();
262  }
263 
266  void SetUseNegativeFeatures(bool u)
267  {
268  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
269  if ( u == true )
270  {
271  this->SetReverseExpansionDirection(false);
272  }
273  else
274  {
275  this->SetReverseExpansionDirection(true);
276  }
277  }
279 
280  bool GetUseNegativeFeatures() const
281  {
282  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
283  if ( m_ReverseExpansionDirection == false )
284  {
285  return true;
286  }
287  else
288  {
289  return false;
290  }
291  }
292 
301  itkSetMacro(ReverseExpansionDirection, bool);
302  itkGetConstMacro(ReverseExpansionDirection, bool);
303  itkBooleanMacro(ReverseExpansionDirection);
305 
311  itkSetMacro(AutoGenerateSpeedAdvection, bool);
312  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
313  itkBooleanMacro(AutoGenerateSpeedAdvection);
315 
320  void SetFeatureScaling(ValueType v)
321  {
322  if ( v != m_SegmentationFunction->GetPropagationWeight() )
323  {
324  this->SetPropagationScaling(v);
325  }
326  if ( v != m_SegmentationFunction->GetAdvectionWeight() )
327  {
328  this->SetAdvectionScaling(v);
329  }
330  }
332 
335  void SetPropagationScaling(ValueType v)
336  {
337  if ( v != m_SegmentationFunction->GetPropagationWeight() )
338  {
339  m_SegmentationFunction->SetPropagationWeight(v);
340  this->Modified();
341  }
342  }
344 
345  ValueType GetPropagationScaling() const
346  {
347  return m_SegmentationFunction->GetPropagationWeight();
348  }
349 
352  void SetAdvectionScaling(ValueType v)
353  {
354  if ( v != m_SegmentationFunction->GetAdvectionWeight() )
355  {
356  m_SegmentationFunction->SetAdvectionWeight(v);
357  this->Modified();
358  }
359  }
361 
362  ValueType GetAdvectionScaling() const
363  {
364  return m_SegmentationFunction->GetAdvectionWeight();
365  }
366 
371  void SetCurvatureScaling(ValueType v)
372  {
373  if ( v != m_SegmentationFunction->GetCurvatureWeight() )
374  {
375  m_SegmentationFunction->SetCurvatureWeight(v);
376  this->Modified();
377  }
378  }
380 
381  ValueType GetCurvatureScaling() const
382  {
383  return m_SegmentationFunction->GetCurvatureWeight();
384  }
385 
387  void SetUseMinimalCurvature(bool b)
388  {
389  if ( m_SegmentationFunction->GetUseMinimalCurvature() != b )
390  {
391  m_SegmentationFunction->SetUseMinimalCurvature(b);
392  this->Modified();
393  }
394  }
396 
397  bool GetUseMinimalCurvature() const
398  {
399  return m_SegmentationFunction->GetUseMinimalCurvature();
400  }
401 
402  void UseMinimalCurvatureOn()
403  {
404  this->SetUseMinimalCurvature(true);
405  }
406 
407  void UseMinimalCurvatureOff()
408  {
409  this->SetUseMinimalCurvature(false);
410  }
411 
417  virtual void SetSegmentationFunction(SegmentationFunctionType *s)
418  {
419  m_SegmentationFunction = s;
420 
422  r.Fill(1);
423 
424  m_SegmentationFunction->Initialize(r);
425  this->SetDifferenceFunction(m_SegmentationFunction);
426  this->Modified();
427  }
428 
429  virtual SegmentationFunctionType * GetSegmentationFunction()
430  { return m_SegmentationFunction; }
431 
436  void SetMaximumCurvatureTimeStep(double n)
437  {
438  if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
439  {
440  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
441  this->Modified();
442  }
443  }
445 
446  double GetMaximumCurvatureTimeStep() const
447  {
448  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
449  }
450 
455  void SetMaximumPropagationTimeStep(double n)
456  {
457  if ( n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
458  {
459  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
460  this->Modified();
461  }
462  }
464 
465  double GetMaximumPropagationTimeStep() const
466  {
467  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
468  }
469 
473  void GenerateSpeedImage();
474 
478  void GenerateAdvectionImage();
479 
480 #ifdef ITK_USE_CONCEPT_CHECKING
481 
482  itkConceptMacro( OutputHasNumericTraitsCheck,
484 
486 #endif
487 
488 protected:
491 
492  virtual void PrintSelf(std::ostream & os, Indent indent) const;
493 
495  virtual void InitializeIteration()
496  {
497  Superclass::InitializeIteration();
498  // Estimate the progress of the filter
499  this->SetProgress( (float)( (float)this->GetElapsedIterations()
500  / (float)this->GetNumberOfIterations() ) );
501  }
503 
506  void GenerateData();
507 
511 
517 
518 private:
519  SegmentationLevelSetImageFilter(const Self &); //purposely not implemented
520  void operator=(const Self &); //purposely not implemented
521 
523 };
524 } // end namespace itk
525 
526 #ifndef ITK_MANUAL_INSTANTIATION
527 #include "itkSegmentationLevelSetImageFilter.hxx"
528 #endif
529 
530 #endif
531