Orfeo Toolbox  3.16
itkDoubleThresholdImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkDoubleThresholdImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2006-08-01 19:16:17 $
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 __itkDoubleThresholdImageFilter_txx
18 #define __itkDoubleThresholdImageFilter_txx
19 
23 #include "itkProgressAccumulator.h"
24 
25 namespace itk {
26 
27 template <class TInputImage, class TOutputImage>
30  : m_NumberOfIterationsUsed( 1 )
31 {
32  m_Threshold1 = NumericTraits<InputPixelType>::NonpositiveMin();
33  m_Threshold2 = NumericTraits<InputPixelType>::NonpositiveMin();
34  m_Threshold3 = NumericTraits<InputPixelType>::max();
35  m_Threshold4 = NumericTraits<InputPixelType>::max();
36 
37  m_OutsideValue = NumericTraits<OutputPixelType>::Zero;
38  m_InsideValue = NumericTraits<OutputPixelType>::max();
39 
40  m_FullyConnected = false;
41 }
42 
43 template <class TInputImage, class TOutputImage>
44 void
47 {
48  // call the superclass' implementation of this method
49  Superclass::GenerateInputRequestedRegion();
50 
51  // We need all the input.
52  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
53  if( input )
54  {
55  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
56  }
57 }
58 
59 
60 template <class TInputImage, class TOutputImage>
61 void
64 {
65  this->GetOutput()
66  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
67 }
68 
69 
70 template<class TInputImage, class TOutputImage>
71 void
74 {
75  // Allocate the output
76  this->AllocateOutputs();
77 
78  // Build a mini-pipeline that involves two thresholds filters and a
79  // geodesic dilation.
82 
83  typename ThresholdFilterType::Pointer narrowThreshold = ThresholdFilterType::New();
84 
85  // Create a process accumulator for tracking the progress of this minipipeline
87  progress->SetMiniPipelineFilter(this);
88 
89 
90  narrowThreshold->SetLowerThreshold( m_Threshold2 );
91  narrowThreshold->SetUpperThreshold( m_Threshold3 );
92  narrowThreshold->SetInsideValue( m_InsideValue );
93  narrowThreshold->SetOutsideValue( m_OutsideValue );
94  narrowThreshold->SetInput( this->GetInput() );
95 
96  typename ThresholdFilterType::Pointer wideThreshold = ThresholdFilterType::New();
97  wideThreshold->SetLowerThreshold( m_Threshold1 );
98  wideThreshold->SetUpperThreshold( m_Threshold4 );
99  wideThreshold->SetInsideValue( m_InsideValue );
100  wideThreshold->SetOutsideValue( m_OutsideValue );
101  wideThreshold->SetInput( this->GetInput() );
102 
103  typename DilationFilterType::Pointer dilate = DilationFilterType::New();
104  dilate->SetMarkerImage( narrowThreshold->GetOutput() );
105  dilate->SetMaskImage( wideThreshold->GetOutput() );
106  dilate->SetFullyConnected( m_FullyConnected );
107  //dilate->RunOneIterationOff(); // run to convergence
108 
109  progress->RegisterInternalFilter(narrowThreshold,.1f);
110  progress->RegisterInternalFilter(wideThreshold,.1f);
111  progress->RegisterInternalFilter(dilate,.8f);
112 
113  // graft our output to the dilate filter to force the proper regions
114  // to be generated
115  dilate->GraftOutput( this->GetOutput() );
116 
117  // reconstruction by dilation
118  dilate->Update();
119 
120  // graft the output of the dilate filter back onto this filter's
121  // output. this is needed to get the appropriate regions passed
122  // back.
123  this->GraftOutput( dilate->GetOutput() );
124 
125 }
126 
127 
128 template<class TInputImage, class TOutputImage>
129 void
131 ::PrintSelf(std::ostream &os, Indent indent) const
132 {
133  Superclass::PrintSelf(os, indent);
134 
135  os << indent << "Threshold1: "
136  << static_cast<typename NumericTraits<InputPixelType>::PrintType>(m_Threshold1)
137  << std::endl;
138  os << indent << "Threshold2: "
139  << static_cast<typename NumericTraits<InputPixelType>::PrintType>(m_Threshold2)
140  << std::endl;
141  os << indent << "Threshold3: "
142  << static_cast<typename NumericTraits<InputPixelType>::PrintType>(m_Threshold3)
143  << std::endl;
144  os << indent << "Threshold4: "
145  << static_cast<typename NumericTraits<InputPixelType>::PrintType>(m_Threshold4)
146  << std::endl;
147  os << indent << "InsideValue: "
148  << static_cast<typename NumericTraits<OutputPixelType>::PrintType>(m_InsideValue)
149  << std::endl;
150  os << indent << "OutsideValue: "
151  << static_cast<typename NumericTraits<OutputPixelType>::PrintType>(m_OutsideValue)
152  << std::endl;
153  os << indent << "Number of iterations used to produce current output: "
154  << m_NumberOfIterationsUsed << std::endl;
155  os << indent << "FullyConnected: " << m_FullyConnected << std::endl;
156 }
157 
158 }// end namespace itk
159 #endif

Generated at Sat Feb 2 2013 23:35:45 for Orfeo Toolbox with doxygen 1.8.1.1