From 38780d2840724f97f8d72b71e23f13e1849bd734 Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Thu, 13 Oct 2011 11:13:12 +0200
Subject: [PATCH] BUG: outputs of mean shift are optional. handle it properly

---
 .../Segmentation/otbMeanShiftSegmentation.cxx        | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Applications/Segmentation/otbMeanShiftSegmentation.cxx b/Applications/Segmentation/otbMeanShiftSegmentation.cxx
index c8060e5fc1..a7ea6795e5 100644
--- a/Applications/Segmentation/otbMeanShiftSegmentation.cxx
+++ b/Applications/Segmentation/otbMeanShiftSegmentation.cxx
@@ -94,10 +94,14 @@ private:
 
     m_Ref = filter;
 
-    SetParameterOutputImage("fout", filter->GetOutput());
-    SetParameterOutputImage("cout", filter->GetClusteredOutput());
-    SetParameterOutputImage("lout", filter->GetLabeledClusteredOutput());
-    SetParameterOutputImage("cbout", filter->GetClusterBoundariesOutput());
+    if (IsParameterEnabled("fout") && HasValue("fout"))
+      SetParameterOutputImage("fout", filter->GetOutput());
+    if (IsParameterEnabled("cout") && HasValue("cout"))
+      SetParameterOutputImage("cout", filter->GetClusteredOutput());
+    if (IsParameterEnabled("lout") && HasValue("lout"))
+      SetParameterOutputImage("lout", filter->GetLabeledClusteredOutput());
+    if (IsParameterEnabled("cbout") && HasValue("cbout"))
+      SetParameterOutputImage("cbout", filter->GetClusterBoundariesOutput());
   }
 
   itk::LightObject::Pointer m_Ref;
-- 
GitLab