From e7ea3f501f4f71019f1044dd4d0ef26a65974779 Mon Sep 17 00:00:00 2001
From: Cyrille Valladeau <cyrille.valladeau@c-s.fr>
Date: Mon, 17 Oct 2011 12:43:48 +0200
Subject: [PATCH] ENH: correct trouble with not exported template methods

---
 Applications/Classification/CMakeLists.txt    |  2 +-
 .../Classification/otbImageSVMClassifier.cxx  | 15 +--
 .../otbKMeansClassification.cxx               | 27 ++----
 .../otbLineSegmentDetection.cxx               |  7 --
 .../otbHyperspectralUnmixing.cxx              | 29 +-----
 Applications/Util/otbConvert.cxx              | 23 ++---
 .../Util/otbMultiResolutionPyramid.cxx        |  7 +-
 .../otbWrapperApplication.cxx                 |  2 +
 .../ApplicationEngine/otbWrapperApplication.h | 93 ++++++++++++++++---
 .../otbWrapperApplication.txx                 | 59 ------------
 .../otbWrapperInputImageParameter.cxx         | 55 +++++++----
 .../otbWrapperInputImageParameter.h           | 39 ++++++--
 12 files changed, 181 insertions(+), 177 deletions(-)
 delete mode 100644 Code/ApplicationEngine/otbWrapperApplication.txx

diff --git a/Applications/Classification/CMakeLists.txt b/Applications/Classification/CMakeLists.txt
index f4470df9a8..69747da6d0 100644
--- a/Applications/Classification/CMakeLists.txt
+++ b/Applications/Classification/CMakeLists.txt
@@ -8,4 +8,4 @@ OTB_CREATE_APPLICATION(NAME           ImageSVMClassifier
 
 OTB_CREATE_APPLICATION(NAME           KMeansClassification
                        SOURCES        otbKMeansClassification.cxx
-                       LINK_LIBRARIES OTBBasicFilters)
+                       LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters;OTBFeatureExtraction;OTBLearning)
diff --git a/Applications/Classification/otbImageSVMClassifier.cxx b/Applications/Classification/otbImageSVMClassifier.cxx
index d464f22f91..a54eae2608 100644
--- a/Applications/Classification/otbImageSVMClassifier.cxx
+++ b/Applications/Classification/otbImageSVMClassifier.cxx
@@ -62,9 +62,9 @@ public:
 
   // Cast filter
   // TODO: supress that !!
-  typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, 
-                                       UInt8ImageType::PixelType>               ExtractImageFilterType;
-  typedef ImageToVectorImageCastFilter<UInt8ImageType, FloatVectorImageType>    CastImageFilterType;
+  //typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, 
+  //                                     UInt8ImageType::PixelType>               ExtractImageFilterType;
+//typedef ImageToVectorImageCastFilter<UInt8ImageType, FloatVectorImageType>    CastImageFilterType;
 
 private:
   ImageSVMClassifier()
@@ -153,13 +153,9 @@ private:
       {
       otbAppLogINFO("Using input mask");
       // Load mask image and cast into LabeledImageType
-      FloatVectorImageType::Pointer inMask = GetParameterImage("mask");
-      m_Extract = ExtractImageFilterType::New();
-      m_Extract->SetInput( inMask );
-      m_Extract->SetChannel(1);
-      m_Extract->UpdateOutputInformation();
+      UInt8ImageType::Pointer inMask = GetParameterUInt8Image("mask");
       
-      m_ClassificationFilter->SetInputMask(m_Extract->GetOutput());
+      m_ClassificationFilter->SetInputMask(inMask);
       }
 
     SetParameterOutputImage<UInt8ImageType>("out", m_ClassificationFilter->GetOutput());
@@ -168,7 +164,6 @@ private:
   ClassificationFilterType::Pointer m_ClassificationFilter;
   ModelPointerType m_ModelSVM;
   RescalerType::Pointer m_Rescaler;
-  ExtractImageFilterType::Pointer m_Extract;
 };
 
 
diff --git a/Applications/Classification/otbKMeansClassification.cxx b/Applications/Classification/otbKMeansClassification.cxx
index 850b84b0bb..0fccc4b117 100644
--- a/Applications/Classification/otbKMeansClassification.cxx
+++ b/Applications/Classification/otbKMeansClassification.cxx
@@ -30,35 +30,28 @@
 #include "itkWeightedCentroidKdTreeGenerator.h"
 #include "itkKdTreeBasedKmeansEstimator.h"
 #include "itkMersenneTwisterRandomVariateGenerator.h"
