diff --git a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx index 07a8a352d7622e29bed60592a69fed040ad53a8c..8f7b676fb0e787ebe65a519cd8c8ec215638a50b 100644 --- a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx @@ -59,6 +59,7 @@ public: typedef ClassificationFilterType::ValueType ValueType; typedef ClassificationFilterType::LabelType LabelType; typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType; + typedef ClassificationFilterType::ConfidenceImageType ConfidenceImageType; private: void DoInit() @@ -94,6 +95,11 @@ private: SetParameterDescription( "out", "Output image containing class labels"); SetParameterOutputImagePixelType( "out", ImagePixelType_uint8); + AddParameter(ParameterType_OutputImage, "confmap", "Confidence map"); + SetParameterDescription( "confmap", "Confidence map of the produced classification. Meaning depends on the model."); + SetParameterOutputImagePixelType( "confmap", ImagePixelType_double); + MandatoryOff("confmap"); + AddRAMParameter(); // Doc example parameter settings @@ -171,6 +177,15 @@ private: } SetParameterOutputImage<OutputImageType>("out", m_ClassificationFilter->GetOutput()); + + // output confidence map + if (IsParameterEnabled("confmap") && HasValue("confmap")) + { + if (m_Model->HasConfidenceIndex()) + { + SetParameterOutputImage<ConfidenceImageType>("confmap",m_ClassificationFilter->GetOutputConfidence()); + } + } } ClassificationFilterType::Pointer m_ClassificationFilter;