18 #ifndef __otbLabelObjectOpeningMuParserFilter_txx
19 #define __otbLabelObjectOpeningMuParserFilter_txx
27 #include "itkNumericTraits.h"
34 template<
class TImage,
class TFunction>
38 this->SetNumberOfRequiredOutputs(2);
39 this->SetNthOutput(1, static_cast<TImage*> (this->MakeOutput(1).GetPointer()));
43 template<
class TImage,
class TFunction>
48 template<
class TImage,
class TFunction>
51 Superclass::PrintSelf(os, indent);
52 os << indent <<
"Expression: " << m_Expression << std::endl;
55 template<
class TImage,
class TFunction>
58 if (m_Expression != expression) m_Expression = expression;
59 m_Functor.SetExpression(m_Expression);
63 template<
class TImage,
class TFunction>
69 template<
class TImage,
class TFunction>
72 return this->m_Functor.GetVar();
75 template<
class TImage,
class TFunction>
78 return this->m_Functor.GetFunList();
81 template<
class TImage,
class TFunction>
84 const std::map<std::string, double*>& variables = this->m_Functor.GetVar();
87 std::map<std::string, double*>::const_iterator item = variables.begin();
90 for (; item != variables.end(); ++item)
92 std::cout <<
"Name: " << item->first <<
" Address: [0x" << item->second <<
"]\n";
97 template<
class TImage,
class TFunction>
100 return this->m_Functor.CheckExpression();
103 template<
class TImage,
class TFunction>
105 std::vector<std::string> statAttributes,
108 this->m_Functor.SetAttributes(shapeAttributes, statAttributes, nbOfBands);
112 template<
class TImage,
class TFunction>
116 if (this->GetInPlace() && this->CanRunInPlace())
121 ImagePointer inputAsOutput =
dynamic_cast<TImage *
> (
const_cast<TImage *
> (this->GetInput()));
126 this->GraftOutput(inputAsOutput);
127 this->GetOutput()->SetLargestPossibleRegion(this->GetOutput()->GetLargestPossibleRegion());
128 this->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
129 this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetBufferedRegion());
134 for (
unsigned int i = 1; i < this->GetNumberOfOutputs(); ++i)
138 outputPtr = this->GetOutput(i);
139 outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion());
140 outputPtr->Allocate();
145 Superclass::AllocateOutputs();
152 template<
class TImage,
class TFunction>
158 template<
class TImage,
class TFunction>
164 this->AllocateOutputs();
167 ImageType * output2 = this->GetOutput(1);
168 assert( this->GetNumberOfOutputs() == 2 );
169 assert( output2 !=
NULL );
172 output2->SetBackgroundValue(output->GetBackgroundValue());
174 const typename ImageType::LabelObjectContainerType & labelObjectContainer = output->GetLabelObjectContainer();
178 typename ImageType::LabelObjectContainerType::const_iterator it = labelObjectContainer.begin();
180 while (it != labelObjectContainer.end())
182 typename LabelObjectType::LabelType label = it->first;
185 if (!m_Functor(*labelObject))
189 output2->AddLabelObject(labelObject);
190 output->RemoveLabel(label);