21 #ifndef otbSpatialisationFilter_hxx
22 #define otbSpatialisationFilter_hxx
24 #include "itkNumericTraits.h"
31 template <
class TLabelMap>
38 template <
class TLabelMap>
42 if (m_AreaVector.size() != (m_NumberOfObjects[0] * m_NumberOfObjects[1]))
44 itkExceptionMacro(<<
"Size problem : AreaVector size must be equal to " << m_NumberOfObjects[0] * m_NumberOfObjects[1]);
46 if (m_PathVector.size() != (m_NumberOfObjects[0] * m_NumberOfObjects[1]))
48 itkExceptionMacro(<<
"Size problem : PathVector size must be equal to " << m_NumberOfObjects[0] * m_NumberOfObjects[1]);
50 if (m_Labels.size() != (m_NumberOfObjects[0] * m_NumberOfObjects[1]))
52 itkExceptionMacro(<<
"Size problem : Labels size must be equal to " << m_NumberOfObjects[0] * m_NumberOfObjects[1]);
55 unsigned int numberOfObjects = m_NumberOfObjects[0] * m_NumberOfObjects[1];
57 for (
unsigned int i = 0; i < numberOfObjects; ++i)
59 this->ProcessObject(i);
63 template <
class TLabelMap>
68 startIndex[1] =
static_cast<unsigned int>(((obj) / m_NumberOfObjects[0]) * m_ObjectSize[1]);
69 startIndex[0] =
static_cast<unsigned int>(((obj) % m_NumberOfObjects[0]) * m_ObjectSize[0]);
71 for (
unsigned int col = startIndex[0]; col < startIndex[0] + m_ObjectSize[0]; col++)
73 for (
unsigned int line = startIndex[1]; line < startIndex[1] + m_ObjectSize[1]; line++)
77 this->GetOutput()->AddPixel(index, m_Labels[obj]);
80 this->GetOutput()->GetLabelObject(m_Labels[obj])->SetAttribute(
"area", m_AreaVector[obj]);
81 if (m_PathVector[obj] !=
"")
82 this->GetOutput()->GetLabelObject(m_Labels[obj])->SetAttribute(
"path", m_PathVector[obj]);
85 template <
class TLabelMap>
89 Superclass::GenerateOutputInformation();
95 size[0] = m_ObjectSize[0] * m_NumberOfObjects[0];
96 size[1] = m_ObjectSize[1] * m_NumberOfObjects[1];
98 region.SetIndex(index);
106 this->GetOutput()->SetLargestPossibleRegion(region);
110 template <
class TLabelMap>
113 Superclass::PrintSelf(os, indent);