ITK  6.0.0
Insight Toolkit
itkSegmentationLevelSetImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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, typename TFeatureImage, typename TOutputPixelType = float>
144 class ITK_TEMPLATE_EXPORT SegmentationLevelSetImageFilter
145  : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType, TInputImage::ImageDimension>>
146 {
147 public:
148  ITK_DISALLOW_COPY_AND_MOVE(SegmentationLevelSetImageFilter);
149 
152 
153  // static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
154 
157 
162 
164  using typename Superclass::ValueType;
165  using typename Superclass::IndexType;
166  using typename Superclass::TimeStepType;
167  using typename Superclass::InputImageType;
168 
170  using FeatureImageType = TFeatureImage;
171 
174 
178 
180  itkOverrideGetNameOfClassMacro(SegmentationLevelSetImageFilter);
181 
184  void
185  SetMaximumIterations(unsigned int i)
186  {
187  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
188  this->SetNumberOfIterations(i);
189  }
192  unsigned int
194  {
195  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
196  return this->GetNumberOfIterations();
197  }
198 
201  virtual void
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);
217  itkSetInputMacro(InitialImage, InputImageType);
218  itkGetInputMacro(InitialImage, InputImageType);
222  void
224  {
225  this->SetFeatureImage(input);
226  }
227 
231  void
233  {
234  m_SegmentationFunction->SetSpeedImage(s);
235  }
236 
240  void
242  {
243  m_SegmentationFunction->SetAdvectionImage(v);
244  }
245 
248  virtual const SpeedImageType *
250  {
251  return m_SegmentationFunction->GetSpeedImage();
252  }
253 
256  virtual const VectorImageType *
258  {
259  return m_SegmentationFunction->GetAdvectionImage();
260  }
261 
265  void
267  {
268  itkWarningMacro(
269  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
270  this->ReverseExpansionDirectionOn();
271  }
274  void
276  {
277  itkWarningMacro(
278  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
279  this->ReverseExpansionDirectionOff();
280  }
281 
284  void
286  {
287  itkWarningMacro("SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
288  if (u)
289  {
290  this->SetReverseExpansionDirection(false);
291  }
292  else
293  {
294  this->SetReverseExpansionDirection(true);
295  }
296  }
299  bool
301  {
302  itkWarningMacro(
303  << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
304  if (m_ReverseExpansionDirection == false)
305  {
306  return true;
307  }
308 
309  return false;
310  }
311 
320  itkSetMacro(ReverseExpansionDirection, bool);
321  itkGetConstMacro(ReverseExpansionDirection, bool);
322  itkBooleanMacro(ReverseExpansionDirection);
330  itkSetMacro(AutoGenerateSpeedAdvection, bool);
331  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
332  itkBooleanMacro(AutoGenerateSpeedAdvection);
339  void
341  {
342  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
343  {
344  this->SetPropagationScaling(v);
345  }
346  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
347  {
348  this->SetAdvectionScaling(v);
349  }
350  }
355  void
357  {
358  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
359  {
360  m_SegmentationFunction->SetPropagationWeight(v);
361  this->Modified();
362  }
363  }
366  ValueType
368  {
369  return m_SegmentationFunction->GetPropagationWeight();
370  }
371 
374  void
376  {
377  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
378  {
379  m_SegmentationFunction->SetAdvectionWeight(v);
380  this->Modified();
381  }
382  }
385  ValueType
387  {
388  return m_SegmentationFunction->GetAdvectionWeight();
389  }
390 
395  void
397  {
398  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
399  {
400  m_SegmentationFunction->SetCurvatureWeight(v);
401  this->Modified();
402  }
403  }
406  ValueType
408  {
409  return m_SegmentationFunction->GetCurvatureWeight();
410  }
411 
413  void
415  {
416  if (m_SegmentationFunction->GetUseMinimalCurvature() != b)
417  {
418  m_SegmentationFunction->SetUseMinimalCurvature(b);
419  this->Modified();
420  }
421  }
424  bool
426  {
427  return m_SegmentationFunction->GetUseMinimalCurvature();
428  }
429 
430  void
432  {
433  this->SetUseMinimalCurvature(true);
434  }
435 
436  void
438  {
439  this->SetUseMinimalCurvature(false);
440  }
441 
447  virtual void
449  {
450  m_SegmentationFunction = s;
451 
452  constexpr auto r = MakeFilled<typename SegmentationFunctionType::RadiusType>(1);
453 
454  m_SegmentationFunction->Initialize(r);
455  this->SetDifferenceFunction(m_SegmentationFunction);
456  this->Modified();
457  }
458 
459  virtual SegmentationFunctionType *
461  {
462  return m_SegmentationFunction;
463  }
464 
469  void
471  {
472  if (n != m_SegmentationFunction->GetMaximumCurvatureTimeStep())
473  {
474  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
475  this->Modified();
476  }
477  }
480  double
482  {
483  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
484  }
485 
490  void
492  {
493  if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep())
494  {
495  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
496  this->Modified();
497  }
498  }
501  double
503  {
504  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
505  }
506 
510  void
511  GenerateSpeedImage();
512 
516  void
517  GenerateAdvectionImage();
518 
519 #ifdef ITK_USE_CONCEPT_CHECKING
520  // Begin concept checking
521  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<TOutputPixelType>));
522  // End concept checking
523 #endif
524 
525 protected:
526  ~SegmentationLevelSetImageFilter() override = default;
528 
529  void
530  PrintSelf(std::ostream & os, Indent indent) const override;
531 
533  void
535  {
536  Superclass::InitializeIteration();
537  // Estimate the progress of the filter
538  this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
539  static_cast<float>(this->GetNumberOfIterations()));
540  }
545  void
546  GenerateData() override;
547 
550  bool m_ReverseExpansionDirection{};
551 
556  bool m_AutoGenerateSpeedAdvection{};
557 
558 private:
559  SegmentationFunctionType * m_SegmentationFunction{};
560 };
561 } // end namespace itk
562 
563 #ifndef ITK_MANUAL_INSTANTIATION
564 # include "itkSegmentationLevelSetImageFilter.hxx"
565 #endif
566 
567 #endif
itk::SegmentationLevelSetImageFilter::GetCurvatureScaling
ValueType GetCurvatureScaling() const
Definition: itkSegmentationLevelSetImageFilter.h:407
itk::SegmentationLevelSetImageFilter
A base class which defines the API for implementing a special class of image segmentation filters usi...
Definition: itkSegmentationLevelSetImageFilter.h:144
itk::SegmentationLevelSetImageFilter::SetCurvatureScaling
void SetCurvatureScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:396
itk::SparseFieldLevelSetImageFilter
This class implements a finite difference partial differential equation solver for evolving surfaces ...
Definition: itkSparseFieldLevelSetImageFilter.h:244
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::SegmentationLevelSetImageFilter::SetUseNegativeFeatures
void SetUseNegativeFeatures(bool u)
Definition: itkSegmentationLevelSetImageFilter.h:285
itk::SegmentationLevelSetImageFilter::GetMaximumIterations
unsigned int GetMaximumIterations()
Definition: itkSegmentationLevelSetImageFilter.h:193
itk::SegmentationLevelSetImageFilter::SpeedImageType
typename SegmentationFunctionType::ImageType SpeedImageType
Definition: itkSegmentationLevelSetImageFilter.h:177
itk::SegmentationLevelSetImageFilter::GetMaximumPropagationTimeStep
double GetMaximumPropagationTimeStep() const
Definition: itkSegmentationLevelSetImageFilter.h:502
itk::SegmentationLevelSetImageFilter::SetSegmentationFunction
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
Definition: itkSegmentationLevelSetImageFilter.h:448
itk::SegmentationLevelSetImageFilter::SetAdvectionScaling
void SetAdvectionScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:375
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Math::NotExactlyEquals
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:733
itk::FiniteDifferenceFunction::ImageType
TImageType ImageType
Definition: itkFiniteDifferenceFunction.h:82
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ProcessObject::SetInput
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
itk::SegmentationLevelSetImageFilter::UseMinimalCurvatureOn
void UseMinimalCurvatureOn()
Definition: itkSegmentationLevelSetImageFilter.h:431
itk::SegmentationLevelSetImageFilter::GetSegmentationFunction
virtual SegmentationFunctionType * GetSegmentationFunction()
Definition: itkSegmentationLevelSetImageFilter.h:460
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkSegmentationLevelSetFunction.h
itk::SegmentationLevelSetImageFilter::GetSpeedImage
virtual const SpeedImageType * GetSpeedImage() const
Definition: itkSegmentationLevelSetImageFilter.h:249
itk::SegmentationLevelSetImageFilter::SetFeatureImage
virtual void SetFeatureImage(const FeatureImageType *f)
Definition: itkSegmentationLevelSetImageFilter.h:202
itk::SegmentationLevelSetImageFilter::SetPropagationScaling
void SetPropagationScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:356
itk::SegmentationLevelSetImageFilter::GetAdvectionImage
virtual const VectorImageType * GetAdvectionImage() const
Definition: itkSegmentationLevelSetImageFilter.h:257
itk::SegmentationLevelSetImageFilter::SetSpeedImage
void SetSpeedImage(SpeedImageType *s)
Definition: itkSegmentationLevelSetImageFilter.h:232
itk::SegmentationLevelSetImageFilter::GetUseMinimalCurvature
bool GetUseMinimalCurvature() const
Definition: itkSegmentationLevelSetImageFilter.h:425
itk::SegmentationLevelSetImageFilter::SetAdvectionImage
void SetAdvectionImage(VectorImageType *v)
Definition: itkSegmentationLevelSetImageFilter.h:241
itk::SegmentationLevelSetImageFilter::GetMaximumCurvatureTimeStep
double GetMaximumCurvatureTimeStep() const
Definition: itkSegmentationLevelSetImageFilter.h:481
itk::SegmentationLevelSetImageFilter::SetMaximumCurvatureTimeStep
void SetMaximumCurvatureTimeStep(double n)
Definition: itkSegmentationLevelSetImageFilter.h:470
itk::SegmentationLevelSetImageFilter::UseMinimalCurvatureOff
void UseMinimalCurvatureOff()
Definition: itkSegmentationLevelSetImageFilter.h:437
itk::SegmentationLevelSetImageFilter::SetFeatureScaling
void SetFeatureScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:340
itk::SegmentationLevelSetImageFilter::GetUseNegativeFeatures
bool GetUseNegativeFeatures() const
Definition: itkSegmentationLevelSetImageFilter.h:300
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::SparseFieldLevelSetImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkSparseFieldLevelSetImageFilter.h:274
itk::SegmentationLevelSetFunction
Definition: itkSegmentationLevelSetFunction.h:47
itk::SegmentationLevelSetImageFilter::SetMaximumIterations
void SetMaximumIterations(unsigned int i)
Definition: itkSegmentationLevelSetImageFilter.h:185
itk::SegmentationLevelSetImageFilter::VectorImageType
typename SegmentationFunctionType::VectorImageType VectorImageType
Definition: itkSegmentationLevelSetImageFilter.h:176
itk::SegmentationLevelSetImageFilter::SetUseNegativeFeaturesOn
void SetUseNegativeFeaturesOn()
Definition: itkSegmentationLevelSetImageFilter.h:266
itk::SegmentationLevelSetImageFilter::SetMaximumPropagationTimeStep
void SetMaximumPropagationTimeStep(double n)
Definition: itkSegmentationLevelSetImageFilter.h:491
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::SegmentationLevelSetImageFilter::SetUseNegativeFeaturesOff
void SetUseNegativeFeaturesOff()
Definition: itkSegmentationLevelSetImageFilter.h:275
itk::SegmentationLevelSetImageFilter::SetInput2
void SetInput2(const FeatureImageType *input)
Definition: itkSegmentationLevelSetImageFilter.h:223
itkSparseFieldLevelSetImageFilter.h
itk::SegmentationLevelSetImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkSegmentationLevelSetImageFilter.h:170
itk::SegmentationLevelSetImageFilter::GetPropagationScaling
ValueType GetPropagationScaling() const
Definition: itkSegmentationLevelSetImageFilter.h:367
itk::SegmentationLevelSetImageFilter::SetUseMinimalCurvature
void SetUseMinimalCurvature(bool b)
Definition: itkSegmentationLevelSetImageFilter.h:414
itkMath.h
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::SegmentationLevelSetImageFilter::GetAdvectionScaling
ValueType GetAdvectionScaling() const
Definition: itkSegmentationLevelSetImageFilter.h:386
itk::SegmentationLevelSetImageFilter::InitializeIteration
void InitializeIteration() override
Definition: itkSegmentationLevelSetImageFilter.h:534