-#include "itkCastImageFilter.h"
-#include "otbMultiToMonoChannelExtractROI.h"
 
 namespace otb
 {
 namespace Wrapper
 {
 
-typedef otb::Image<FloatVectorImageType::InternalPixelType, 2> ImageReaderType;
-
-typedef UInt8ImageType LabeledImageType;
-typedef ImageReaderType::PixelType PixelType;
+typedef FloatImageType::PixelType PixelType;
 
 typedef itk::FixedArray<PixelType, 108> SampleType;
 typedef itk::Statistics::ListSample<SampleType> ListSampleType;
 typedef itk::Statistics::WeightedCentroidKdTreeGenerator<ListSampleType> TreeGeneratorType;
 typedef TreeGeneratorType::KdTreeType TreeType;
 typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType;
-typedef itk::CastImageFilter<FloatImageListType, FloatImageType> CastMaskFilterType;
-typedef otb::MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType,LabeledImageType::InternalPixelType > ExtractorType;
 
 typedef otb::StreamingTraits<FloatVectorImageType> StreamingTraitsType;
 typedef itk::ImageRegionSplitter<2> SplitterType;
-typedef ImageReaderType::RegionType RegionType;
+typedef FloatImageType::RegionType RegionType;
 
 typedef itk::ImageRegionConstIterator<FloatVectorImageType> IteratorType;
-typedef itk::ImageRegionConstIterator<LabeledImageType> LabeledIteratorType;
+typedef itk::ImageRegionConstIterator<UInt8ImageType> LabeledIteratorType;
 
-typedef otb::KMeansImageClassificationFilter<FloatVectorImageType, LabeledImageType, 108> ClassificationFilterType;
+typedef otb::KMeansImageClassificationFilter<FloatVectorImageType, UInt8ImageType, 108> ClassificationFilterType;
 
 class KMeansClassification: public Application
 {
@@ -116,12 +109,11 @@ private:
     itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer
         randomGen = itk::Statistics::MersenneTwisterRandomVariateGenerator::New();
     m_InImage = GetParameterImage("in");
-    m_Extractor = ExtractorType::New();
-    m_Extractor->SetInput(GetParameterImage("vm"));
-    m_Extractor->SetChannel(1);
-    m_Extractor->UpdateOutputInformation();
-    LabeledImageType::Pointer maskImage = m_Extractor->GetOutput();
+    std::cout<<"mask in progress"<<std::endl;
+
+    UInt8ImageType::Pointer maskImage = GetParameterUInt8Image("vm");
 
+    std::cout<<"mask in progress done"<<std::endl;
     std::ostringstream message("");
 
     const unsigned int nbsamples = GetParameterInt("ts");
@@ -331,11 +323,10 @@ private:
 
     m_Classifier->SetCentroids(estimator->GetParameters());
 
-    SetParameterOutputImage<LabeledImageType> ("out", m_Classifier->GetOutput());
+    SetParameterOutputImage<UInt8ImageType> ("out", m_Classifier->GetOutput());
 
   }
 
-  ExtractorType::Pointer m_Extractor;
   ClassificationFilterType::Pointer m_Classifier;
   FloatVectorImageType::Pointer m_InImage;
 
diff --git a/Applications/FeatureExtraction/otbLineSegmentDetection.cxx b/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
index 6467b754f9..b7a064e721 100644
--- a/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
+++ b/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
@@ -20,13 +20,8 @@
 
 #include "otbStreamingLineSegmentDetector.h"
 
-#include "otbImage.h"
-#include "otbVectorImage.h"
 #include "otbVectorImageToAmplitudeImageFilter.h"
 #include "otbVectorData.h"
-#include "otbImageFileReader.h"
-#include "otbVectorDataFileWriter.h"
-#include "otbStandardFilterWatcher.h"
 #include "otbStreamingStatisticsImageFilter.h"
 #include "itkShiftScaleImageFilter.h"
 
@@ -35,8 +30,6 @@
 #include "itkAffineTransform.h"
 
 
-
-
 namespace otb
 {
 namespace Wrapper
diff --git a/Applications/Hyperspectral/otbHyperspectralUnmixing.cxx b/Applications/Hyperspectral/otbHyperspectralUnmixing.cxx
index ff70251c33..eb4623b06f 100644
--- a/Applications/Hyperspectral/otbHyperspectralUnmixing.cxx
+++ b/Applications/Hyperspectral/otbHyperspectralUnmixing.cxx
@@ -30,17 +30,12 @@
 
 #include "otbVectorImageToMatrixImageFilter.h"
 
-#include "itkCastImageFilter.h"
-
 
 namespace otb
 {
 namespace Wrapper
 {
 
-typedef itk::CastImageFilter<FloatVectorImageType, DoubleVectorImageType> FloatToDoubleFilterType;
-typedef itk::CastImageFilter<DoubleVectorImageType, FloatVectorImageType> DoubleToFloatFilterType;
-
 const unsigned int Dimension = 2;
 
 typedef otb::StreamingStatisticsVectorImageFilter<DoubleVectorImageType> StreamingStatisticsVectorImageFilterType;
@@ -265,10 +260,7 @@ private:
      *
      */
 
-    FloatToDoubleFilterType::Pointer cast = FloatToDoubleFilterType::New();
-    cast->SetInput( GetParameterImage("in") );
-    DoubleVectorImageType::Pointer inputImage = cast->GetOutput();
-    m_ProcessObjects.push_back(cast.GetPointer());
+    DoubleVectorImageType::Pointer inputImage = GetParameterImage<DoubleVectorImageType>("in");
 
     DoubleVectorImageType::Pointer endmembersImage;
     if ( inputEndmembers.empty() )
@@ -332,11 +324,7 @@ private:
        * Read input endmembers
        */
       std::cout << "Read Endmembers " << inputEndmembers << std::endl;
-
-      FloatToDoubleFilterType::Pointer cast = FloatToDoubleFilterType::New();
-      cast->SetInput( GetParameterImage("ie") );
-      endmembersImage = cast->GetOutput();
-      m_ProcessObjects.push_back(cast.GetPointer());
+      endmembersImage = GetParameterImage<DoubleVectorImageType>("ie");
 
       }
   //  endmembersRef->Update();
@@ -430,12 +418,7 @@ private:
        */
       std::cout << "Write endmembers " << outputEndmembers << std::endl;
 
-      DoubleToFloatFilterType::Pointer cast = DoubleToFloatFilterType::New();
-      cast->SetInput( endmembersImage );
-      FloatVectorImageType::Pointer endmembersImageFloat = cast->GetOutput();
-      m_ProcessObjects.push_back(cast.GetPointer());
-
-      SetParameterOutputImage("oe", endmembersImageFloat);
+      SetParameterOutputImage<DoubleVectorImageType>("oe", endmembersImage);
       }
 
     if ( unmixingAlgo != UnMixingMethod_NONE )
@@ -444,12 +427,8 @@ private:
        * Write abundance map
        */
       //std::cout << "Write abundance map" << outputImageName << std::endl;
-      DoubleToFloatFilterType::Pointer cast = DoubleToFloatFilterType::New();
-      cast->SetInput( abundanceMap );
-      FloatVectorImageType::Pointer abundanceMapFloat = cast->GetOutput();
-      m_ProcessObjects.push_back(cast.GetPointer());
 
-      SetParameterOutputImage("out", abundanceMapFloat);
+      SetParameterOutputImage<DoubleVectorImageType>("out", abundanceMap);
       }
   }
 
diff --git a/Applications/Util/otbConvert.cxx b/Applications/Util/otbConvert.cxx
index 37d1303d31..90a7361873 100644
--- a/Applications/Util/otbConvert.cxx
+++ b/Applications/Util/otbConvert.cxx
@@ -117,8 +117,7 @@ private:
  void GenericDoExecute()
   {  
     // Get the input image list
-    FloatVectorImageType::Pointer input = this->GetParameterImage("in");
-    input->UpdateOutputInformation();
+  
     
     typename TImageType::Pointer castIm;
     
@@ -131,14 +130,13 @@ private:
     
     if( rescaleType == "None" )
       {
-      typedef itk::CastImageFilter<FloatVectorImageType, TImageType> CastFilterType;
-      typename CastFilterType::Pointer cast = CastFilterType::New();
-      cast->SetInput( input );
-      m_TmpFilter = cast;
-      castIm = cast->GetOutput();
+      castIm = this->GetParameterImage<TImageType>("in");
       }
     else
       {
+      FloatVectorImageType::Pointer input = this->GetParameterImage("in");
+      input->UpdateOutputInformation();
+
       const unsigned int nbComp(input->GetNumberOfComponentsPerPixel());
       
       typedef otb::VectorRescaleIntensityImageFilter<FloatVectorImageType, TImageType> RescalerType;
@@ -233,14 +231,8 @@ private:
       castIm = rescaler->GetOutput();
       }
     
-    
-    typedef itk::CastImageFilter<TImageType, FloatVectorImageType> EndCastFilterType;
-    typename EndCastFilterType::Pointer endCast = EndCastFilterType::New();
-    endCast->SetInput( castIm );
-    endCast->UpdateOutputInformation();
-
-    m_FinalCaster = endCast;
-    SetParameterOutputImage("out", endCast->GetOutput());
+   
+    SetParameterOutputImage<TImageType>("out", castIm);
   }
 
 
@@ -278,7 +270,6 @@ private:
       }
   }
 
