ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkNarrowBandLevelSetImageFilter.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 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,
147  TInputImage::ImageDimension > >
148 class ITK_TEMPLATE_EXPORT NarrowBandLevelSetImageFilter:
149  public NarrowBandImageFilterBase< TInputImage, TOutputImage >
150 {
151 public:
152  ITK_DISALLOW_COPY_AND_ASSIGN(NarrowBandLevelSetImageFilter);
153 
159 
161  using ValueType = typename Superclass::ValueType;
163  using TimeStepType = typename Superclass::TimeStepType;
164  using InputImageType = typename Superclass::InputImageType;
165 
167  using OutputImageType = TOutputImage;
168  using FeatureImageType = TFeatureImage;
169 
173 
176 
179 
182  virtual void SetFeatureImage(const FeatureImageType *f)
183  {
184  this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >( f ) );
185  m_SegmentationFunction->SetFeatureImage(f);
186  }
188 
190  {
191  return ( static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) ) );
192  }
193 
197  {
198  this->SetInput(f);
199  }
200 
201  virtual const typename SegmentationFunctionType::ImageType * GetSpeedImage() const
202  { return m_SegmentationFunction->GetSpeedImage(); }
203 
205  { return m_SegmentationFunction->GetAdvectionImage(); }
206 
211  {
212  itkWarningMacro(
213  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
214  this->ReverseExpansionDirectionOn();
215  }
217 
219  {
220  itkWarningMacro(
221  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
222  this->ReverseExpansionDirectionOff();
223  }
224 
228  {
229  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
230  if ( u == true )
231  {
232  this->SetReverseExpansionDirection(false);
233  }
234  else
235  {
236  this->SetReverseExpansionDirection(true);
237  }
238  }
240 
242  {
243  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
244  if ( this->GetReverseExpansionDirection() == false )
245  {
246  return true;
247  }
248  else
249  {
250  return false;
251  }
252  }
253 
262  itkSetMacro(ReverseExpansionDirection, bool);
263  itkGetConstMacro(ReverseExpansionDirection, bool);
264  itkBooleanMacro(ReverseExpansionDirection);
266 
272  {
273  if ( v != m_SegmentationFunction->GetPropagationWeight() )
274  {
275  this->SetPropagationScaling(v);
276  }
277  if ( v != m_SegmentationFunction->GetAdvectionWeight() )
278  {
279  this->SetAdvectionScaling(v);
280  }
281  }
283 
287  {
288  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
289  {
290  m_SegmentationFunction->SetPropagationWeight(v);
291  }
292  }
294 
296  {
297  return m_SegmentationFunction->GetPropagationWeight();
298  }
299 
303  {
304  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
305  {
306  m_SegmentationFunction->SetAdvectionWeight(v);
307  }
308  }
310 
312  {
313  return m_SegmentationFunction->GetAdvectionWeight();
314  }
315 
321  {
322  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()) )
323  {
324  m_SegmentationFunction->SetCurvatureWeight(v);
325  }
326  }
328 
330  {
331  return m_SegmentationFunction->GetCurvatureWeight();
332  }
333 
336  virtual void SetSegmentationFunction(SegmentationFunctionType *s);
337 
339  { return m_SegmentationFunction; }
340 
343  void SetMaximumIterations(unsigned int i)
344  {
345  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
346  this->SetNumberOfIterations(i);
347  }
349 
350  unsigned int GetMaximumIterations()
351  {
352  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
353  return this->GetNumberOfIterations();
354  }
355 
356  void SetMaximumRMSError(const double) override
357  {
358  itkWarningMacro(
359  "The current implmentation of this solver does not compute maximum RMS change. The maximum RMS error value will not be set or used.");
360  }
361 
362 #ifdef ITK_USE_CONCEPT_CHECKING
363  // Begin concept checking
364  itkConceptMacro( OutputHasNumericTraitsCheck,
366  // End concept checking
367 #endif
368 
369 protected:
370  ~NarrowBandLevelSetImageFilter() override = default;
372 
373  void PrintSelf(std::ostream & os, Indent indent) const override;
374 
375 
377  void InitializeIteration() override
378  {
379  Superclass::InitializeIteration();
380  // Estimate the progress of the filter
381  this->UpdateProgress( (float)( (float)this->GetElapsedIterations()
382  / (float)this->GetNumberOfIterations() ) );
383  }
385 
389  void CreateNarrowBand() override;
390 
393  void GenerateData() override;
394 
398 
402  using IsoFilterType =
404  using ChamferFilterType =
406 
408 
410 
411 private:
413 };
414 } // end namespace itk
415 
416 #ifndef ITK_MANUAL_INSTANTIATION
417 #include "itkNarrowBandLevelSetImageFilter.hxx"
418 #endif
419 
420 #endif
virtual const SegmentationFunctionType::VectorImageType * GetAdvectionImage() const
Light weight base class for most itk classes.
Compute an approximate distance from an interpolated isocontour to the close grid points...
virtual const SegmentationFunctionType::ImageType * GetSpeedImage() const
This class compute the signed (positive and negative) chamfer distance in a narrow band...
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
virtual void SetFeatureImage(const FeatureImageType *f)
This class implements a multi-threaded finite difference image to image solver that can be applied to...
A base class which defines the API for implementing a special class of image segmentation filters usi...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
#define itkConceptMacro(name, concept)
Templated n-dimensional image class.
Definition: itkImage.h:75
virtual SegmentationFunctionType * GetSegmentationFunction()