ITK  5.0.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  ITK_DISALLOW_COPY_AND_ASSIGN(SegmentationLevelSetImageFilter);
152 
155 
156  //static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
157 
160 
165 
167  using ValueType = typename Superclass::ValueType;
169  using TimeStepType = typename Superclass::TimeStepType;
170  using InputImageType = typename Superclass::InputImageType;
171 
173  using FeatureImageType = TFeatureImage;
174 
178 
182 
185 
188  void SetMaximumIterations(unsigned int i)
189  {
190  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
191  this->SetNumberOfIterations(i);
192  }
194 
195  unsigned int GetMaximumIterations()
196  {
197  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
198  return this->GetNumberOfIterations();
199  }
200 
203  virtual void SetFeatureImage(const FeatureImageType *f)
204  {
205  itkDebugMacro("setting input FeatureImage to " << f );
206  if ( f != itkDynamicCastInDebugMode< FeatureImageType * >( this->ProcessObject::GetInput("FeatureImage") ) )
207  {
208  this->ProcessObject::SetInput( "FeatureImage", const_cast< FeatureImageType * >( f ) );
209  m_SegmentationFunction->SetFeatureImage(f);
210  this->Modified();
211  }
212  }
213  itkGetInputMacro(FeatureImage, FeatureImageType);
215 
218  itkSetInputMacro(InitialImage, InputImageType);
219  itkGetInputMacro(InitialImage, InputImageType);
221 
223  void SetInput2(const FeatureImageType *input)
224  {
225  this->SetFeatureImage(input);
226  }
227 
232  { m_SegmentationFunction->SetSpeedImage(s); }
233 
238  { m_SegmentationFunction->SetAdvectionImage(v); }
239 
242  virtual const SpeedImageType * GetSpeedImage() const
243  { return m_SegmentationFunction->GetSpeedImage(); }
244 
247  virtual const VectorImageType * GetAdvectionImage() const
248  { return m_SegmentationFunction->GetAdvectionImage(); }
249 
254  {
255  itkWarningMacro(
256  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
257  this->ReverseExpansionDirectionOn();
258  }
260 
262  {
263  itkWarningMacro(
264  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
265  this->ReverseExpansionDirectionOff();
266  }
267 
271  {
272  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
273  if ( u == true )
274  {
275  this->SetReverseExpansionDirection(false);
276  }
277  else
278  {
279  this->SetReverseExpansionDirection(true);
280  }
281  }
283 
285  {
286  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
287  if ( m_ReverseExpansionDirection == false )
288  {
289  return true;
290  }
291  else
292  {
293  return false;
294  }
295  }
296 
305  itkSetMacro(ReverseExpansionDirection, bool);
306  itkGetConstMacro(ReverseExpansionDirection, bool);
307  itkBooleanMacro(ReverseExpansionDirection);
309 
315  itkSetMacro(AutoGenerateSpeedAdvection, bool);
316  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
317  itkBooleanMacro(AutoGenerateSpeedAdvection);
319 
325  {
326  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
327  {
328  this->SetPropagationScaling(v);
329  }
330  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
331  {
332  this->SetAdvectionScaling(v);
333  }
334  }
336 
340  {
341  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
342  {
343  m_SegmentationFunction->SetPropagationWeight(v);
344  this->Modified();
345  }
346  }
348 
350  {
351  return m_SegmentationFunction->GetPropagationWeight();
352  }
353 
357  {
358  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
359  {
360  m_SegmentationFunction->SetAdvectionWeight(v);
361  this->Modified();
362  }
363  }
365 
367  {
368  return m_SegmentationFunction->GetAdvectionWeight();
369  }
370 
376  {
377  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()) )
378  {
379  m_SegmentationFunction->SetCurvatureWeight(v);
380  this->Modified();
381  }
382  }
384 
386  {
387  return m_SegmentationFunction->GetCurvatureWeight();
388  }
389 
392  {
393  if ( m_SegmentationFunction->GetUseMinimalCurvature() != b )
394  {
395  m_SegmentationFunction->SetUseMinimalCurvature(b);
396  this->Modified();
397  }
398  }
400 
402  {
403  return m_SegmentationFunction->GetUseMinimalCurvature();
404  }
405 
407  {
408  this->SetUseMinimalCurvature(true);
409  }
410 
412  {
413  this->SetUseMinimalCurvature(false);
414  }
415 
422  {
423  m_SegmentationFunction = s;
424 
426  r.Fill(1);
427 
428  m_SegmentationFunction->Initialize(r);
429  this->SetDifferenceFunction(m_SegmentationFunction);
430  this->Modified();
431  }
432 
434  { return m_SegmentationFunction; }
435 
441  {
442  if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
443  {
444  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
445  this->Modified();
446  }
447  }
449 
451  {
452  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
453  }
454 
460  {
461  if ( n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
462  {
463  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
464  this->Modified();
465  }
466  }
468 
470  {
471  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
472  }
473 
477  void GenerateSpeedImage();
478 
482  void GenerateAdvectionImage();
483 
484 #ifdef ITK_USE_CONCEPT_CHECKING
485  // Begin concept checking
486  itkConceptMacro( OutputHasNumericTraitsCheck,
488  // End concept checking
489 #endif
490 
491 protected:
492  ~SegmentationLevelSetImageFilter() override = default;
494 
495  void PrintSelf(std::ostream & os, Indent indent) const override;
496 
498  void InitializeIteration() override
499  {
500  Superclass::InitializeIteration();
501  // Estimate the progress of the filter
502  this->UpdateProgress( (float)( (float)this->GetElapsedIterations()
503  / (float)this->GetNumberOfIterations() ) );
504  }
506 
509  void GenerateData() override;
510 
514 
520 
521 private:
523 };
524 } // end namespace itk
525 
526 #ifndef ITK_MANUAL_INSTANTIATION
527 #include "itkSegmentationLevelSetImageFilter.hxx"
528 #endif
529 
530 #endif
Light weight base class for most itk classes.
virtual void SetFeatureImage(const FeatureImageType *f)
This class implements a finite difference partial differential equation solver for evolving surfaces ...
typename SegmentationFunctionType::ImageType SpeedImageType
void Initialize(const RadiusType &r) override
typename SegmentationFunctionType::VectorImageType VectorImageType
typename Superclass::InputImageType InputImageType
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
virtual const SpeedImageType * GetSpeedImage() const
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
virtual SegmentationFunctionType * GetSegmentationFunction()
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
#define itkConceptMacro(name, concept)
virtual const VectorImageType * GetAdvectionImage() const
typename Superclass::RadiusType RadiusType
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