ITK  4.13.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 
158 
160  typedef typename Superclass::ValueType ValueType;
162  typedef typename Superclass::TimeStepType TimeStepType;
163  typedef typename Superclass::InputImageType InputImageType;
164 
166  typedef TOutputImage OutputImageType;
167  typedef TFeatureImage FeatureImageType;
168 
172 
175 
178 
181  virtual void SetFeatureImage(const FeatureImageType *f)
182  {
183  this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >( f ) );
184  m_SegmentationFunction->SetFeatureImage(f);
185  }
187 
189  {
190  return ( static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) ) );
191  }
192 
196  {
197  this->SetInput(f);
198  }
199 
200  virtual const typename SegmentationFunctionType::ImageType * GetSpeedImage() const
201  { return m_SegmentationFunction->GetSpeedImage(); }
202 
204  { return m_SegmentationFunction->GetAdvectionImage(); }
205 
210  {
211  itkWarningMacro(
212  << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
213  this->ReverseExpansionDirectionOn();
214  }
216 
218  {
219  itkWarningMacro(
220  << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
221  this->ReverseExpansionDirectionOff();
222  }
223 
227  {
228  itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
229  if ( u == true )
230  {
231  this->SetReverseExpansionDirection(false);
232  }
233  else
234  {
235  this->SetReverseExpansionDirection(true);
236  }
237  }
239 
241  {
242  itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
243  if ( this->GetReverseExpansionDirection() == false )
244  {
245  return true;
246  }
247  else
248  {
249  return false;
250  }
251  }
252 
261  itkSetMacro(ReverseExpansionDirection, bool);
262  itkGetConstMacro(ReverseExpansionDirection, bool);
263  itkBooleanMacro(ReverseExpansionDirection);
265 
271  {
272  if ( v != m_SegmentationFunction->GetPropagationWeight() )
273  {
274  this->SetPropagationScaling(v);
275  }
276  if ( v != m_SegmentationFunction->GetAdvectionWeight() )
277  {
278  this->SetAdvectionScaling(v);
279  }
280  }
282 
286  {
287  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()) )
288  {
289  m_SegmentationFunction->SetPropagationWeight(v);
290  }
291  }
293 
295  {
296  return m_SegmentationFunction->GetPropagationWeight();
297  }
298 
302  {
303  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()) )
304  {
305  m_SegmentationFunction->SetAdvectionWeight(v);
306  }
307  }
309 
311  {
312  return m_SegmentationFunction->GetAdvectionWeight();
313  }
314 
320  {
321  if ( Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()) )
322  {
323  m_SegmentationFunction->SetCurvatureWeight(v);
324  }
325  }
327 
329  {
330  return m_SegmentationFunction->GetCurvatureWeight();
331  }
332 
335  virtual void SetSegmentationFunction(SegmentationFunctionType *s);
336 
338  { return m_SegmentationFunction; }
339 
342  void SetMaximumIterations(unsigned int i)
343  {
344  itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
345  this->SetNumberOfIterations(i);
346  }
348 
349  unsigned int GetMaximumIterations()
350  {
351  itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
352  return this->GetNumberOfIterations();
353  }
354 
355  virtual void SetMaximumRMSError(const double) ITK_OVERRIDE
356  {
357  itkWarningMacro(
358  "The current implmentation of this solver does not compute maximum RMS change. The maximum RMS error value will not be set or used.");
359  }
360 
361 #ifdef ITK_USE_CONCEPT_CHECKING
362  // Begin concept checking
363  itkConceptMacro( OutputHasNumericTraitsCheck,
365  // End concept checking
366 #endif
367 
368 protected:
369  virtual ~NarrowBandLevelSetImageFilter() ITK_OVERRIDE {}
371 
372  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
373 
374 
376  virtual void InitializeIteration() ITK_OVERRIDE
377  {
378  Superclass::InitializeIteration();
379  // Estimate the progress of the filter
380  this->UpdateProgress( (float)( (float)this->GetElapsedIterations()
381  / (float)this->GetNumberOfIterations() ) );
382  }
384 
388  virtual void CreateNarrowBand() ITK_OVERRIDE;
389 
392  void GenerateData() ITK_OVERRIDE;
393 
396  bool m_ReverseExpansionDirection;
397 
401  typedef IsoContourDistanceImageFilter< OutputImageType, OutputImageType >
403  typedef FastChamferDistanceImageFilter< OutputImageType, OutputImageType >
405 
406  typename IsoFilterType::Pointer m_IsoFilter;
407 
408  typename ChamferFilterType::Pointer m_ChamferFilter;
409 
410 private:
411  ITK_DISALLOW_COPY_AND_ASSIGN(NarrowBandLevelSetImageFilter);
412 
413  SegmentationFunctionType *m_SegmentationFunction;
414 };
415 } // end namespace itk
416 
417 #ifndef ITK_MANUAL_INSTANTIATION
418 #include "itkNarrowBandLevelSetImageFilter.hxx"
419 #endif
420 
421 #endif
virtual void SetMaximumRMSError(const double) override
virtual const SegmentationFunctionType::VectorImageType * GetAdvectionImage() const
Compute an approximate distance from an interpolated isocontour to the close grid points...
SegmentationFunctionType::VectorImageType VectorImageType
SegmentationLevelSetFunction< OutputImageType, FeatureImageType > SegmentationFunctionType
virtual const SegmentationFunctionType::ImageType * GetSpeedImage() const
This class compute the signed (positive and negative) chamfer distance in a narrow band...
NarrowBandImageFilterBase< TInputImage, TOutputImage > Superclass
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:721
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()