Orfeo Toolbox  3.16
itkAttributeRelabelImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkAttributeRelabelImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2006/08/01 19:16:18 $
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 __itkAttributeRelabelImageFilter_txx
18 #define __itkAttributeRelabelImageFilter_txx
19 
21 #include "itkProgressAccumulator.h"
22 
23 
24 namespace itk {
25 
26 template<class TInputImage, class TLabelObject, class TLabelObjectValuator, class TAttributeAccessor>
29 {
30  m_BackgroundValue = NumericTraits<OutputImagePixelType>::NonpositiveMin();
31  m_ReverseOrdering = false;
32 }
33 
34 template<class TInputImage, class TLabelObject, class TLabelObjectValuator, class TAttributeAccessor>
35 void
38 {
39  // call the superclass' implementation of this method
40  Superclass::GenerateInputRequestedRegion();
41 
42  // We need all the input.
43  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
44  if( input )
45  {
46  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
47  }
48 }
49 
50 
51 template<class TInputImage, class TLabelObject, class TLabelObjectValuator, class TAttributeAccessor>
52 void
55 {
56  this->GetOutput()
57  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
58 }
59 
60 
61 template<class TInputImage, class TLabelObject, class TLabelObjectValuator, class TAttributeAccessor>
62 void
65 {
66  // Create a process accumulator for tracking the progress of this minipipeline
68  progress->SetMiniPipelineFilter(this);
69 
70  // Allocate the output
71  this->AllocateOutputs();
72 
73  typename LabelizerType::Pointer labelizer = LabelizerType::New();
74  labelizer->SetInput( this->GetInput() );
75  labelizer->SetBackgroundValue( m_BackgroundValue );
76  labelizer->SetNumberOfThreads( this->GetNumberOfThreads() );
77  progress->RegisterInternalFilter(labelizer, .3f);
78 
79  typename LabelObjectValuatorType::Pointer valuator = LabelObjectValuatorType::New();
80  valuator->SetInput( labelizer->GetOutput() );
81  valuator->SetNumberOfThreads( this->GetNumberOfThreads() );
82  progress->RegisterInternalFilter(valuator, .3f);
83 
84  typename RelabelType::Pointer opening = RelabelType::New();
85  opening->SetInput( valuator->GetOutput() );
86  opening->SetReverseOrdering( m_ReverseOrdering );
87  opening->SetNumberOfThreads( this->GetNumberOfThreads() );
88  progress->RegisterInternalFilter(opening, .2f);
89 
90  typename BinarizerType::Pointer binarizer = BinarizerType::New();
91  binarizer->SetInput( opening->GetOutput() );
92  binarizer->SetNumberOfThreads( this->GetNumberOfThreads() );
93  progress->RegisterInternalFilter(binarizer, .2f);
94 
95  this->CustomizeInternalFilters( labelizer, valuator, opening, binarizer );
96 
97  binarizer->GraftOutput( this->GetOutput() );
98  binarizer->Update();
99  this->GraftOutput( binarizer->GetOutput() );
100 }
101 
102 
103 template<class TInputImage, class TLabelObject, class TLabelObjectValuator, class TAttributeAccessor>
104 void
106 ::PrintSelf(std::ostream &os, Indent indent) const
107 {
108  Superclass::PrintSelf(os, indent);
109 
110  os << indent << "ReverseOrdering: " << m_ReverseOrdering << std::endl;
111  os << indent << "BackgroundValue: " << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_BackgroundValue) << std::endl;
112 }
113 
114 }// end namespace itk
115 #endif

Generated at Sat Feb 2 2013 23:24:31 for Orfeo Toolbox with doxygen 1.8.1.1