Orfeo Toolbox  3.16
itkGrayscaleFillholeImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkGrayscaleFillholeImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2006-12-15 21:41:24 $
7  Version: $Revision: 1.10 $
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 __itkGrayscaleFillholeImageFilter_txx
18 #define __itkGrayscaleFillholeImageFilter_txx
19 
20 #include "itkImageRegionIterator.h"
27 #include "itkProgressAccumulator.h"
28 
29 namespace itk {
30 
31 template <class TInputImage, class TOutputImage>
34  : m_NumberOfIterationsUsed( 1 )
35 {
36  m_FullyConnected = false;
37 }
38 
39 template <class TInputImage, class TOutputImage>
40 void
43 {
44  // call the superclass' implementation of this method
45  Superclass::GenerateInputRequestedRegion();
46 
47  // We need all the input.
48  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
49  if( input )
50  {
51  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
52  }
53 }
54 
55 
56 template <class TInputImage, class TOutputImage>
57 void
60 {
61  this->GetOutput()
62  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
63 }
64 
65 
66 template<class TInputImage, class TOutputImage>
67 void
70 {
71  // Allocate the output
72  this->AllocateOutputs();
73 
74  // construct a marker image to manipulate using reconstruction by
75  // erosion. the marker image will have the same pixel values as the
76  // input image on the boundary of the image and will have the
77  // maximum pixel value from the input image for all the pixels in
78  // the interior
79  //
80 
81  // compute the maximum pixel value in the input
84  calculator->SetImage( this->GetInput() );
85  calculator->ComputeMaximum();
86 
87  InputImagePixelType maxValue;
88  maxValue = calculator->GetMaximum();
89 
90  // allocate a marker image
91  InputImagePointer markerPtr = InputImageType::New();
92  markerPtr->SetRegions( this->GetInput()->GetRequestedRegion() );
93  markerPtr->CopyInformation( this->GetInput() );
94  markerPtr->Allocate();
95 
96  // fill the marker image with the maximum value from the input
97  markerPtr->FillBuffer( maxValue );
98 
99  // copy the borders of the input image to the marker image
100  //
102  inputBoundaryIt( this->GetInput(), this->GetInput()->GetRequestedRegion());
103  inputBoundaryIt.SetExclusionRegionToInsetRegion();
104 
106  markerBoundaryIt( markerPtr, this->GetInput()->GetRequestedRegion() );
107  markerBoundaryIt.SetExclusionRegionToInsetRegion();
108 
109  // copy the boundary pixels
110  inputBoundaryIt.GoToBegin();
111  markerBoundaryIt.GoToBegin();
112  while ( !inputBoundaryIt.IsAtEnd() )
113  {
114  markerBoundaryIt.Set( inputBoundaryIt.Get() );
115  ++markerBoundaryIt;
116  ++inputBoundaryIt;
117  }
118 
119 
120  // Delegate to a geodesic erosion filter.
121  //
122  //
124  erode
126 
127  // Create a process accumulator for tracking the progress of this minipipeline
129  progress->SetMiniPipelineFilter(this);
130  progress->RegisterInternalFilter(erode,1.0f);
131 
132  // set up the erode filter
133  //erode->RunOneIterationOff(); // run to convergence
134  erode->SetMarkerImage( markerPtr );
135  erode->SetMaskImage( this->GetInput() );
136  erode->SetFullyConnected( m_FullyConnected );
137 
138  // graft our output to the erode filter to force the proper regions
139  // to be generated
140  erode->GraftOutput( this->GetOutput() );
141 
142  // reconstruction by erosion
143  erode->Update();
144 
145  // graft the output of the erode filter back onto this filter's
146  // output. this is needed to get the appropriate regions passed
147  // back.
148  this->GraftOutput( erode->GetOutput() );
149 }
150 
151 
152 template<class TInputImage, class TOutputImage>
153 void
155 ::PrintSelf(std::ostream &os, Indent indent) const
156 {
157  Superclass::PrintSelf(os, indent);
158 
159  os << indent << "Number of iterations used to produce current output: "
160  << m_NumberOfIterationsUsed << std::endl;
161  os << indent << "FullyConnected: " << m_FullyConnected << std::endl;
162 }
163 
164 }// end namespace itk
165 #endif

Generated at Sat Feb 2 2013 23:40:07 for Orfeo Toolbox with doxygen 1.8.1.1