From d7d974351994a94963a5bdac0eb9f3277c8fd424 Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Mon, 12 Mar 2012 19:54:16 +0100 Subject: [PATCH] ENH: modify HooverInstanceFilter to avoid segfault at plugin unloading with gcc>=45 --- .../otbHooverCompareSegmentation.cxx | 17 ++- Code/OBIA/otbAttributesMapLabelObject.h | 9 ++ Code/OBIA/otbHooverInstanceFilter.h | 107 +++++++++++++----- Code/OBIA/otbHooverInstanceFilter.txx | 78 ++++--------- Code/OBIA/otbLabelMapToAttributeImageFilter.h | 6 + Examples/OBIA/HooverMetricsEstimation.cxx | 8 +- .../Applications/Segmentation/CMakeLists.txt | 2 + ...tbHooverInstanceFilterToAttributeImage.cxx | 8 +- 8 files changed, 134 insertions(+), 101 deletions(-) diff --git a/Applications/Segmentation/otbHooverCompareSegmentation.cxx b/Applications/Segmentation/otbHooverCompareSegmentation.cxx index 603adf43a1..8672055b95 100644 --- a/Applications/Segmentation/otbHooverCompareSegmentation.cxx +++ b/Applications/Segmentation/otbHooverCompareSegmentation.cxx @@ -230,17 +230,17 @@ private: m_AttributeImageGT = AttributeImageFilterType::New(); m_AttributeImageGT->SetInput(m_InstanceFilter->GetOutputGroundTruthLabelMap()); - m_AttributeImageGT->SetAttributeForNthChannel(0, m_InstanceFilter->ATTRIBUTE_RC.c_str()); - m_AttributeImageGT->SetAttributeForNthChannel(1, m_InstanceFilter->ATTRIBUTE_RF.c_str()); - m_AttributeImageGT->SetAttributeForNthChannel(2, m_InstanceFilter->ATTRIBUTE_RA.c_str()); - m_AttributeImageGT->SetAttributeForNthChannel(3, m_InstanceFilter->ATTRIBUTE_RM.c_str()); + m_AttributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC)); + m_AttributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF)); + m_AttributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA)); + m_AttributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM)); m_AttributeImageMS = AttributeImageFilterType::New(); m_AttributeImageMS->SetInput(m_InstanceFilter->GetOutputMachineSegmentationLabelMap()); - m_AttributeImageMS->SetAttributeForNthChannel(0, m_InstanceFilter->ATTRIBUTE_RC.c_str()); - m_AttributeImageMS->SetAttributeForNthChannel(1, m_InstanceFilter->ATTRIBUTE_RF.c_str()); - m_AttributeImageMS->SetAttributeForNthChannel(2, m_InstanceFilter->ATTRIBUTE_RA.c_str()); - //m_AttributeImageMS->SetAttributeForNthChannel(3, m_InstanceFilter->ATTRIBUTE_RN.c_str()); + m_AttributeImageMS->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC)); + m_AttributeImageMS->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF)); + m_AttributeImageMS->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA)); + //m_AttributeImageMS->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RN); m_GTColorFilter = HooverColorFilterType::New(); m_GTColorFilter->SetInput(m_AttributeImageGT->GetOutput()); @@ -296,7 +296,6 @@ private: SetParameterFloat("rf", m_InstanceFilter->GetMeanRF()); SetParameterFloat("ra", m_InstanceFilter->GetMeanRA()); SetParameterFloat("rm", m_InstanceFilter->GetMeanRM()); - } ImageToLabelMapFilterType::Pointer m_GTFilter; diff --git a/Code/OBIA/otbAttributesMapLabelObject.h b/Code/OBIA/otbAttributesMapLabelObject.h index f4f8047aa2..8a92e23c89 100644 --- a/Code/OBIA/otbAttributesMapLabelObject.h +++ b/Code/OBIA/otbAttributesMapLabelObject.h @@ -203,6 +203,15 @@ public: 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 */ diff --git a/Code/OBIA/otbHooverInstanceFilter.h b/Code/OBIA/otbHooverInstanceFilter.h index b9cd24fbb8..9fd007b28b 100644 --- a/Code/OBIA/otbHooverInstanceFilter.h +++ b/Code/OBIA/otbHooverInstanceFilter.h @@ -19,10 +19,10 @@ #ifndef __otbHooverInstanceFilter_h #define __otbHooverInstanceFilter_h +#include <set> #include "itkInPlaceLabelMapFilter.h" #include "itkVariableSizeMatrix.h" #include "itkVariableLengthVector.h" -#include <set> 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 * 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) * * \sa HooverMatrixFilter @@ -86,6 +86,7 @@ public: typedef typename LabelMapType::LabelObjectContainerType LabelObjectContainerType; typedef typename LabelObjectContainerType::const_iterator LabelObjectContainerTypeConstIterator; typedef typename LabelMapType::LabelObjectType LabelObjectType; + typedef typename LabelObjectType::AttributeType AttributeType; typedef typename LabelObjectType::AttributesValueType AttributesValueType; typedef typename LabelMapType::LabelVectorType LabelVectorType; typedef typename LabelMapType::RegionType ImageRegionType; @@ -126,35 +127,79 @@ public: itkGetMacro(MeanRM, AttributesValueType); itkGetMacro(MeanRN, AttributesValueType); - /** Attribute name for correct detection */ - static const std::string ATTRIBUTE_CD; - - /** Attribute name for over segmentation */ - static const std::string ATTRIBUTE_OS; - - /** Attribute name for under segmentation */ - static const std::string ATTRIBUTE_US; - - /** Attribute name for missing region */ - static const std::string ATTRIBUTE_M; - - /** Attribute name for noise region */ - static const std::string ATTRIBUTE_N; - - /** Attribute name for correct detection score */ - static const std::string ATTRIBUTE_RC; - - /** Attribute name for fragmentation score (over segmentation) */ - static const std::string ATTRIBUTE_RF; - - /** Attribute name for aggregation score (under segmentation) */ - static const std::string ATTRIBUTE_RA; - - /** Attribute name for missed score */ - static const std::string ATTRIBUTE_RM; - - /** Attribute name for noise score */ - static const std::string ATTRIBUTE_RN; + itkStaticConstMacro(ATTRIBUTE_CD, AttributeType, 100); + itkStaticConstMacro(ATTRIBUTE_OS, AttributeType, 101); + itkStaticConstMacro(ATTRIBUTE_US, AttributeType, 102); + itkStaticConstMacro(ATTRIBUTE_M, AttributeType, 103); + itkStaticConstMacro(ATTRIBUTE_N, AttributeType, 104); + itkStaticConstMacro(ATTRIBUTE_RC, AttributeType, 105); + itkStaticConstMacro(ATTRIBUTE_RF, AttributeType, 106); + itkStaticConstMacro(ATTRIBUTE_RA, AttributeType, 107); + itkStaticConstMacro(ATTRIBUTE_RM, AttributeType, 108); + itkStaticConstMacro(ATTRIBUTE_RN, AttributeType, 109); + + static std::string GetNameFromAttribute( const AttributeType & a ) + { + std::string name; + switch( a ) + { + case ATTRIBUTE_CD: name = "HooverInstance_Ext_CD"; break; + case ATTRIBUTE_OS: name = "HooverInstance_Ext_OS"; break; + case ATTRIBUTE_US: name = "HooverInstance_Ext_US"; break; + case ATTRIBUTE_M: name = "HooverInstance_Ext_M"; break; + case ATTRIBUTE_N: name = "HooverInstance_Ext_N"; break; + case ATTRIBUTE_RC: name = "HooverInstance_RC"; break; + case ATTRIBUTE_RF: name = "HooverInstance_RF"; break; + case ATTRIBUTE_RA: name = "HooverInstance_RA"; break; + case ATTRIBUTE_RM: name = "HooverInstance_RM"; break; + case ATTRIBUTE_RN: name = "HooverInstance_RN"; break; + } + return name; + } + + 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: HooverInstanceFilter(); diff --git a/Code/OBIA/otbHooverInstanceFilter.txx b/Code/OBIA/otbHooverInstanceFilter.txx index 155fb1b31c..534d21f12f 100644 --- a/Code/OBIA/otbHooverInstanceFilter.txx +++ b/Code/OBIA/otbHooverInstanceFilter.txx @@ -23,36 +23,6 @@ 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 */ template <class TLabelMap> @@ -232,10 +202,10 @@ void HooverInstanceFilter<TLabelMap> otbWarningMacro("Region "<<i<<" in machine segmentation label map is empty"); } // reset any Hoover attribute already present - regionMS->SetAttribute(ATTRIBUTE_RC.c_str(), 0.0); - regionMS->SetAttribute(ATTRIBUTE_RF.c_str(), 0.0); - regionMS->SetAttribute(ATTRIBUTE_RA.c_str(), 0.0); - regionMS->SetAttribute(ATTRIBUTE_RN.c_str(), 0.0); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), 0.0); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), 0.0); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), 0.0); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RN), 0.0); if (m_UseExtendedAttributes) { @@ -284,10 +254,10 @@ void HooverInstanceFilter<TLabelMap> } // reset any Hoover attribute already present - labelObject->SetAttribute(ATTRIBUTE_RC.c_str(), 0.0); - labelObject->SetAttribute(ATTRIBUTE_RF.c_str(), 0.0); - labelObject->SetAttribute(ATTRIBUTE_RA.c_str(), 0.0); - labelObject->SetAttribute(ATTRIBUTE_RM.c_str(), 0.0); + labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), 0.0); + labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RF), 0.0); + labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RA), 0.0); + labelObject->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RM), 0.0); if (m_UseExtendedAttributes) { @@ -381,13 +351,13 @@ void HooverInstanceFilter<TLabelMap> double scoreRC = m_Threshold * (std::min(coefT / tGT, coefT / tMS)); bufferRC += scoreRC * static_cast<double>(m_CardRegGT[row]); - regionGT->SetAttribute(ATTRIBUTE_RC.c_str(), static_cast<AttributesValueType>(scoreRC)); - regionMS->SetAttribute(ATTRIBUTE_RC.c_str(), static_cast<AttributesValueType>(scoreRC)); + regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), static_cast<AttributesValueType>(scoreRC)); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_RC), static_cast<AttributesValueType>(scoreRC)); if (m_UseExtendedAttributes) { - regionGT->SetAttribute(ATTRIBUTE_CD.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); - regionMS->SetAttribute(ATTRIBUTE_CD.c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); + regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_CD), static_cast<AttributesValueType>(regionMS->GetLabel())); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_CD), static_cast<AttributesValueType>(regionGT->GetLabel())); } GTindices.insert(row); @@ -422,7 +392,7 @@ void HooverInstanceFilter<TLabelMap> double scoreRF = 1.0 - sumScoreRF / (cardRegGT * (cardRegGT - 1.0)); 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; for(typename ObjectVectorType::iterator it=objectsOfMS.begin(); it!=objectsOfMS.end(); ++it) @@ -431,12 +401,12 @@ void HooverInstanceFilter<TLabelMap> std::ostringstream attribute; 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) { 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++; @@ -518,7 +488,7 @@ void HooverInstanceFilter<TLabelMap> double scoreRA = 1.0 - sumScoreUS / (sumCardUS * (sumCardUS - 1.0)); 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; for(typename ObjectVectorType::iterator it=objectsOfGT.begin(); it!=objectsOfGT.end(); ++it) @@ -527,12 +497,12 @@ void HooverInstanceFilter<TLabelMap> std::ostringstream attribute; 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) { - regionMS->SetAttribute(attribute.str().c_str(), static_cast<AttributesValueType>(regionGT->GetLabel())); - regionGT->SetAttribute(ATTRIBUTE_US.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); + regionMS->SetAttribute(attribute.str(), static_cast<AttributesValueType>(regionGT->GetLabel())); + regionGT->SetAttribute(GetNameFromAttribute(ATTRIBUTE_US), static_cast<AttributesValueType>(regionMS->GetLabel())); } indexUS++; @@ -573,11 +543,12 @@ void HooverInstanceFilter<TLabelMap> 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) { - 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> 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) { - regionMS->SetAttribute(ATTRIBUTE_N.c_str(), static_cast<AttributesValueType>(regionMS->GetLabel())); + regionMS->SetAttribute(GetNameFromAttribute(ATTRIBUTE_N), + static_cast<AttributesValueType>(regionMS->GetLabel())); } } diff --git a/Code/OBIA/otbLabelMapToAttributeImageFilter.h b/Code/OBIA/otbLabelMapToAttributeImageFilter.h index c18de64922..b2c55fd23a 100644 --- a/Code/OBIA/otbLabelMapToAttributeImageFilter.h +++ b/Code/OBIA/otbLabelMapToAttributeImageFilter.h @@ -92,6 +92,12 @@ public: /** Fill the given channel with value from the given 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: LabelMapToAttributeImageFilter(); ~LabelMapToAttributeImageFilter() {}; diff --git a/Examples/OBIA/HooverMetricsEstimation.cxx b/Examples/OBIA/HooverMetricsEstimation.cxx index 79a22aaafa..06e99dc1dd 100644 --- a/Examples/OBIA/HooverMetricsEstimation.cxx +++ b/Examples/OBIA/HooverMetricsEstimation.cxx @@ -164,10 +164,10 @@ int main(int argc, char* argv[]) // Software Guide : BeginCodeSnippet AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New(); attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap()); - attributeImageGT->SetAttributeForNthChannel(0, instances->ATTRIBUTE_RC.c_str()); - attributeImageGT->SetAttributeForNthChannel(1, instances->ATTRIBUTE_RF.c_str()); - attributeImageGT->SetAttributeForNthChannel(2, instances->ATTRIBUTE_RA.c_str()); - attributeImageGT->SetAttributeForNthChannel(3, instances->ATTRIBUTE_RM.c_str()); + attributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC)); + attributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF)); + attributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA)); + attributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM)); WriterType::Pointer writer = WriterType::New(); writer->SetInput(attributeImageGT->GetOutput()); diff --git a/Testing/Applications/Segmentation/CMakeLists.txt b/Testing/Applications/Segmentation/CMakeLists.txt index 86dc2fc148..ae6ff0254e 100644 --- a/Testing/Applications/Segmentation/CMakeLists.txt +++ b/Testing/Applications/Segmentation/CMakeLists.txt @@ -51,6 +51,8 @@ OTB_TEST_APPLICATION(NAME apTvSeHooverCompareSegmentationTest APP HooverCompareSegmentation OPTIONS -ingt ${INPUTDATA}/maur_GT.tif -inms ${INPUTDATA}/maur_labelled.tif + -outgt ${TEMP}/apTvSeHooverCompareSegmentationTestOutgt.tif + -outms ${TEMP}/apTvSeHooverCompareSegmentationTestOutms.tif TESTENVOPTIONS ${TEMP}/apTvSeHooverCompareSegmentationTest.txt VALID --compare-ascii ${EPSILON_7} ${BASELINE_FILES}/apTvSeHooverCompareSegmentationTest.txt diff --git a/Testing/Code/OBIA/otbHooverInstanceFilterToAttributeImage.cxx b/Testing/Code/OBIA/otbHooverInstanceFilterToAttributeImage.cxx index 1efe061847..0357503539 100644 --- a/Testing/Code/OBIA/otbHooverInstanceFilterToAttributeImage.cxx +++ b/Testing/Code/OBIA/otbHooverInstanceFilterToAttributeImage.cxx @@ -84,10 +84,10 @@ int otbHooverInstanceFilterToAttributeImage(int argc, char* argv[]) AttributeImageFilterType::Pointer attributeImageGT = AttributeImageFilterType::New(); attributeImageGT->SetInput(instances->GetOutputGroundTruthLabelMap()); - attributeImageGT->SetAttributeForNthChannel(0, instances->ATTRIBUTE_RC.c_str()); - attributeImageGT->SetAttributeForNthChannel(1, instances->ATTRIBUTE_RF.c_str()); - attributeImageGT->SetAttributeForNthChannel(2, instances->ATTRIBUTE_RA.c_str()); - attributeImageGT->SetAttributeForNthChannel(3, instances->ATTRIBUTE_RM.c_str()); + attributeImageGT->SetAttributeForNthChannel(0, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RC)); + attributeImageGT->SetAttributeForNthChannel(1, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RF)); + attributeImageGT->SetAttributeForNthChannel(2, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RA)); + attributeImageGT->SetAttributeForNthChannel(3, InstanceFilterType::GetNameFromAttribute(InstanceFilterType::ATTRIBUTE_RM)); WriterType::Pointer writer = WriterType::New(); writer->SetInput(attributeImageGT->GetOutput()); -- GitLab