ITK  6.0.0
Insight Toolkit
itkNarrowBandLevelSetImageFilter.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 itkNarrowBandLevelSetImageFilter_h
19 #define itkNarrowBandLevelSetImageFilter_h
20 
25 #include "itkMath.h"
26 
27 namespace itk
28 {
143 template <typename TInputImage,
144  typename TFeatureImage,
145  typename TOutputPixelType = float,
146  typename TOutputImage = Image<TOutputPixelType, TInputImage::ImageDimension>>
147 class ITK_TEMPLATE_EXPORT NarrowBandLevelSetImageFilter : public NarrowBandImageFilterBase<TInputImage, TOutputImage>
148 {
149 public:
150  ITK_DISALLOW_COPY_AND_MOVE(NarrowBandLevelSetImageFilter);
151 
157 
159  using typename Superclass::ValueType;
160  using typename Superclass::IndexType;
161  using typename Superclass::TimeStepType;
162  using typename Superclass::InputImageType;
163 
165  using OutputImageType = TOutputImage;
166  using FeatureImageType = TFeatureImage;
167 
170 
173 
175  itkOverrideGetNameOfClassMacro(NarrowBandLevelSetImageFilter);
176 
179  virtual void
181  {
182  this->ProcessObject::SetNthInput(1, const_cast<FeatureImageType *>(f));
183  m_SegmentationFunction->SetFeatureImage(f);
184  }
187  virtual FeatureImageType *
189  {
190  return (static_cast<FeatureImageType *>(this->ProcessObject::GetInput(1)));
191  }
192 
195  virtual void
197  {
198  this->SetInput(f);
199  }
200 
201  virtual const typename SegmentationFunctionType::ImageType *
203  {
204  return m_SegmentationFunction->GetSpeedImage();
205  }
206 
207  virtual const typename SegmentationFunctionType::VectorImageType *
209  {
210  return m_SegmentationFunction->GetAdvectionImage();
211  }
212 
216  void
218  {
219  itkWarningMacro(
220  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
221  this->ReverseExpansionDirectionOn();
222  }
225  void
227  {
228  itkWarningMacro(
229  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
230  this->ReverseExpansionDirectionOff();
231  }
232 
235  void
237  {
238  itkWarningMacro("SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
239  if (u)
240  {
241  this->SetReverseExpansionDirection(false);
242  }
243  else
244  {
245  this->SetReverseExpansionDirection(true);
246  }
247  }
250  bool
252  {
253  itkWarningMacro(
254  << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
255  if (this->GetReverseExpansionDirection() == false)
256  {
257  return true;
258  }
259 
260  return false;
261  }
262 
271  itkSetMacro(ReverseExpansionDirection, bool);
272  itkGetConstMacro(ReverseExpansionDirection, bool);
273  itkBooleanMacro(ReverseExpansionDirection);
280  void
282  {
283  if (v != m_SegmentationFunction->GetPropagationWeight())
284  {
285  this->SetPropagationScaling(v);
286  }
287  if (v != m_SegmentationFunction->GetAdvectionWeight())
288  {
289  this->SetAdvectionScaling(v);
290  }
291  }
296  void
298  {
299  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
300  {
301  m_SegmentationFunction->SetPropagationWeight(v);
302  }
303  }
306  ValueType
308  {
309  return m_SegmentationFunction->GetPropagationWeight();
310  }
311 
314  void
316  {
317  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
318  {
319  m_SegmentationFunction->SetAdvectionWeight(v);
320  }
321  }
324  ValueType
326  {
327  return m_SegmentationFunction->GetAdvectionWeight();
328  }
329 
334  void
336  {
337  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
338  {
339  m_SegmentationFunction->SetCurvatureWeight(v);
340  }
341  }
344  ValueType
346  {
347  return m_SegmentationFunction->GetCurvatureWeight();
348  }
349 
352  virtual void
353  SetSegmentationFunction(SegmentationFunctionType * s);
354 
355  virtual SegmentationFunctionType *
357  {
358  return m_SegmentationFunction;
359  }
360 
363  void
364  SetMaximumIterations(unsigned int i)
365  {
366  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
367  this->SetNumberOfIterations(i);
368  }
371  unsigned int
373  {
374  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
375  return this->GetNumberOfIterations();
376  }
377 
378  void
379  SetMaximumRMSError(const double) override
380  {
381  itkWarningMacro("The current implementation of this solver does not compute maximum RMS change. The maximum RMS "
382  "error value will not be set or used.");
383  }
384 
385 #ifdef ITK_USE_CONCEPT_CHECKING
386  // Begin concept checking
388  // End concept checking
389 #endif
390 
391 protected:
392  ~NarrowBandLevelSetImageFilter() override = default;
394 
395  void
396  PrintSelf(std::ostream & os, Indent indent) const override;
397 
398 
400  void
402  {
403  Superclass::InitializeIteration();
404  // Estimate the progress of the filter
405  this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
406  static_cast<float>(this->GetNumberOfIterations()));
407  }
413  void
414  CreateNarrowBand() override;
415 
418  void
419  GenerateData() override;
420 
423  bool m_ReverseExpansionDirection{};
424 
430 
431  typename IsoFilterType::Pointer m_IsoFilter{};
432 
433  typename ChamferFilterType::Pointer m_ChamferFilter{};
434 
435 private:
436  SegmentationFunctionType * m_SegmentationFunction{};
437 };
438 } // end namespace itk
439 
440 #ifndef ITK_MANUAL_INSTANTIATION
441 # include "itkNarrowBandLevelSetImageFilter.hxx"
442 #endif
443 
444 #endif
itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType, TInputImage::ImageDimension > >::VectorImageType
typename SegmentationFunctionType::VectorImageType VectorImageType
Definition: itkNarrowBandLevelSetImageFilter.h:172
itk::NarrowBandImageFilterBase
This class implements a multi-threaded finite difference image to image solver that can be applied to...
Definition: itkNarrowBandImageFilterBase.h:70
itk::NarrowBandLevelSetImageFilter::SetMaximumIterations
void SetMaximumIterations(unsigned int i)
Definition: itkNarrowBandLevelSetImageFilter.h:364
itk::NarrowBandLevelSetImageFilter::GetCurvatureScaling
ValueType GetCurvatureScaling() const
Definition: itkNarrowBandLevelSetImageFilter.h:345
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::NarrowBandLevelSetImageFilter
A base class which defines the API for implementing a special class of image segmentation filters usi...
Definition: itkNarrowBandLevelSetImageFilter.h:147
itk::NarrowBandLevelSetImageFilter::SetCurvatureScaling
void SetCurvatureScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:335
itk::NarrowBandLevelSetImageFilter::GetFeatureImage
virtual FeatureImageType * GetFeatureImage()
Definition: itkNarrowBandLevelSetImageFilter.h:188
itk::NarrowBandLevelSetImageFilter::SetUseNegativeFeaturesOff
void SetUseNegativeFeaturesOff()
Definition: itkNarrowBandLevelSetImageFilter.h:226
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::IsoContourDistanceImageFilter
Compute an approximate distance from an interpolated isocontour to the close grid points.
Definition: itkIsoContourDistanceImageFilter.h:59
itk::NarrowBandLevelSetImageFilter::GetMaximumIterations
unsigned int GetMaximumIterations()
Definition: itkNarrowBandLevelSetImageFilter.h:372
itk::NarrowBandLevelSetImageFilter::GetPropagationScaling
ValueType GetPropagationScaling() const
Definition: itkNarrowBandLevelSetImageFilter.h:307
itk::NarrowBandLevelSetImageFilter::SetFeatureImage
virtual void SetFeatureImage(const FeatureImageType *f)
Definition: itkNarrowBandLevelSetImageFilter.h:180
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkSegmentationLevelSetFunction.h
itk::NarrowBandLevelSetImageFilter::GetSegmentationFunction
virtual SegmentationFunctionType * GetSegmentationFunction()
Definition: itkNarrowBandLevelSetImageFilter.h:356
itk::NarrowBandLevelSetImageFilter::SetInitialImage
virtual void SetInitialImage(InputImageType *f)
Definition: itkNarrowBandLevelSetImageFilter.h:196
itk::NarrowBandLevelSetImageFilter::SetPropagationScaling
void SetPropagationScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:297
itk::NarrowBandLevelSetImageFilter::SetFeatureScaling
void SetFeatureScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:281
itk::NarrowBandLevelSetImageFilter::SetUseNegativeFeaturesOn
void SetUseNegativeFeaturesOn()
Definition: itkNarrowBandLevelSetImageFilter.h:217
itkIsoContourDistanceImageFilter.h
itk::NarrowBandLevelSetImageFilter::GetUseNegativeFeatures
bool GetUseNegativeFeatures() const
Definition: itkNarrowBandLevelSetImageFilter.h:251
itk::NarrowBandLevelSetImageFilter::InitializeIteration
void InitializeIteration() override
Definition: itkNarrowBandLevelSetImageFilter.h:401
itk::ImageToImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkFastChamferDistanceImageFilter.h
itk::NarrowBandLevelSetImageFilter::GetSpeedImage
virtual const SegmentationFunctionType::ImageType * GetSpeedImage() const
Definition: itkNarrowBandLevelSetImageFilter.h:202
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
itkNarrowBandImageFilterBase.h
itk::ProcessObject::SetNthInput
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
itk::NarrowBandLevelSetImageFilter::GetAdvectionImage
virtual const SegmentationFunctionType::VectorImageType * GetAdvectionImage() const
Definition: itkNarrowBandLevelSetImageFilter.h:208
itk::SegmentationLevelSetFunction
Definition: itkSegmentationLevelSetFunction.h:47
itk::NarrowBandLevelSetImageFilter::GetAdvectionScaling
ValueType GetAdvectionScaling() const
Definition: itkNarrowBandLevelSetImageFilter.h:325
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::FastChamferDistanceImageFilter
This class compute the signed (positive and negative) chamfer distance in a narrow band.
Definition: itkFastChamferDistanceImageFilter.h:56
itk::NarrowBandLevelSetImageFilter::SetMaximumRMSError
void SetMaximumRMSError(const double) override
Definition: itkNarrowBandLevelSetImageFilter.h:379
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkNarrowBandImageFilterBase.h:105
itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType, TInputImage::ImageDimension > >::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkNarrowBandLevelSetImageFilter.h:166
itkMath.h
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::NarrowBandLevelSetImageFilter::SetUseNegativeFeatures
void SetUseNegativeFeatures(bool u)
Definition: itkNarrowBandLevelSetImageFilter.h:236
itk::NarrowBandLevelSetImageFilter::SetAdvectionScaling
void SetAdvectionScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:315