-  itk::ProcessObject::Pointer m_FinalCaster;
   itk::ProcessObject::Pointer m_TmpFilter;
   TransferLogType::Pointer m_TransferLog;
 };;
diff --git a/Applications/Util/otbMultiResolutionPyramid.cxx b/Applications/Util/otbMultiResolutionPyramid.cxx
index 3671cda391..1efff57af1 100644
--- a/Applications/Util/otbMultiResolutionPyramid.cxx
+++ b/Applications/Util/otbMultiResolutionPyramid.cxx
@@ -18,8 +18,6 @@
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
 
-#include "otbImage.h"
-#include "otbVectorImage.h"
 #include "otbPerBandVectorImageFilter.h"
 #include "itkDiscreteGaussianImageFilter.h"
 #include "itkShrinkImageFilter.h"
@@ -53,9 +51,8 @@ public:
   itkTypeMacro(MultiResolutionPyramid, otb::Application);
 
   /** Image and filters typedef */
-  typedef otb::Image<float>                                         SingleImageType;
-  typedef itk::DiscreteGaussianImageFilter<SingleImageType,
-                                           SingleImageType>         SmoothingImageFilterType;
+  typedef itk::DiscreteGaussianImageFilter<FloatImageType,
+                                           FloatImageType>         SmoothingImageFilterType;
 
   typedef otb::PerBandVectorImageFilter<FloatVectorImageType,
                                         FloatVectorImageType,
diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx
index 9e87af74fb..bb6deb868b 100644
--- a/Code/ApplicationEngine/otbWrapperApplication.cxx
+++ b/Code/ApplicationEngine/otbWrapperApplication.cxx
@@ -37,6 +37,8 @@
 
 #include "otbWrapperAddProcessToWatchEvent.h"
 
+
+#include "otbWrapperTypes.h"
 namespace otb
 {
 namespace Wrapper
diff --git a/Code/ApplicationEngine/otbWrapperApplication.h b/Code/ApplicationEngine/otbWrapperApplication.h
index 17806a3b75..7f8fa5c7ab 100644
--- a/Code/ApplicationEngine/otbWrapperApplication.h
+++ b/Code/ApplicationEngine/otbWrapperApplication.h
@@ -30,6 +30,7 @@
 #include "otbWrapperMacros.h"
 #include "otbWrapperTypes.h"
 #include "otbWrapperOutputImageParameter.h"
+#include "otbWrapperInputImageParameter.h"
 
 namespace otb
 {
@@ -216,14 +217,6 @@ public:
    */
   void SetParameterOutputImage(std::string parameter, FloatVectorImageType* value);
 
-  /* Set an output image value
-   *
-   * Can be called for types :
-   * \li ParameterType_OutputImage
-   */
-  template <class TImageType>
-    void SetParameterOutputImage(std::string parameter, TImageType* value);
-
   /* Set the pixel type in which the image will be saved
    *
    * Can be called for types :
@@ -289,8 +282,45 @@ public:
    * Can be called for types :
    * \li ParameterType_InputImage
    */
-  template <class TImageType>
-    TImageType* GetParameterImage(std::string parameter);
+#define otbGetParameterImageMacro( Image )                              \
+  Image##Type * GetParameter##Image( std::string parameter )            \
+    {                                                                   \
+    Image##Type::Pointer ret;                                           \
+    Parameter* param = GetParameterByKey(parameter);                    \
+    if (dynamic_cast<InputImageParameter*>(param))                      \
+      {                                                                 \
+      InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); \
+      ret = paramDown->Get##Image();                                    \
+      }                                                                 \
+    return ret;                                                         \
+    }
+   
+  otbGetParameterImageMacro(UInt8Image);
+  otbGetParameterImageMacro(Int8Image);
+  otbGetParameterImageMacro(UInt16Image);
+  otbGetParameterImageMacro(Int16Image);
+  otbGetParameterImageMacro(UInt32Image);
+  otbGetParameterImageMacro(Int32Image);
+  otbGetParameterImageMacro(FloatImage);
+  otbGetParameterImageMacro(DoubleImage);
+
+  otbGetParameterImageMacro(UInt8VectorImage);
+  otbGetParameterImageMacro(Int8VectorImage);
+  otbGetParameterImageMacro(UInt16VectorImage);
+  otbGetParameterImageMacro(Int16VectorImage);
+  otbGetParameterImageMacro(UInt32VectorImage);
+  otbGetParameterImageMacro(Int32VectorImage);
+  otbGetParameterImageMacro(FloatVectorImage);
+  otbGetParameterImageMacro(DoubleVectorImage);
+
+  otbGetParameterImageMacro(UInt8RGBAImage);
+  otbGetParameterImageMacro(Int8RGBAImage);
+  otbGetParameterImageMacro(UInt16RGBAImage);
+  otbGetParameterImageMacro(Int16RGBAImage);
+  otbGetParameterImageMacro(UInt32RGBAImage);
+  otbGetParameterImageMacro(Int32RGBAImage);
+  otbGetParameterImageMacro(FloatRGBAImage);
+  otbGetParameterImageMacro(DoubleRGBAImage);
 
 
   /* Get an image list value
@@ -384,6 +414,43 @@ protected:
   /* Set the user level of access to a parameter */
   void SetParameterUserLevel(std::string paramKey, UserLevel level);
 
+  /* Get an image value
+   *
+   * Can be called for types :
+   * \li ParameterType_InputImage
+   */
+  template <class TImageType>
+    TImageType* GetParameterImage(std::string parameter)
+  {
+    typename TImageType::Pointer ret;
+    Parameter* param = GetParameterByKey(parameter);
+    if (dynamic_cast<InputImageParameter*>(param))
+      {
+      InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param);
+      ret = paramDown->GetImage<TImageType>();
+      }
+    
+    //TODO: exception if not found ?
+    return ret;
+  }
+  
+  /* Set an output image value
+   *
+   * Can be called for types :
+   * \li ParameterType_OutputImage
+   */
+  template <class TImageType>
+    void SetParameterOutputImage(std::string parameter, TImageType* value)
+  {
+    Parameter* param = GetParameterByKey(parameter);
+    
+    if (dynamic_cast<OutputImageParameter*>(param))
+      {
+      OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param);
+      paramDown->SetValue(value);
+      }
+  }
+
 private:
   /* Implement this method to add parameters */
   virtual void DoCreateParameters() = 0;
