20 #ifndef __itkInPlaceLabelMapFilter_txx
21 #define __itkInPlaceLabelMapFilter_txx
32 template <
class TInputImage>
41 template <
class TInputImage>
49 template<
class TInputImage>
54 Superclass::PrintSelf(os, indent);
55 os << indent <<
"InPlace: " << (this->m_InPlace ?
"On" :
"Off") << std::endl;
56 if ( this->CanRunInPlace())
58 os << indent <<
"The input and output to this filter are the same type. The filter can be run in place." << std::endl;
62 os << indent <<
"The input and output to this filter are different types. The filter cannot be run in place." << std::endl;
66 template<
class TInputImage>
72 if( this->m_InPlace && this->CanRunInPlace() )
84 RegionType region = this->GetOutput()->GetLargestPossibleRegion();
85 this->GraftOutput( inputAsOutput );
86 this->GetOutput()->SetRegions( region );
90 for (
unsigned int i=1; i < this->GetNumberOfOutputs(); i++)
94 outputPtr = this->GetOutput(i);
95 outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion());
96 outputPtr->Allocate();
101 Superclass::AllocateOutputs();
103 const TInputImage * input = this->GetInput();
105 assert( input !=
NULL );
106 assert( output !=
NULL );
108 output->SetBackgroundValue( input->GetBackgroundValue() );
115 while( it != labelObjectContainer.end() )
119 assert( labeObject !=
NULL );
120 assert( labeObject->GetLabel() == it->first );
122 typename LabelObjectType::Pointer newLabelObject = LabelObjectType::New();
123 newLabelObject->CopyAllFrom( labeObject );
125 output->AddLabelObject( newLabelObject );
132 template<
class TInputImage>
138 if( this->m_InPlace && (
typeid(TInputImage) ==
typeid(
TOutputImage)) )
145 TInputImage * ptr =
const_cast<TInputImage*
>( this->GetInput() );
153 Superclass::ReleaseInputs();