Orfeo Toolbox  3.16
itkVotingBinaryIterativeHoleFillingImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkVotingBinaryIterativeHoleFillingImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-17 20:50:03 $
7  Version: $Revision: 1.7 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkVotingBinaryIterativeHoleFillingImageFilter_txx
18 #define __itkVotingBinaryIterativeHoleFillingImageFilter_txx
20 
23 #include "itkImageRegionIterator.h"
26 #include "itkOffset.h"
27 #include "itkProgressReporter.h"
28 
29 #include <vector>
30 #include <algorithm>
31 
32 namespace itk
33 {
34 
35 template <class TInputImage >
38 {
39  m_Radius.Fill(1);
40  m_ForegroundValue = NumericTraits<InputPixelType>::max();
41  m_BackgroundValue = NumericTraits<InputPixelType>::Zero;
42  m_MaximumNumberOfIterations = 10;
43  m_CurrentNumberOfIterations = 0;
44  m_MajorityThreshold = 1;
45  m_NumberOfPixelsChanged = 0;
46 }
47 
48 
49 template< class TInputImage >
50 void
53 {
54 
55  typename InputImageType::ConstPointer input = this->GetInput();
56 
57  m_NumberOfPixelsChanged = 0;
58 
59  typename VotingFilterType::Pointer filter = VotingFilterType::New();
60 
61 
62  filter->SetRadius( this->GetRadius() );
63  filter->SetBackgroundValue( this->GetBackgroundValue() );
64  filter->SetForegroundValue( this->GetForegroundValue() );
65  filter->SetMajorityThreshold( this->GetMajorityThreshold() );
66 
67  m_CurrentNumberOfIterations = 0;
68 
69  typename OutputImageType::Pointer output;
70 
71  ProgressReporter progress(this, 0, m_MaximumNumberOfIterations);
72 
73  while ( m_CurrentNumberOfIterations < m_MaximumNumberOfIterations )
74  {
75  filter->SetInput( input );
76  filter->Update();
77 
78  m_CurrentNumberOfIterations++;
79  progress.CompletedPixel(); // not really a pixel but an iteration
80  this->InvokeEvent( IterationEvent() );
81 
82  const unsigned int numberOfPixelsChangedInThisIteration =
83  filter->GetNumberOfPixelsChanged();
84  m_NumberOfPixelsChanged += numberOfPixelsChangedInThisIteration;
85 
86  output = filter->GetOutput();
87  output->DisconnectPipeline();
88  input = output;
89  if( numberOfPixelsChangedInThisIteration == 0 )
90  {
91  break;
92  }
93  }
94  this->GraftOutput( output );
95 }
96 
100 template <class TInputImage >
101 void
104  std::ostream& os,
105  Indent indent) const
106 {
107  Superclass::PrintSelf( os, indent );
108  os << indent << "Radius: " << m_Radius << std::endl;
109  os << indent << "Foreground value : "
110  << static_cast<typename NumericTraits<InputPixelType>::PrintType>( m_ForegroundValue )<< std::endl;
111  os << indent << "Background value : "
112  << static_cast<typename NumericTraits<InputPixelType>::PrintType>( m_BackgroundValue ) << std::endl;
113  os << indent << "Maximum Number of Iterations : " << m_MaximumNumberOfIterations << std::endl;
114  os << indent << "Current Number of Iterations : " << m_CurrentNumberOfIterations << std::endl;
115  os << indent << "Majority Threshold : " << m_MajorityThreshold << std::endl;
116  os << indent << "Number of Pixels Changed : " << m_NumberOfPixelsChanged << std::endl;
117 }
118 
119 } // end namespace itk
120 
121 #endif

Generated at Sun Feb 3 2013 00:14:13 for Orfeo Toolbox with doxygen 1.8.1.1