@@ -412,8 +479,8 @@ private:
 } //end namespace otb
 
 
-#ifndef OTB_MANUAL_INSTANTIATION
-#include "otbWrapperApplication.txx"
-#endif
+//#ifndef OTB_MANUAL_INSTANTIATION
+//#include "otbWrapperApplication.txx"
+//#endif
 
 #endif // __otbWrapperApplication_h_
diff --git a/Code/ApplicationEngine/otbWrapperApplication.txx b/Code/ApplicationEngine/otbWrapperApplication.txx
deleted file mode 100644
index 12d21fb4ef..0000000000
--- a/Code/ApplicationEngine/otbWrapperApplication.txx
+++ /dev/null
@@ -1,59 +0,0 @@
-/*=========================================================================
-
-  Program:   ORFEO Toolbox
-  Language:  C++
-  Date:      $Date$
-  Version:   $Revision$
-
-
-  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
-  See OTBCopyright.txt for details.
-
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notices for more information.
-
-=========================================================================*/
-#include "otbWrapperApplication.h"
-
-#include "otbWrapperOutputImageParameter.h"
-#include "otbWrapperInputImageParameter.h"
-//#include "otbWrapperParameterGroup.h"
-
-
-namespace otb
-{
-namespace Wrapper
-{
-
-template <class TImageType>
-void Application::SetParameterOutputImage(std::string parameter, TImageType* value)
-{
-  Parameter* param = GetParameterByKey(parameter);
-
-  if (dynamic_cast<OutputImageParameter*>(param))
-    {
-    OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param);
-    paramDown->SetValue(value);
-    }
-}
-
-template <class TImageType>
-TImageType* Application::GetParameterImage(std::string parameter)
-{
-  typename TImageType::Pointer ret;
-  Parameter* param = GetParameterByKey(parameter);
-
-  if (dynamic_cast<InputImageParameter*>(param))
-    {
-    InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param);
-    ret = paramDown->GetImage<TImageType>();
-    }
-
-  //TODO: exception if not found ?
-  return ret;
-}
-
-}
-}
diff --git a/Code/ApplicationEngine/otbWrapperInputImageParameter.cxx b/Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
index a83d776ce4..db38925881 100644
--- a/Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
+++ b/Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
@@ -29,14 +29,10 @@ namespace Wrapper
 
 InputImageParameter::InputImageParameter()
 {
-  std::cout<<this<<" InputImageParameter::GetImage m_Image.IsNull() "<<m_Image.IsNull()<<std::endl;
-
   this->SetName("Input Image");
   this->SetKey("in");
   m_FileName="";
   this->ClearValue();
-  std::cout<<this<<" InputImageParameter::GetImage m_Image.IsNull() "<<m_Image.IsNull()<<std::endl;
-
 }
 
 InputImageParameter::~InputImageParameter()
