Skip to content
Snippets Groups Projects
Commit 38605bd8 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: better behaviour with the UseConfidenceMap flag

parent 2be1463c
No related branches found
No related tags found
No related merge requests found
......@@ -181,6 +181,7 @@ private:
// output confidence map
if (IsParameterEnabled("confmap") && HasValue("confmap"))
{
m_ClassificationFilter->SetUseConfidenceMap(true);
if (m_Model->HasConfidenceIndex())
{
SetParameterOutputImage<ConfidenceImageType>("confmap",m_ClassificationFilter->GetOutputConfidence());
......
......@@ -80,6 +80,10 @@ public:
itkSetMacro(DefaultLabel, LabelType);
itkGetMacro(DefaultLabel, LabelType);
/** Set/Get the confidence map flag */
itkSetMacro(UseConfidenceMap, bool);
itkGetMacro(UseConfidenceMap, bool);
/**
* If set, only pixels within the mask will be classified.
* All pixels with a value greater than 0 in the mask, will be classified.
......@@ -119,7 +123,7 @@ private:
ModelPointerType m_Model;
/** Default label for invalid pixels (when using a mask) */
LabelType m_DefaultLabel;
/** Flag to produce the confidence map */
/** Flag to produce the confidence map (if the model supports it) */
bool m_UseConfidenceMap;
};
} // End namespace otb
......
......@@ -84,7 +84,6 @@ ImageClassificationFilter<TInputImage, TOutputImage, TMaskImage>
{
itkGenericExceptionMacro(<< "No model for classification");
}
m_UseConfidenceMap = m_Model->HasConfidenceIndex();
}
template <class TInputImage, class TOutputImage, class TMaskImage>
......@@ -119,8 +118,9 @@ ImageClassificationFilter<TInputImage, TOutputImage, TMaskImage>
}
// setup iterator for confidence map
bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex());
ConfidenceMapIteratorType confidenceIt;
if (m_UseConfidenceMap)
if (computeConfidenceMap)
{
confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread);
confidenceIt.GoToBegin();
......@@ -142,7 +142,7 @@ ImageClassificationFilter<TInputImage, TOutputImage, TMaskImage>
if (validPoint)
{
// Classifify
if (m_UseConfidenceMap)
if (computeConfidenceMap)
{
outIt.Set(m_Model->Predict(inIt.Get(),&confidenceIndex)[0]);
}
......@@ -157,7 +157,7 @@ ImageClassificationFilter<TInputImage, TOutputImage, TMaskImage>
outIt.Set(m_DefaultLabel);
confidenceIndex = 0.0;
}
if (m_UseConfidenceMap)
if (computeConfidenceMap)
{
confidenceIt.Set(confidenceIndex);
++confidenceIt;
......
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