ITK  4.12.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 #include "itkMath.h"
24 
25 namespace itk
26 {
143 template< typename TInputImage,
144  typename TFeatureImage,
145  typename TOutputPixelType = float >
146 class ITK_TEMPLATE_EXPORT SegmentationLevelSetImageFilter:
147  public SparseFieldLevelSetImageFilter< TInputImage, Image< TOutputPixelType,
148  TInputImage::ImageDimension > >
149 {
150 public:
151 
154 
155  //itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
156 
159 
164 
166  typedef typename Superclass::ValueType ValueType;
167  typedef typename Superclass::IndexType IndexType;
168  typedef typename Superclass::TimeStepType TimeStepType;
169  typedef typename Superclass::InputImageType InputImageType;
170 
172  typedef TFeatureImage FeatureImageType;
173 
177 
181 
184 
187  void SetMaximumIterations(unsigned int i)
188  {
189  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
190  this->SetNumberOfIterations(i);
191  }
193 
194  unsigned int GetMaximumIterations()
195  {
196  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
197  return this->GetNumberOfIterations();
198  }
199 
202  virtual void SetFeatureImage(const FeatureImageType *f)
203  {
204  this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >( f ) );
205  m_SegmentationFunction->SetFeatureImage(f);
206  }
208 
210  { return ( static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) ) ); }
211 
215  {
216  this->SetInput(f);
217  }
218 
220  void SetInput2(const FeatureImageType *input)
221  {
222  this->SetFeatureImage(input);
223  }
224 
229  { m_SegmentationFunction->SetSpeedImage(s); }
230 
235  { m_SegmentationFunction->SetAdvectionImage(v); }
236 
239  virtual const SpeedImageType * GetSpeedImage() const
240  { return m_SegmentationFunction->GetSpeedImage(); }
241 
244  virtual const VectorImageType * GetAdvectionImage() const
245  { return m_SegmentationFunction->GetAdvectionImage(); }
246 
251  {
252  itkWarningMacro(
253  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
254  this->ReverseExpansionDirectionOn();
255  }
257 
259  {
260  itkWarningMacro(
261  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
262  this->ReverseExpansionDirectionOff();
263  }
264 
268  {
269  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
270  if ( u == true )
271  {
272  this->SetReverseExpansionDirection(false);
273  }
274  else
275  {
276  this->SetReverseExpansionDirection(true);
277  }
278  }
280 
282  {
283  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
284  if ( m_ReverseExpansionDirection == false )
285  {
286  return true;
287  }
288  else
289  {
290  return false;
291  }
292  }
293 
302  itkSetMacro(ReverseExpansionDirection, bool);
303  itkGetConstMacro(ReverseExpansionDirection, bool);
304  itkBooleanMacro(ReverseExpansionDirection);
306 
312  itkSetMacro(AutoGenerateSpeedAdvection, bool);
313  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
314  itkBooleanMacro(AutoGenerateSpeedAdvection);
316 
322  {
323  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
324  {
325  this->SetPropagationScaling(v);
326  }
327  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
328  {
329  this->SetAdvectionScaling(v);
330  }
331  }
333 
337  {
338  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
339  {
340  m_SegmentationFunction->SetPropagationWeight(v);
341  this->Modified();
342  }
343  }
345 
347  {
348  return m_SegmentationFunction->GetPropagationWeight();
349  }
350 
354  {
355  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
356  {
357  m_SegmentationFunction->SetAdvectionWeight(v);
358  this->Modified();
359  }
360  }
362 
364  {
365  return m_SegmentationFunction->GetAdvectionWeight();
366  }
367 
373  {
374  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()) )
375  {
376  m_SegmentationFunction->SetCurvatureWeight(v);
377  this->Modified();
378  }
379  }
381 
383  {
384  return m_SegmentationFunction->GetCurvatureWeight();
385  }
386 
389  {
390  if ( m_SegmentationFunction->GetUseMinimalCurvature() != b )
391  {
392  m_SegmentationFunction->SetUseMinimalCurvature(b);
393  this->Modified();
394  }
395  }
397 
399  {
400  return m_SegmentationFunction->GetUseMinimalCurvature();
401  }
402 
404  {
405  this->SetUseMinimalCurvature(true);
406  }
407 
409  {
410  this->SetUseMinimalCurvature(false);
411  }
412 
419  {
420  m_SegmentationFunction = s;
421 
423  r.Fill(1);
424 
425  m_SegmentationFunction->Initialize(r);
426  this->SetDifferenceFunction(m_SegmentationFunction);
427  this->Modified();
428  }
429 
431  { return m_SegmentationFunction; }
432 
438  {
439  if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
440  {
441  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
442  this->Modified();
443  }
444  }
446 
448  {
449  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
450  }
451 
457  {
458  if ( n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
459  {
460  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
461  this->Modified();
462  }
463  }
465 
467  {
468  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
469  }
470 
474  void GenerateSpeedImage();
475 
479  void GenerateAdvectionImage();
480 
481 #ifdef ITK_USE_CONCEPT_CHECKING
482  // Begin concept checking
483  itkConceptMacro( OutputHasNumericTraitsCheck,
485  // End concept checking
486 #endif
487 
488 protected:
491 
492  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
493 
495  virtual void InitializeIteration() ITK_OVERRIDE
496  {
497  Superclass::InitializeIteration();
498  // Estimate the progress of the filter
499  this->UpdateProgress( (float)( (float)this->GetElapsedIterations()
500  / (float)this->GetNumberOfIterations() ) );
501  }
503 
506  void GenerateData() ITK_OVERRIDE;
507 
510  bool m_ReverseExpansionDirection;
511 
516  bool m_AutoGenerateSpeedAdvection;
517 
518 private:
519  ITK_DISALLOW_COPY_AND_ASSIGN(SegmentationLevelSetImageFilter);
520 
521  SegmentationFunctionType *m_SegmentationFunction;
522 };
523 } // end namespace itk
524 
525 #ifndef ITK_MANUAL_INSTANTIATION
526 #include "itkSegmentationLevelSetImageFilter.hxx"
527 #endif
528 
529 #endif
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SegmentationFunctionType::VectorImageType VectorImageType
virtual void SetFeatureImage(const FeatureImageType *f)
SegmentationLevelSetFunction< OutputImageType, FeatureImageType > SegmentationFunctionType
This class implements a finite difference partial differential equation solver for evolving surfaces ...
SparseFieldLevelSetImageFilter< TInputImage, OutputImageType > Superclass
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
Image< TOutputPixelType, itkGetStaticConstMacro(InputImageDimension) > OutputImageType
virtual const SpeedImageType * GetSpeedImage() const
SegmentationFunctionType::ImageType SpeedImageType
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:721
virtual SegmentationFunctionType * GetSegmentationFunction()
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void Initialize(const RadiusType &r) override
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
#define itkConceptMacro(name, concept)
virtual const VectorImageType * GetAdvectionImage() const
A base class which defines the API for implementing a special class of image segmentation filters usi...
Templated n-dimensional image class.
Definition: itkImage.h:75