17 #ifndef __itkDoubleThresholdImageFilter_txx
18 #define __itkDoubleThresholdImageFilter_txx
27 template <
class TInputImage,
class TOutputImage>
30 : m_NumberOfIterationsUsed( 1 )
32 m_Threshold1 = NumericTraits<InputPixelType>::NonpositiveMin();
33 m_Threshold2 = NumericTraits<InputPixelType>::NonpositiveMin();
34 m_Threshold3 = NumericTraits<InputPixelType>::max();
35 m_Threshold4 = NumericTraits<InputPixelType>::max();
37 m_OutsideValue = NumericTraits<OutputPixelType>::Zero;
38 m_InsideValue = NumericTraits<OutputPixelType>::max();
40 m_FullyConnected =
false;
43 template <
class TInputImage,
class TOutputImage>
49 Superclass::GenerateInputRequestedRegion();
55 input->SetRequestedRegion( input->GetLargestPossibleRegion() );
60 template <
class TInputImage,
class TOutputImage>
66 ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
70 template<
class TInputImage,
class TOutputImage>
76 this->AllocateOutputs();
83 typename ThresholdFilterType::Pointer narrowThreshold = ThresholdFilterType::New();
87 progress->SetMiniPipelineFilter(
this);
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() );
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() );
103 typename DilationFilterType::Pointer dilate = DilationFilterType::New();
104 dilate->SetMarkerImage( narrowThreshold->GetOutput() );
105 dilate->SetMaskImage( wideThreshold->GetOutput() );
106 dilate->SetFullyConnected( m_FullyConnected );
109 progress->RegisterInternalFilter(narrowThreshold,.1f);
110 progress->RegisterInternalFilter(wideThreshold,.1f);
111 progress->RegisterInternalFilter(dilate,.8f);
115 dilate->GraftOutput( this->GetOutput() );
123 this->GraftOutput( dilate->GetOutput() );
128 template<
class TInputImage,
class TOutputImage>
133 Superclass::PrintSelf(os, indent);
135 os << indent <<
"Threshold1: "
136 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>(m_Threshold1)
138 os << indent <<
"Threshold2: "
139 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>(m_Threshold2)
141 os << indent <<
"Threshold3: "
142 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>(m_Threshold3)
144 os << indent <<
"Threshold4: "
145 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>(m_Threshold4)
147 os << indent <<
"InsideValue: "
148 <<
static_cast<typename NumericTraits<OutputPixelType>::PrintType
>(m_InsideValue)
150 os << indent <<
"OutsideValue: "
151 <<
static_cast<typename NumericTraits<OutputPixelType>::PrintType
>(m_OutsideValue)
153 os << indent <<
"Number of iterations used to produce current output: "
154 << m_NumberOfIterationsUsed << std::endl;
155 os << indent <<
"FullyConnected: " << m_FullyConnected << std::endl;