Skip to content
Snippets Groups Projects
Commit d7d97435 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: modify HooverInstanceFilter to avoid segfault at plugin unloading with gcc>=45

parent ca84f7cb
No related branches found
No related tags found
No related merge requests found
...@@ -230,17 +230,17 @@ private: ...@@ -230,17 +230,17 @@ private:
m_AttributeImageGT = AttributeImageFilterType::New(); m_AttributeImageGT = AttributeImageFilterType::New();
m_AttributeImageGT->SetInput(m_InstanceFilter->GetOutputGroundTruthLabelMap()); m_AttributeImageGT->SetInput(m_InstanceFilter->GetOutputGroundTruthLabelMap());
m_AttributeImageGT->SetAttributeForNthChannel(0, m_InstanceFilter->ATTRIBUTE_RC.c_str()); m_AttributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC));
m_AttributeImageGT->SetAttributeForNthChannel(1, m_InstanceFilter->ATTRIBUTE_RF.c_str()); m_AttributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF));
m_AttributeImageGT->SetAttributeForNthChannel(2, m_InstanceFilter->ATTRIBUTE_RA.c_str()); m_AttributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA));
m_AttributeImageGT->SetAttributeForNthChannel(3, m_InstanceFilter->ATTRIBUTE_RM.c_str()); m_AttributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM));
m_AttributeImageMS = AttributeImageFilterType::New(); m_AttributeImageMS = AttributeImageFilterType::New();
m_AttributeImageMS->SetInput(m_InstanceFilter->GetOutputMachineSegmentationLabelMap()); m_AttributeImageMS->SetInput(m_InstanceFilter->GetOutputMachineSegmentationLabelMap());
m_AttributeImageMS->SetAttributeForNthChannel(0, m_InstanceFilter->ATTRIBUTE_RC.c_str()); m_AttributeImageMS->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC));
m_AttributeImageMS->SetAttributeForNthChannel(1, m_InstanceFilter->ATTRIBUTE_RF.c_str()); m_AttributeImageMS->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF));
m_AttributeImageMS->SetAttributeForNthChannel(2, m_InstanceFilter->ATTRIBUTE_RA.c_str()); m_AttributeImageMS->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA));
//m_AttributeImageMS->SetAttributeForNthChannel(3, m_InstanceFilter->ATTRIBUTE_RN.c_str()); //m_AttributeImageMS->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RN);
m_GTColorFilter = HooverColorFilterType::New(); m_GTColorFilter = HooverColorFilterType::New();
m_GTColorFilter->SetInput(m_AttributeImageGT->GetOutput()); m_GTColorFilter->SetInput(m_AttributeImageGT->GetOutput());
...@@ -296,7 +296,6 @@ private: ...@@ -296,7 +296,6 @@ private:
SetParameterFloat("rf", m_InstanceFilter->GetMeanRF()); SetParameterFloat("rf", m_InstanceFilter->GetMeanRF());
SetParameterFloat("ra", m_InstanceFilter->GetMeanRA()); SetParameterFloat("ra", m_InstanceFilter->GetMeanRA());
SetParameterFloat("rm", m_InstanceFilter->GetMeanRM()); SetParameterFloat("rm", m_InstanceFilter->GetMeanRM());
} }
ImageToLabelMapFilterType::Pointer m_GTFilter; ImageToLabelMapFilterType::Pointer m_GTFilter;
......
...@@ -203,6 +203,15 @@ public: ...@@ -203,6 +203,15 @@ public:
m_Attributes[name] = value; m_Attributes[name] = value;
} }
/**
* Set an attribute value.
* If the key name already exists in the map, the value is overwritten.
*/
void SetAttribute(const std::string& name, AttributesValueType value)
{
this->SetAttribute(name.c_str(), value);
}
/** /**
* Returns the attribute corresponding to name * Returns the attribute corresponding to name
*/ */
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#ifndef __otbHooverInstanceFilter_h #ifndef __otbHooverInstanceFilter_h
#define __otbHooverInstanceFilter_h #define __otbHooverInstanceFilter_h
#include <set>
#include "itkInPlaceLabelMapFilter.h" #include "itkInPlaceLabelMapFilter.h"
#include "itkVariableSizeMatrix.h" #include "itkVariableSizeMatrix.h"
#include "itkVariableLengthVector.h" #include "itkVariableLengthVector.h"
#include <set>
namespace otb namespace otb
{ {
...@@ -58,7 +58,7 @@ namespace otb ...@@ -58,7 +58,7 @@ namespace otb
* *
* These attributes are handled in a different way than the Hoover scores. The simple presence of an extended attribute in a given region has a * These attributes are handled in a different way than the Hoover scores. The simple presence of an extended attribute in a given region has a
* meaning, regardless of its value. It is assumed that its value always corresponds to an existing region label. This is why these extended * meaning, regardless of its value. It is assumed that its value always corresponds to an existing region label. This is why these extended
* attributes are not reseted but removed before computing Hoover instances. * attributes are not reset but removed before computing Hoover instances.
* (see Hoover et al., "An experimental comparison of range image segmentation algorithms", IEEE PAMI vol. 18, no. 7, July 1996) * (see Hoover et al., "An experimental comparison of range image segmentation algorithms", IEEE PAMI vol. 18, no. 7, July 1996)
* *
* \sa HooverMatrixFilter * \sa HooverMatrixFilter
...@@ -86,6 +86,7 @@ public: ...@@ -86,6 +86,7 @@ public:
typedef typename LabelMapType::LabelObjectContainerType LabelObjectContainerType; typedef typename LabelMapType::LabelObjectContainerType LabelObjectContainerType;
typedef typename LabelObjectContainerType::const_iterator LabelObjectContainerTypeConstIterator; typedef typename LabelObjectContainerType::const_iterator LabelObjectContainerTypeConstIterator;
typedef typename LabelMapType::LabelObjectType LabelObjectType; typedef typename LabelMapType::LabelObjectType LabelObjectType;
typedef typename LabelObjectType::AttributeType AttributeType;
typedef typename LabelObjectType::AttributesValueType AttributesValueType; typedef typename LabelObjectType::AttributesValueType AttributesValueType;
typedef typename LabelMapType::LabelVectorType LabelVectorType; typedef typename LabelMapType::LabelVectorType LabelVectorType;
typedef typename LabelMapType::RegionType ImageRegionType; typedef typename LabelMapType::RegionType ImageRegionType;
...@@ -126,35 +127,79 @@ public: ...@@ -126,35 +127,79 @@ public:
itkGetMacro(MeanRM, AttributesValueType); itkGetMacro(MeanRM, AttributesValueType);
itkGetMacro(MeanRN, AttributesValueType); itkGetMacro(MeanRN, AttributesValueType);
/** Attribute name for correct detection */ itkStaticConstMacro(ATTRIBUTE_CD, AttributeType, 100);
static const std::string ATTRIBUTE_CD; itkStaticConstMacro(ATTRIBUTE_OS, AttributeType, 101);
itkStaticConstMacro(ATTRIBUTE_US, AttributeType, 102);
/** Attribute name for over segmentation */ itkStaticConstMacro(ATTRIBUTE_M, AttributeType, 103);
static const std::string ATTRIBUTE_OS; itkStaticConstMacro(ATTRIBUTE_N, AttributeType, 104);
itkStaticConstMacro(ATTRIBUTE_RC, AttributeType, 105);
/** Attribute name for under segmentation */ itkStaticConstMacro(ATTRIBUTE_RF, AttributeType, 106);
static const std::string ATTRIBUTE_US; itkStaticConstMacro(ATTRIBUTE_RA, AttributeType, 107);
itkStaticConstMacro(ATTRIBUTE_RM, AttributeType, 108);
/** Attribute name for missing region */ itkStaticConstMacro(ATTRIBUTE_RN, AttributeType, 109);
static const std::string ATTRIBUTE_M;
static std::string GetNameFromAttribute( const AttributeType & a )
/** Attribute name for noise region */ {
static const std::string ATTRIBUTE_N; std::string name;
switch( a )
/** Attribute name for correct detection score */ {
static const std::string ATTRIBUTE_RC; case ATTRIBUTE_CD: name = "HooverInstance_Ext_CD"; break;
case ATTRIBUTE_OS: name = "HooverInstance_Ext_OS"; break;
/** Attribute name for fragmentation score (over segmentation) */ case ATTRIBUTE_US: name = "HooverInstance_Ext_US"; break;
static const std::string ATTRIBUTE_RF; case ATTRIBUTE_M: name = "HooverInstance_Ext_M"; break;
case ATTRIBUTE_N: name = "HooverInstance_Ext_N"; break;
/** Attribute name for aggregation score (under segmentation) */ case ATTRIBUTE_RC: name = "HooverInstance_RC"; break;
static const std::string ATTRIBUTE_RA; case ATTRIBUTE_RF: name = "HooverInstance_RF"; break;
case ATTRIBUTE_RA: name = "HooverInstance_RA"; break;
/** Attribute name for missed score */ case ATTRIBUTE_RM: name = "HooverInstance_RM"; break;
static const std::string ATTRIBUTE_RM; case ATTRIBUTE_RN: name = "HooverInstance_RN"; break;
}
/** Attribute name for noise score */ return name;
static const std::string ATTRIBUTE_RN; }
static AttributeType GetAttributeFromName( const std::string & name )
{
if ( name == "HooverInstance_Ext_CD" )
{
return ATTRIBUTE_CD;
}
else if ( name == "HooverInstance_Ext_OS" )
{
return ATTRIBUTE_OS;
}
else if ( name == "HooverInstance_Ext_US" )
{
return ATTRIBUTE_US;
}
else if ( name == "HooverInstance_Ext_M" )
{
return ATTRIBUTE_M;
}
else if ( name == "HooverInstance_Ext_N" )
{
return ATTRIBUTE_N;
}
else if ( name == "HooverInstance_RC" )
{
return ATTRIBUTE_RC;
}
else if ( name == "HooverInstance_RF" )
{
return ATTRIBUTE_RF;
}
else if ( name == "HooverInstance_RA" )
{
return ATTRIBUTE_RA;
}
else if ( name == "HooverInstance_RM" )
{
return ATTRIBUTE_RM;
}
else if ( name == "HooverInstance_RN" )
{
return ATTRIBUTE_RN;
}
}
protected: protected:
HooverInstanceFilter(); HooverInstanceFilter();
......
...@@ -23,36 +23,6 @@ ...@@ -23,36 +23,6 @@
namespace otb namespace otb
{ {
/** Hoover Attribute names */
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_CD="HooverInstance_Ext_CD";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_OS="HooverInstance_Ext_OS";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_US="HooverInstance_Ext_US";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_M="HooverInstance_Ext_M";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_N="HooverInstance_Ext_N";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_RC="HooverInstance_RC";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_RF="HooverInstance_RF";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_RA="HooverInstance_RA";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_RM="HooverInstance_RM";
template <class TLabelMap>
const std::string HooverInstanceFilter<TLabelMap>::ATTRIBUTE_RN="HooverInstance_RN";
/** Constructor */ /** Constructor */
template <class TLabelMap> template <class TLabelMap>
...@@ -232,10 +202,10 @@ void HooverInstanceFilter<TLabelMap> ...@@ -232,10 +202,10 @@ void HooverInstanceFilter<TLabelMap>
otbWarningMacro("Region "<<i<<" in machine segmentation label map is empty"); otbWarningMacro("Region "<<i<<" in machine segmentation label map is empty");
} }
// reset any Hoover attribute already present // reset any Hoover attribute already present
regionMS->SetAttribute(ATTRIBUTE_RC.c_str(), 0.0); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), 0.0);
regionMS->SetAttribute(ATTRIBUTE_RF.c_str(), 0.0); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), 0.0);
regionMS->SetAttribute(ATTRIBUTE_RA.c_str(), 0.0); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), 0.0);
regionMS->SetAttribute(ATTRIBUTE_RN.c_str(), 0.0); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RN), 0.0);
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
...@@ -284,10 +254,10 @@ void HooverInstanceFilter<TLabelMap> ...@@ -284,10 +254,10 @@ void HooverInstanceFilter<TLabelMap>
} }
// reset any Hoover attribute already present // reset any Hoover attribute already present
labelObject->SetAttribute(ATTRIBUTE_RC.c_str(), 0.0); labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), 0.0);
labelObject->SetAttribute(ATTRIBUTE_RF.c_str(), 0.0); labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), 0.0);
labelObject->SetAttribute(ATTRIBUTE_RA.c_str(), 0.0); labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), 0.0);
labelObject->SetAttribute(ATTRIBUTE_RM.c_str(), 0.0); labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RM), 0.0);
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
...@@ -381,13 +351,13 @@ void HooverInstanceFilter<TLabelMap> ...@@ -381,13 +351,13 @@ void HooverInstanceFilter<TLabelMap>
double scoreRC = m_Threshold * (std::min(coefT / tGT, coefT / tMS)); double scoreRC = m_Threshold * (std::min(coefT / tGT, coefT / tMS));
bufferRC += scoreRC * static_cast<double>(m_CardRegGT[row]); bufferRC += scoreRC * static_cast<double>(m_CardRegGT[row]);
regionGT->SetAttribute(ATTRIBUTE_RC.c_str(), static_cast<AttributesValueType>(scoreRC)); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), static_cast<AttributesValueType>(scoreRC));
regionMS->SetAttribute(ATTRIBUTE_RC.c_str(), static_cast<AttributesValueType>(scoreRC)); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), static_cast<AttributesValueType>(scoreRC));
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
regionGT->SetAttribute(ATTRIBUTE_CD.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_CD), static_cast<AttributesValueType>(regionMS->GetLabel()));
regionMS->SetAttribute(ATTRIBUTE_CD.c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_CD), static_cast<AttributesValueType>(regionGT->GetLabel()));
} }
GTindices.insert(row); GTindices.insert(row);
...@@ -422,7 +392,7 @@ void HooverInstanceFilter<TLabelMap> ...@@ -422,7 +392,7 @@ void HooverInstanceFilter<TLabelMap>
double scoreRF = 1.0 - sumScoreRF / (cardRegGT * (cardRegGT - 1.0)); double scoreRF = 1.0 - sumScoreRF / (cardRegGT * (cardRegGT - 1.0));
bufferRF += scoreRF * cardRegGT; bufferRF += scoreRF * cardRegGT;
regionGT->SetAttribute(ATTRIBUTE_RF.c_str(), static_cast<AttributesValueType>(scoreRF)); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), static_cast<AttributesValueType>(scoreRF));
unsigned int indexOS=1; unsigned int indexOS=1;
for(typename ObjectVectorType::iterator it=objectsOfMS.begin(); it!=objectsOfMS.end(); ++it) for(typename ObjectVectorType::iterator it=objectsOfMS.begin(); it!=objectsOfMS.end(); ++it)
...@@ -431,12 +401,12 @@ void HooverInstanceFilter<TLabelMap> ...@@ -431,12 +401,12 @@ void HooverInstanceFilter<TLabelMap>
std::ostringstream attribute; std::ostringstream attribute;
attribute << ATTRIBUTE_OS << "_" << indexOS; attribute << ATTRIBUTE_OS << "_" << indexOS;
regionMS->SetAttribute(ATTRIBUTE_RF.c_str(), static_cast<AttributesValueType>(scoreRF)); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), static_cast<AttributesValueType>(scoreRF));
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
regionGT->SetAttribute(attribute.str().c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); regionGT->SetAttribute(attribute.str().c_str(), static_cast<AttributesValueType>(regionMS->GetLabel()));
regionMS->SetAttribute(ATTRIBUTE_OS.c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_OS), static_cast<AttributesValueType>(regionGT->GetLabel()));
} }
indexOS++; indexOS++;
...@@ -518,7 +488,7 @@ void HooverInstanceFilter<TLabelMap> ...@@ -518,7 +488,7 @@ void HooverInstanceFilter<TLabelMap>
double scoreRA = 1.0 - sumScoreUS / (sumCardUS * (sumCardUS - 1.0)); double scoreRA = 1.0 - sumScoreUS / (sumCardUS * (sumCardUS - 1.0));
bufferRA += scoreRA * sumCardUS; bufferRA += scoreRA * sumCardUS;
regionMS->SetAttribute(ATTRIBUTE_RA.c_str(), static_cast<AttributesValueType>(scoreRA)); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), static_cast<AttributesValueType>(scoreRA));
unsigned int indexUS=1; unsigned int indexUS=1;
for(typename ObjectVectorType::iterator it=objectsOfGT.begin(); it!=objectsOfGT.end(); ++it) for(typename ObjectVectorType::iterator it=objectsOfGT.begin(); it!=objectsOfGT.end(); ++it)
...@@ -527,12 +497,12 @@ void HooverInstanceFilter<TLabelMap> ...@@ -527,12 +497,12 @@ void HooverInstanceFilter<TLabelMap>
std::ostringstream attribute; std::ostringstream attribute;
attribute << ATTRIBUTE_US << "_" << indexUS; attribute << ATTRIBUTE_US << "_" << indexUS;
regionGT->SetAttribute(ATTRIBUTE_RA.c_str(), static_cast<AttributesValueType>(scoreRA)); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), static_cast<AttributesValueType>(scoreRA));
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
regionMS->SetAttribute(attribute.str().c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); regionMS->SetAttribute(attribute.str(), static_cast<AttributesValueType>(regionGT->GetLabel()));
regionGT->SetAttribute(ATTRIBUTE_US.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_US), static_cast<AttributesValueType>(regionMS->GetLabel()));
} }
indexUS++; indexUS++;
...@@ -573,11 +543,12 @@ void HooverInstanceFilter<TLabelMap> ...@@ -573,11 +543,12 @@ void HooverInstanceFilter<TLabelMap>
bufferRM += static_cast<double>(m_CardRegGT[i]); bufferRM += static_cast<double>(m_CardRegGT[i]);
regionGT->SetAttribute(ATTRIBUTE_RM.c_str(), 1.0); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RM), 1.0);
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
regionGT->SetAttribute(ATTRIBUTE_M.c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_M),
static_cast<AttributesValueType>(regionGT->GetLabel()));
} }
} }
...@@ -593,11 +564,12 @@ void HooverInstanceFilter<TLabelMap> ...@@ -593,11 +564,12 @@ void HooverInstanceFilter<TLabelMap>
bufferRN += static_cast<double>(m_CardRegMS[i]); bufferRN += static_cast<double>(m_CardRegMS[i]);
regionMS->SetAttribute(ATTRIBUTE_RN.c_str(), 1.0); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RN), 1.0);
if (m_UseExtendedAttributes) if (m_UseExtendedAttributes)
{ {
regionMS->SetAttribute(ATTRIBUTE_N.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_N),
static_cast<AttributesValueType>(regionMS->GetLabel()));
} }
} }
......
...@@ -92,6 +92,12 @@ public: ...@@ -92,6 +92,12 @@ public:
/** Fill the given channel with value from the given attribute */ /** Fill the given channel with value from the given attribute */
bool SetAttributeForNthChannel(unsigned int channel, const char *attribute); bool SetAttributeForNthChannel(unsigned int channel, const char *attribute);
/** Fill the given channel with value from the given attribute */
bool SetAttributeForNthChannel(unsigned int channel, const std::string& attribute)
{
return this->SetAttributeForNthChannel(channel, attribute.c_str());
}
protected: protected:
LabelMapToAttributeImageFilter(); LabelMapToAttributeImageFilter();
~LabelMapToAttributeImageFilter() {}; ~LabelMapToAttributeImageFilter() {};
......
...@@ -164,10 +164,10 @@ int main(int argc, char* argv[]) ...@@ -164,10 +164,10 @@ int main(int argc, char* argv[])
// Software Guide : BeginCodeSnippet // Software Guide : BeginCodeSnippet
AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New(); AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New();
attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap()); attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap());
attributeImageGT->SetAttributeForNthChannel(0, instances->ATTRIBUTE_RC.c_str()); attributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC));
attributeImageGT->SetAttributeForNthChannel(1, instances->ATTRIBUTE_RF.c_str()); attributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF));
attributeImageGT->SetAttributeForNthChannel(2, instances->ATTRIBUTE_RA.c_str()); attributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA));
attributeImageGT->SetAttributeForNthChannel(3, instances->ATTRIBUTE_RM.c_str()); attributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM));
WriterType::Pointer writer = WriterType::New(); WriterType::Pointer writer = WriterType::New();
writer->SetInput(attributeImageGT->GetOutput()); writer->SetInput(attributeImageGT->GetOutput());
......
...@@ -51,6 +51,8 @@ OTB_TEST_APPLICATION(NAME apTvSeHooverCompareSegmentationTest ...@@ -51,6 +51,8 @@ OTB_TEST_APPLICATION(NAME apTvSeHooverCompareSegmentationTest
APP HooverCompareSegmentation APP HooverCompareSegmentation
OPTIONS -ingt ${INPUTDATA}/maur_GT.tif OPTIONS -ingt ${INPUTDATA}/maur_GT.tif
-inms ${INPUTDATA}/maur_labelled.tif -inms ${INPUTDATA}/maur_labelled.tif
-outgt ${TEMP}/apTvSeHooverCompareSegmentationTestOutgt.tif
-outms ${TEMP}/apTvSeHooverCompareSegmentationTestOutms.tif
TESTENVOPTIONS ${TEMP}/apTvSeHooverCompareSegmentationTest.txt TESTENVOPTIONS ${TEMP}/apTvSeHooverCompareSegmentationTest.txt
VALID --compare-ascii ${EPSILON_7} VALID --compare-ascii ${EPSILON_7}
${BASELINE_FILES}/apTvSeHooverCompareSegmentationTest.txt ${BASELINE_FILES}/apTvSeHooverCompareSegmentationTest.txt
......
...@@ -84,10 +84,10 @@ int otbHooverInstanceFilterToAttributeImage(int argc, char* argv[]) ...@@ -84,10 +84,10 @@ int otbHooverInstanceFilterToAttributeImage(int argc, char* argv[])
AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New(); AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New();
attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap()); attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap());
attributeImageGT->SetAttributeForNthChannel(0, instances->ATTRIBUTE_RC.c_str()); attributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC));
attributeImageGT->SetAttributeForNthChannel(1, instances->ATTRIBUTE_RF.c_str()); attributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF));
attributeImageGT->SetAttributeForNthChannel(2, instances->ATTRIBUTE_RA.c_str()); attributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA));
attributeImageGT->SetAttributeForNthChannel(3, instances->ATTRIBUTE_RM.c_str()); attributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM));
WriterType::Pointer writer = WriterType::New(); WriterType::Pointer writer = WriterType::New();
writer->SetInput(attributeImageGT->GetOutput()); writer->SetInput(attributeImageGT->GetOutput());
......
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