@@ -46,7 +42,6 @@ InputImageParameter::~InputImageParameter()
 void
 InputImageParameter::SetFromFileName(const std::string& filename)
 {
-  std::cout<<this<<" InputImageParameter::SetFromFileName"<<std::endl;
   // First clear previous file choosen
   this->ClearValue();
 
@@ -72,23 +67,53 @@ InputImageParameter::SetFromFileName(const std::string& filename)
 }
 
 
+
 FloatVectorImageType*
 InputImageParameter::GetImage()
 {
-  std::cout<<this<<" GetImage<FloatVectorImageType>"<<std::endl;
   return this->GetImage<FloatVectorImageType>();
 }
 
 
+#define otbGetImageMacro(image)                       \
+  image##Type *                                       \
+  InputImageParameter::Get##image ()                  \
+  {                                                   \
+    return this->GetImage< image##Type > ();          \
+  }
+
+otbGetImageMacro(UInt8Image)
+otbGetImageMacro(Int8Image);
+otbGetImageMacro(UInt16Image);
+otbGetImageMacro(Int16Image);
+otbGetImageMacro(UInt32Image);
+otbGetImageMacro(Int32Image);
+otbGetImageMacro(FloatImage);
+otbGetImageMacro(DoubleImage);
+
+otbGetImageMacro(UInt8VectorImage);
+otbGetImageMacro(Int8VectorImage);
+otbGetImageMacro(UInt16VectorImage);
+otbGetImageMacro(Int16VectorImage);
+otbGetImageMacro(UInt32VectorImage);
+otbGetImageMacro(Int32VectorImage);
+otbGetImageMacro(FloatVectorImage);
+otbGetImageMacro(DoubleVectorImage);
+
+otbGetImageMacro(UInt8RGBAImage);
+otbGetImageMacro(Int8RGBAImage);
+otbGetImageMacro(UInt16RGBAImage);
+otbGetImageMacro(Int16RGBAImage);
+otbGetImageMacro(UInt32RGBAImage);
+otbGetImageMacro(Int32RGBAImage);
+otbGetImageMacro(FloatRGBAImage);
+otbGetImageMacro(DoubleRGBAImage);
+
+
 template <class TOutputImage>
 TOutputImage *
 InputImageParameter::GetImage()
 {
-  std::cout<<this<<" InputImageParameter::GetImage inside"<<std::endl;
-  std::cout<<this<<" InputImageParameter::GetImage m_FileName "<<m_FileName<<std::endl;
-  std::cout<<this<<" InputImageParameter::GetImage m_FileName.empty() "<<m_FileName.empty()<<std::endl;
-  std::cout<<this<<" InputImageParameter::GetImage m_Image.IsNull() "<<m_Image.IsNull()<<std::endl;
-
   // 2 cases : the user set a filename vs. the user set an image
   //////////////////////// Filename case:
   if( !m_FileName.empty() )
@@ -107,14 +132,13 @@ InputImageParameter::GetImage()
     
     m_Image = reader->GetOutput();
     m_Reader = reader;
-    
+
     // Pay attention, don't return m_Image because it is a ImageBase...
     return reader->GetOutput();
     }
   //////////////////////// Image case:
   else
     {
-    std::cout<<this<<" GetImage<FloatVectorImageType>"<<std::endl;
     if( m_Image.IsNull() )
       {
       itkExceptionMacro("No input image or filename detected...");
@@ -224,7 +248,6 @@ InputImageParameter::GetImage()
   
       }
     }
