ITK  4.13.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;
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  itkDebugMacro("setting input FeatureImage to " << f );
205  if ( f != itkDynamicCastInDebugMode< FeatureImageType * >( this->ProcessObject::GetInput("FeatureImage") ) )
206  {
207  this->ProcessObject::SetInput( "FeatureImage", const_cast< FeatureImageType * >( f ) );
208  m_SegmentationFunction->SetFeatureImage(f);
209  this->Modified();
210  }
211  }
212  itkGetInputMacro(FeatureImage, FeatureImageType);
214 
217  itkSetInputMacro(InitialImage, InputImageType);
218  itkGetInputMacro(InitialImage, InputImageType);
220 
222  void SetInput2(const FeatureImageType *input)
223  {
224  this->SetFeatureImage(input);
225  }
226 
231  { m_SegmentationFunction->SetSpeedImage(s); }
232 
237  { m_SegmentationFunction->SetAdvectionImage(v); }
238 
241  virtual const SpeedImageType * GetSpeedImage() const
242  { return m_SegmentationFunction->GetSpeedImage(); }
243 
246  virtual const VectorImageType * GetAdvectionImage() const
247  { return m_SegmentationFunction->GetAdvectionImage(); }
248 
253  {
254  itkWarningMacro(
255  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
256  this->ReverseExpansionDirectionOn();
257  }
259 
261  {
262  itkWarningMacro(
263  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
264  this->ReverseExpansionDirectionOff();
265  }
266 
270  {
271  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
272  if ( u == true )
273  {
274  this->SetReverseExpansionDirection(false);
275  }
276  else
277  {
278  this->SetReverseExpansionDirection(true);
279  }
280  }
282 
284  {
285  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
286  if ( m_ReverseExpansionDirection == false )
287  {
288  return true;
289  }
290  else
291  {
292  return false;
293  }
294  }
295 
304  itkSetMacro(ReverseExpansionDirection, bool);
305  itkGetConstMacro(ReverseExpansionDirection, bool);
306  itkBooleanMacro(ReverseExpansionDirection);
308 
314  itkSetMacro(AutoGenerateSpeedAdvection, bool);
315  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
316  itkBooleanMacro(AutoGenerateSpeedAdvection);
318 
324  {
325  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
326  {
327  this->SetPropagationScaling(v);
328  }
329  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
330  {
331  this->SetAdvectionScaling(v);
332  }
333  }
335 
339  {
340  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
341  {
342  m_SegmentationFunction->SetPropagationWeight(v);
343  this->Modified();
344  }
345  }
347 
349  {
350  return m_SegmentationFunction->GetPropagationWeight();
351  }
352 
356  {
357  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
358  {
359  m_SegmentationFunction->SetAdvectionWeight(v);
360  this->Modified();
361  }
362  }
364 
366  {
367  return m_SegmentationFunction->GetAdvectionWeight();
368  }
369 
375  {
376  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()) )
377  {
378  m_SegmentationFunction->SetCurvatureWeight(v);
379  this->Modified();
380  }
381  }
383 
385  {
386  return m_SegmentationFunction->GetCurvatureWeight();
387  }
388 
391  {
392  if ( m_SegmentationFunction->GetUseMinimalCurvature() != b )
393  {
394  m_SegmentationFunction->SetUseMinimalCurvature(b);
395  this->Modified();
396  }
397  }
399 
401  {
402  return m_SegmentationFunction->GetUseMinimalCurvature();
403  }
404 
406  {
407  this->SetUseMinimalCurvature(true);
408  }
409 
411  {
412  this->SetUseMinimalCurvature(false);
413  }
414 
421  {
422  m_SegmentationFunction = s;
423 
425  r.Fill(1);
426 
427  m_SegmentationFunction->Initialize(r);
428  this->SetDifferenceFunction(m_SegmentationFunction);
429  this->Modified();
430  }
431 
433  { return m_SegmentationFunction; }
434 
440  {
441  if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
442  {
443  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
444  this->Modified();
445  }
446  }
448 
450  {
451  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
452  }
453 
459  {
460  if ( n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
461  {
462  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
463  this->Modified();
464  }
465  }
467 
469  {
470  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
471  }
472 
476  void GenerateSpeedImage();
477 
481  void GenerateAdvectionImage();
482 
483 #ifdef ITK_USE_CONCEPT_CHECKING
484  // Begin concept checking
485  itkConceptMacro( OutputHasNumericTraitsCheck,
487  // End concept checking
488 #endif
489 
490 protected:
491  virtual ~SegmentationLevelSetImageFilter() ITK_OVERRIDE {}
493 
494  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
495 
497  virtual void InitializeIteration() ITK_OVERRIDE
498  {
499  Superclass::InitializeIteration();
500  // Estimate the progress of the filter
501  this->UpdateProgress( (float)( (float)this->GetElapsedIterations()
502  / (float)this->GetNumberOfIterations() ) );
503  }
505 
508  void GenerateData() ITK_OVERRIDE;
509 
512  bool m_ReverseExpansionDirection;
513 
518  bool m_AutoGenerateSpeedAdvection;
519 
520 private:
521  ITK_DISALLOW_COPY_AND_ASSIGN(SegmentationLevelSetImageFilter);
522 
523  SegmentationFunctionType *m_SegmentationFunction;
524 };
525 } // end namespace itk
526 
527 #ifndef ITK_MANUAL_INSTANTIATION
528 #include "itkSegmentationLevelSetImageFilter.hxx"
529 #endif
530 
531 #endif
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 SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
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
#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