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  else
309  {
310  return false;
311  }
312  }
313 
322  itkSetMacro(ReverseExpansionDirection, bool);
323  itkGetConstMacro(ReverseExpansionDirection, bool);
324  itkBooleanMacro(ReverseExpansionDirection);
332  itkSetMacro(AutoGenerateSpeedAdvection, bool);
333  itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
334  itkBooleanMacro(AutoGenerateSpeedAdvection);
341  void
343  {
344  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
345  {
346  this->SetPropagationScaling(v);
347  }
348  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
349  {
350  this->SetAdvectionScaling(v);
351  }
352  }
357  void
359  {
360  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
361  {
362  m_SegmentationFunction->SetPropagationWeight(v);
363  this->Modified();
364  }
365  }
368  ValueType
370  {
371  return m_SegmentationFunction->GetPropagationWeight();
372  }
373 
376  void
378  {
379  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
380  {
381  m_SegmentationFunction->SetAdvectionWeight(v);
382  this->Modified();
383  }
384  }
387  ValueType
389  {
390  return m_SegmentationFunction->GetAdvectionWeight();
391  }
392 
397  void
399  {
400  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
401  {
402  m_SegmentationFunction->SetCurvatureWeight(v);
403  this->Modified();
404  }
405  }
408  ValueType
410  {
411  return m_SegmentationFunction->GetCurvatureWeight();
412  }
413 
415  void
417  {
418  if (m_SegmentationFunction->GetUseMinimalCurvature() != b)
419  {
420  m_SegmentationFunction->SetUseMinimalCurvature(b);
421  this->Modified();
422  }
423  }
426  bool
428  {
429  return m_SegmentationFunction->GetUseMinimalCurvature();
430  }
431 
432  void
434  {
435  this->SetUseMinimalCurvature(true);
436  }
437 
438  void
440  {
441  this->SetUseMinimalCurvature(false);
442  }
443 
449  virtual void
451  {
452  m_SegmentationFunction = s;
453 
455  r.Fill(1);
456 
457  m_SegmentationFunction->Initialize(r);
458  this->SetDifferenceFunction(m_SegmentationFunction);
459  this->Modified();
460  }
461 
462  virtual SegmentationFunctionType *
464  {
465  return m_SegmentationFunction;
466  }
467 
472  void
474  {
475  if (n != m_SegmentationFunction->GetMaximumCurvatureTimeStep())
476  {
477  m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
478  this->Modified();
479  }
480  }
483  double
485  {
486  return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
487  }
488 
493  void
495  {
496  if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep())
497  {
498  m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
499  this->Modified();
500  }
501  }
504  double
506  {
507  return m_SegmentationFunction->GetMaximumPropagationTimeStep();
508  }
509 
513  void
514  GenerateSpeedImage();
515 
519  void
520  GenerateAdvectionImage();
521 
522 #ifdef ITK_USE_CONCEPT_CHECKING
523  // Begin concept checking
524  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<TOutputPixelType>));
525  // End concept checking
526 #endif
527 
528 protected:
529  ~SegmentationLevelSetImageFilter() override = default;
531 
532  void
533  PrintSelf(std::ostream & os, Indent indent) const override;
534 
536  void
538  {
539  Superclass::InitializeIteration();
540  // Estimate the progress of the filter
541  this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
542  static_cast<float>(this->GetNumberOfIterations()));
543  }
548  void
549  GenerateData() override;
550 
553  bool m_ReverseExpansionDirection{};
554 
559  bool m_AutoGenerateSpeedAdvection{};
560 
561 private:
562  SegmentationFunctionType * m_SegmentationFunction{};
563 };
564 } // end namespace itk
565 
566 #ifndef ITK_MANUAL_INSTANTIATION
567 # include "itkSegmentationLevelSetImageFilter.hxx"
568 #endif
569 
570 #endif
itk::SegmentationLevelSetImageFilter::GetCurvatureScaling
ValueType GetCurvatureScaling() const
Definition: itkSegmentationLevelSetImageFilter.h:409
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:398
itk::FiniteDifferenceFunction::RadiusType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::SparseFieldLevelSetImageFilter
This class implements a finite difference partial differential equation solver for evolving surfaces ...
Definition: itkSparseFieldLevelSetImageFilter.h:244
itk::SegmentationLevelSetFunction::Initialize
void Initialize(const RadiusType &r) override
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:716
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:505
itk::SegmentationLevelSetImageFilter::SetSegmentationFunction
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
Definition: itkSegmentationLevelSetImageFilter.h:450
itk::SegmentationLevelSetImageFilter::SetAdvectionScaling
void SetAdvectionScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:377
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:737
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:433
itk::SegmentationLevelSetImageFilter::GetSegmentationFunction
virtual SegmentationFunctionType * GetSegmentationFunction()
Definition: itkSegmentationLevelSetImageFilter.h:463
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:358
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:427
itk::SegmentationLevelSetImageFilter::SetAdvectionImage
void SetAdvectionImage(VectorImageType *v)
Definition: itkSegmentationLevelSetImageFilter.h:241
itk::SegmentationLevelSetImageFilter::GetMaximumCurvatureTimeStep
double GetMaximumCurvatureTimeStep() const
Definition: itkSegmentationLevelSetImageFilter.h:484
itk::SegmentationLevelSetImageFilter::SetMaximumCurvatureTimeStep
void SetMaximumCurvatureTimeStep(double n)
Definition: itkSegmentationLevelSetImageFilter.h:473
itk::SegmentationLevelSetImageFilter::UseMinimalCurvatureOff
void UseMinimalCurvatureOff()
Definition: itkSegmentationLevelSetImageFilter.h:439
itk::SegmentationLevelSetImageFilter::SetFeatureScaling
void SetFeatureScaling(ValueType v)
Definition: itkSegmentationLevelSetImageFilter.h:342
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: itkAnnulusOperator.h:24
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:494
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:369
itk::SegmentationLevelSetImageFilter::SetUseMinimalCurvature
void SetUseMinimalCurvature(bool b)
Definition: itkSegmentationLevelSetImageFilter.h:416
itkMath.h
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::SegmentationLevelSetImageFilter::GetAdvectionScaling
ValueType GetAdvectionScaling() const
Definition: itkSegmentationLevelSetImageFilter.h:388
itk::SegmentationLevelSetImageFilter::InitializeIteration
void InitializeIteration() override
Definition: itkSegmentationLevelSetImageFilter.h:537