/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelAttributeOpeningImageFilter.txx,v $ Language: C++ Date: $Date: 2006/08/01 19:16:18 $ Version: $Revision: 1.7 $ 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 __itkLabelAttributeOpeningImageFilter_txx #define __itkLabelAttributeOpeningImageFilter_txx #include "itkLabelAttributeOpeningImageFilter.h" #include "itkProgressAccumulator.h" namespace itk { template LabelAttributeOpeningImageFilter ::LabelAttributeOpeningImageFilter() { m_BackgroundValue = NumericTraits::NonpositiveMin(); m_Lambda = NumericTraits< AttributeValueType >::Zero; m_ReverseOrdering = false; } template void LabelAttributeOpeningImageFilter ::GenerateInputRequestedRegion() { // call the superclass' implementation of this method Superclass::GenerateInputRequestedRegion(); // We need all the input. InputImagePointer input = const_cast(this->GetInput()); if( input ) { input->SetRequestedRegion( input->GetLargestPossibleRegion() ); } } template void LabelAttributeOpeningImageFilter ::EnlargeOutputRequestedRegion(DataObject *) { this->GetOutput() ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() ); } template void LabelAttributeOpeningImageFilter ::GenerateData() { // Create a process accumulator for tracking the progress of this minipipeline ProgressAccumulator::Pointer progress = ProgressAccumulator::New(); progress->SetMiniPipelineFilter(this); // Allocate the output this->AllocateOutputs(); typename LabelizerType::Pointer labelizer = LabelizerType::New(); labelizer->SetInput( this->GetInput() ); labelizer->SetBackgroundValue( m_BackgroundValue ); progress->RegisterInternalFilter(labelizer, .3f); typename LabelObjectValuatorType::Pointer valuator = LabelObjectValuatorType::New(); valuator->SetInput( labelizer->GetOutput() ); progress->RegisterInternalFilter(valuator, .3f); typename OpeningType::Pointer opening = OpeningType::New(); opening->SetInput( valuator->GetOutput() ); opening->SetLambda( m_Lambda ); opening->SetReverseOrdering( m_ReverseOrdering ); progress->RegisterInternalFilter(opening, .2f); typename BinarizerType::Pointer binarizer = BinarizerType::New(); binarizer->SetInput( opening->GetOutput() ); progress->RegisterInternalFilter(binarizer, .2f); this->CustomizeInternalFilters( labelizer, valuator, opening, binarizer ); binarizer->GraftOutput( this->GetOutput() ); binarizer->Update(); this->GraftOutput( binarizer->GetOutput() ); } template void LabelAttributeOpeningImageFilter ::PrintSelf(std::ostream &os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "BackgroundValue: " << static_cast::PrintType>(m_BackgroundValue) << std::endl; os << indent << "Lambda: " << static_cast::PrintType>(m_Lambda) << std::endl; os << indent << "ReverseOrdering: " << m_ReverseOrdering << std::endl; } }// end namespace itk #endif