Skip to content
Snippets Groups Projects
Commit 409c7100 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Since the shape label object filter computes the polygon corresponding to...

ENH: Since the shape label object filter computes the polygon corresponding to each label object, an AttributeMapLabelObject is now able to store this polygon for reuse
parent 5a04ebfb
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
#include "itkLabelObject.h"
#include "itkLabelMap.h"
#include "otbPolygon.h"
#include <map>
namespace otb
......@@ -129,6 +130,10 @@ public:
typedef typename AttributesMapType::iterator AttributesMapIteratorType;
typedef typename AttributesMapType::const_iterator AttributesMapConstIteratorType;
// The polygon corresponding to the label object
typedef Polygon<double> PolygonType;
typedef typename PolygonType::Pointer PolygonPointerType;
/**
* Set an attribute value.
* If the key name already exists in the map, the value is overwritten.
......@@ -188,9 +193,27 @@ public:
m_Attributes = src->m_Attributes;
}
/** Return the polygon (const version) */
const PolygonType * GetPolygon() const
{
return m_Polygon;
}
/** Return the polygon (non const version) */
PolygonType * GetPolygon()
{
return m_Polygon;
}
/** Set the polygon */
void SetPolygon(PolygonType* p)
{
m_Polygon = p;
}
protected:
/** Constructor */
AttributesMapLabelObject() : m_Attributes()
AttributesMapLabelObject() : m_Attributes(), m_Polygon(PolygonType::New())
{}
/** Destructor */
virtual ~AttributesMapLabelObject() {}
......@@ -212,6 +235,10 @@ private:
/** The attributes map */
AttributesMapType m_Attributes;
/** The polygon corresponding to the label object. Caution, this
* will be empty by default */
PolygonPointerType m_Polygon;
};
} // end namespace otb
......
......@@ -43,16 +43,16 @@ class ShapeAttributesLabelObjectFunctor
{
public:
/** Self typedef */
typedef ShapeAttributesLabelObjectFunctor Self;
typedef ShapeAttributesLabelObjectFunctor Self;
/** LabelObject typedef */
typedef TLabelObject LabelObjectType;
typedef TLabelObject LabelObjectType;
/** Labeled image type */
typedef TLabelImage LabelImageType;
typedef TLabelImage LabelImageType;
/** Flusser moments typedef */
typedef Polygon<double> PolygonType;
typedef typename TLabelObject::PolygonType PolygonType;
typedef Functor::LabelObjectToPolygonFunctor
<LabelObjectType,PolygonType> PolygonFunctorType;
typedef FlusserPathFunction<PolygonType> FlusserPathFunctionType;
......
......@@ -445,6 +445,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject,TLabelImage>
// Flusser moments
PolygonFunctorType polygonFunctor;
typename PolygonType::Pointer polygon = polygonFunctor(lo);
lo->SetPolygon(polygon);
typename FlusserPathFunctionType::Pointer flusser = FlusserPathFunctionType::New();
flusser->SetInputPath(polygon);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment