From 5659e323ae9f8577e891b015b3369f7108036297 Mon Sep 17 00:00:00 2001
From: Jonathan Guinet <jonathan.guinet@c-s.fr>
Date: Wed, 14 Dec 2011 14:51:03 +0100
Subject: [PATCH] ENH: explicit cast of labeled and clusterboundaries output of
 meanshift segmentation application.

---
 .../Segmentation/otbMeanShiftSegmentation.cxx | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/Applications/Segmentation/otbMeanShiftSegmentation.cxx b/Applications/Segmentation/otbMeanShiftSegmentation.cxx
index 6e5d0750ab..e1bd94fd96 100644
--- a/Applications/Segmentation/otbMeanShiftSegmentation.cxx
+++ b/Applications/Segmentation/otbMeanShiftSegmentation.cxx
@@ -35,6 +35,8 @@ public:
   typedef itk::SmartPointer<Self>       Pointer;
   typedef itk::SmartPointer<const Self> ConstPointer;
 
+  typedef otb::MeanShiftVectorImageFilter<FloatVectorImageType, FloatVectorImageType> MSFilterType;
+
   /** Standard macro */
   itkNewMacro(Self);
 
@@ -100,28 +102,26 @@ private:
   {
     FloatVectorImageType* input = GetParameterImage("in");
 
-    typedef otb::MeanShiftVectorImageFilter<FloatVectorImageType, FloatVectorImageType> MSFilterType;
-    MSFilterType::Pointer filter = MSFilterType::New();
+   m_filter = MSFilterType::New();
 
-    filter->SetInput(input);
-    filter->SetSpatialRadius( GetParameterInt("spatialr") );
-    filter->SetRangeRadius( GetParameterFloat("ranger") );
-    filter->SetMinimumRegionSize( GetParameterInt("minsize") );
-    filter->SetScale( GetParameterFloat("scale") );
+    m_filter->SetInput(input);
+    m_filter->SetSpatialRadius( GetParameterInt("spatialr") );
+    m_filter->SetRangeRadius( GetParameterFloat("ranger") );
+    m_filter->SetMinimumRegionSize( GetParameterInt("minsize") );
+    m_filter->SetScale( GetParameterFloat("scale") );
 
-    m_Ref = filter;
 
     if (IsParameterEnabled("fout") && HasValue("fout"))
-      SetParameterOutputImage("fout", filter->GetOutput());
+      SetParameterOutputImage("fout", m_filter->GetOutput());
     if (IsParameterEnabled("cout") && HasValue("cout"))
-      SetParameterOutputImage("cout", filter->GetClusteredOutput());
+      SetParameterOutputImage("cout", m_filter->GetClusteredOutput());
     if (IsParameterEnabled("lout") && HasValue("lout"))
-      SetParameterOutputImage("lout", filter->GetLabeledClusteredOutput());
+      SetParameterOutputImage<UInt16ImageType>("lout", m_filter->GetLabeledClusteredOutput());
     if (IsParameterEnabled("cbout") && HasValue("cbout"))
-      SetParameterOutputImage("cbout", filter->GetClusterBoundariesOutput());
+      SetParameterOutputImage<UInt16ImageType>("cbout", m_filter->GetClusterBoundariesOutput());
   }
 
-  itk::LightObject::Pointer m_Ref;
+  MSFilterType::Pointer m_filter;
 
 };
 
-- 
GitLab