/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkKappaSigmaThresholdImageFilter.txx,v $ Language: C++ Date: $Date: 2006/03/15 01:57:09 $ Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itkKappaSigmaThresholdImageFilter_txx #define _itkKappaSigmaThresholdImageFilter_txx #include "itkKappaSigmaThresholdImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkProgressAccumulator.h" namespace itk { template KappaSigmaThresholdImageFilter ::KappaSigmaThresholdImageFilter() { m_OutsideValue = NumericTraits::Zero; m_InsideValue = NumericTraits::max(); m_Threshold = NumericTraits::Zero; m_SigmaFactor = 2; m_NumberOfIterations = 2; m_MaskValue = NumericTraits::max(); } template void KappaSigmaThresholdImageFilter ::GenerateData() { typename ProgressAccumulator::Pointer progress = ProgressAccumulator::New(); progress->SetMiniPipelineFilter(this); // Compute the Threshold for the input image typename CalculatorType::Pointer thresholdCalculator = CalculatorType::New(); thresholdCalculator->SetInput( this->GetInput() ); thresholdCalculator->SetMask( this->GetMaskImage() ); thresholdCalculator->SetMaskValue( m_MaskValue ); thresholdCalculator->SetSigmaFactor( m_SigmaFactor ); thresholdCalculator->SetNumberOfIterations( m_NumberOfIterations ); thresholdCalculator->Compute(); m_Threshold = thresholdCalculator->GetOutput(); typename BinaryThresholdImageFilter::Pointer threshold = BinaryThresholdImageFilter::New();; progress->RegisterInternalFilter(threshold,.5f); threshold->GraftOutput (this->GetOutput()); threshold->SetInput (this->GetInput()); threshold->SetLowerThreshold( m_Threshold ); threshold->SetInsideValue (m_InsideValue); threshold->SetOutsideValue (m_OutsideValue); threshold->Update(); this->GraftOutput(threshold->GetOutput()); } template void KappaSigmaThresholdImageFilter ::GenerateInputRequestedRegion() { const_cast(this->GetInput())->SetRequestedRegionToLargestPossibleRegion(); } template void KappaSigmaThresholdImageFilter ::PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf(os,indent); os << indent << "Threshold: " << static_cast::PrintType>(m_Threshold) << std::endl; os << indent << "MaskValue: " << static_cast::PrintType>(m_MaskValue) << std::endl; os << indent << "SigmaFactor: " << m_SigmaFactor << std::endl; os << indent << "NumberOfIterations: " << m_NumberOfIterations << std::endl; } }// end namespace itk #endif