/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelImageToStatisticsLabelMapFilter.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 __itkLabelImageToStatisticsLabelMapFilter_txx #define __itkLabelImageToStatisticsLabelMapFilter_txx #include "itkLabelImageToStatisticsLabelMapFilter.h" #include "itkProgressAccumulator.h" namespace itk { template LabelImageToStatisticsLabelMapFilter ::LabelImageToStatisticsLabelMapFilter() { m_BackgroundValue = NumericTraits::NonpositiveMin(); m_ComputeFeretDiameter = false; m_ComputePerimeter = false; this->SetNumberOfRequiredInputs(2); } template void LabelImageToStatisticsLabelMapFilter ::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 LabelImageToStatisticsLabelMapFilter ::EnlargeOutputRequestedRegion(DataObject *) { this->GetOutput() ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() ); } template void LabelImageToStatisticsLabelMapFilter ::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 ); labelizer->SetNumberOfThreads( this->GetNumberOfThreads() ); progress->RegisterInternalFilter(labelizer, .5f); typename LabelObjectValuatorType::Pointer valuator = LabelObjectValuatorType::New(); valuator->SetInput( labelizer->GetOutput() ); valuator->SetFeatureImage( this->GetFeatureImage() ); valuator->SetNumberOfThreads( this->GetNumberOfThreads() ); valuator->SetComputePerimeter( m_ComputePerimeter ); valuator->SetComputeFeretDiameter( m_ComputeFeretDiameter ); progress->RegisterInternalFilter(valuator, .5f); valuator->GraftOutput( this->GetOutput() ); valuator->Update(); this->GraftOutput( valuator->GetOutput() ); } template void LabelImageToStatisticsLabelMapFilter ::PrintSelf(std::ostream &os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "BackgroundValue: " << static_cast::PrintType>(m_BackgroundValue) << std::endl; os << indent << "ComputeFeretDiameter: " << m_ComputeFeretDiameter << std::endl; os << indent << "ComputePerimeter: " << m_ComputePerimeter << std::endl; } }// end namespace itk #endif