-std::cout<<this<<" InputImageParameter::GetImage outside"<<std::endl;
 }
 
 
@@ -1644,8 +1667,7 @@ template <class TInputImage>
 void
 InputImageParameter::SetImage(TInputImage* image)
 {
-std::cout<<this<<" InputImageParameter::SetImage"<<std::endl;
-   m_Image = image;
+  m_Image = image;
 }
 
 
@@ -1661,7 +1683,6 @@ InputImageParameter::HasValue() const
 void
 InputImageParameter::ClearValue()
 {
- std::cout<<this<<" InputImageParameter::ClearValue"<<std::endl;
  m_Image   = NULL;
  m_Reader = NULL;
  m_Caster = NULL;
diff --git a/Code/ApplicationEngine/otbWrapperInputImageParameter.h b/Code/ApplicationEngine/otbWrapperInputImageParameter.h
index 93e386575b..937ec74dad 100644
--- a/Code/ApplicationEngine/otbWrapperInputImageParameter.h
+++ b/Code/ApplicationEngine/otbWrapperInputImageParameter.h
@@ -51,15 +51,42 @@ public:
   void SetFromFileName(const std::string& filename);
   itkGetConstMacro(FileName, std::string);
 
-  /** Get the input image as FloatVectorImageType */
+
+  /** Get the input image as FloatVectorImageType. */
   FloatVectorImageType* GetImage();
-  
+
+  /** Get the input image as XXXImageType */
+  UInt8ImageType* GetUInt8Image();
+  Int8ImageType* GetInt8Image();
+  UInt16ImageType* GetUInt16Image();
+  Int16ImageType* GetInt16Image();
+  UInt32ImageType* GetUInt32Image();
+  Int32ImageType* GetInt32Image();
+  FloatImageType* GetFloatImage();
+  DoubleImageType* GetDoubleImage();
+
+  UInt8VectorImageType* GetUInt8VectorImage();
+  Int8VectorImageType* GetInt8VectorImage();
+  UInt16VectorImageType* GetUInt16VectorImage();
+  Int16VectorImageType* GetInt16VectorImage();
+  UInt32VectorImageType* GetUInt32VectorImage();
+  Int32VectorImageType* GetInt32VectorImage();
+  FloatVectorImageType* GetFloatVectorImage();
+  DoubleVectorImageType* GetDoubleVectorImage();
+ 
+  UInt8RGBAImageType* GetUInt8RGBAImage();
+  Int8RGBAImageType* GetInt8RGBAImage();
+  UInt16RGBAImageType* GetUInt16RGBAImage();
+  Int16RGBAImageType* GetInt16RGBAImage();
+  UInt32RGBAImageType* GetUInt32RGBAImage();
+  Int32RGBAImageType* GetInt32RGBAImage();
+  FloatRGBAImageType* GetFloatRGBAImage();
+  DoubleRGBAImageType* GetDoubleRGBAImage();
+
   /** Get the input image as templated image type. */
   template <class TImageType>
     TImageType* GetImage();
 
-  template <class TOutputImage>
-    TOutputImage* GetImage(unsigned int typeIn);
 
   /** Set a FloatVectorImageType image.*/
   void SetImage(FloatVectorImageType* image);
@@ -160,8 +187,8 @@ protected:
   RGBAFloatReaderType::Pointer  m_RGBAFloatReader;
   RGBADoubleReaderType::Pointer m_RGBADoubleReader;
 */
-  itk::ProcessObject * m_Reader;
-  itk::ProcessObject * m_Caster;
+  itk::ProcessObject::Pointer m_Reader;
+  itk::ProcessObject::Pointer m_Caster;
 
 private:
   InputImageParameter(const Parameter &); //purposely not implemented
-- 
GitLab