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  else
260  {
261  return false;
262  }
263  }
264 
273  itkSetMacro(ReverseExpansionDirection, bool);
274  itkGetConstMacro(ReverseExpansionDirection, bool);
275  itkBooleanMacro(ReverseExpansionDirection);
282  void
284  {
285  if (v != m_SegmentationFunction->GetPropagationWeight())
286  {
287  this->SetPropagationScaling(v);
288  }
289  if (v != m_SegmentationFunction->GetAdvectionWeight())
290  {
291  this->SetAdvectionScaling(v);
292  }
293  }
298  void
300  {
301  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
302  {
303  m_SegmentationFunction->SetPropagationWeight(v);
304  }
305  }
308  ValueType
310  {
311  return m_SegmentationFunction->GetPropagationWeight();
312  }
313 
316  void
318  {
319  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
320  {
321  m_SegmentationFunction->SetAdvectionWeight(v);
322  }
323  }
326  ValueType
328  {
329  return m_SegmentationFunction->GetAdvectionWeight();
330  }
331 
336  void
338  {
339  if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
340  {
341  m_SegmentationFunction->SetCurvatureWeight(v);
342  }
343  }
346  ValueType
348  {
349  return m_SegmentationFunction->GetCurvatureWeight();
350  }
351 
354  virtual void
355  SetSegmentationFunction(SegmentationFunctionType * s);
356 
357  virtual SegmentationFunctionType *
359  {
360  return m_SegmentationFunction;
361  }
362 
365  void
366  SetMaximumIterations(unsigned int i)
367  {
368  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
369  this->SetNumberOfIterations(i);
370  }
373  unsigned int
375  {
376  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
377  return this->GetNumberOfIterations();
378  }
379 
380  void
381  SetMaximumRMSError(const double) override
382  {
383  itkWarningMacro("The current implementation of this solver does not compute maximum RMS change. The maximum RMS "
384  "error value will not be set or used.");
385  }
386 
387 #ifdef ITK_USE_CONCEPT_CHECKING
388  // Begin concept checking
390  // End concept checking
391 #endif
392 
393 protected:
394  ~NarrowBandLevelSetImageFilter() override = default;
396 
397  void
398  PrintSelf(std::ostream & os, Indent indent) const override;
399 
400 
402  void
404  {
405  Superclass::InitializeIteration();
406  // Estimate the progress of the filter
407  this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
408  static_cast<float>(this->GetNumberOfIterations()));
409  }
415  void
416  CreateNarrowBand() override;
417 
420  void
421  GenerateData() override;
422 
425  bool m_ReverseExpansionDirection{};
426 
432 
433  typename IsoFilterType::Pointer m_IsoFilter{};
434 
435  typename ChamferFilterType::Pointer m_ChamferFilter{};
436 
437 private:
438  SegmentationFunctionType * m_SegmentationFunction{};
439 };
440 } // end namespace itk
441 
442 #ifndef ITK_MANUAL_INSTANTIATION
443 # include "itkNarrowBandLevelSetImageFilter.hxx"
444 #endif
445 
446 #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:366
itk::NarrowBandLevelSetImageFilter::GetCurvatureScaling
ValueType GetCurvatureScaling() const
Definition: itkNarrowBandLevelSetImageFilter.h:347
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:337
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:374
itk::NarrowBandLevelSetImageFilter::GetPropagationScaling
ValueType GetPropagationScaling() const
Definition: itkNarrowBandLevelSetImageFilter.h:309
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:358
itk::NarrowBandLevelSetImageFilter::SetInitialImage
virtual void SetInitialImage(InputImageType *f)
Definition: itkNarrowBandLevelSetImageFilter.h:196
itk::NarrowBandLevelSetImageFilter::SetPropagationScaling
void SetPropagationScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:299
itk::NarrowBandLevelSetImageFilter::SetFeatureScaling
void SetFeatureScaling(ValueType v)
Definition: itkNarrowBandLevelSetImageFilter.h:283
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:403
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:327
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:381
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:317