diff --git a/Code/FeatureExtraction/otbCloudDetectionFilter.h b/Code/FeatureExtraction/otbCloudDetectionFilter.h
index 35a322c06edf2d56f7163e803f28a33021dfd430..fac04d004039126fcf41417b7982405d30606414 100644
--- a/Code/FeatureExtraction/otbCloudDetectionFilter.h
+++ b/Code/FeatureExtraction/otbCloudDetectionFilter.h
@@ -18,25 +18,23 @@
 #ifndef __otbCloudDetectionFilter_h
 #define __otbCloudDetectionFilter_h
 
-#include "otbSpectralAngleFunctor.h"
+#include "otbCloudDetectionFunctor.h"
 #include "itkUnaryFunctorImageFilter.h"
 
 namespace otb
 {
 /** \class CloudDetectionFilter
- * \brief Apply spectral angle functor to an image.
- * \brief Apply a threshold.
- * \brief Apply a color reversal.
+ * \brief Applies cloud detection functor to an image.
  */
-template <class TInputImage, class TOutputImage, class TFunction = Functor::SpectralAngleFunctor<
-ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> >
+template <class TInputImage, class TOutputImage, class TFunction = Functor::CloudDetectionFunctor< 
+                                          ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> >
 class ITK_EXPORT CloudDetectionFilter : public itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, TFunction >
 {
 public:
   /** Standard class typedefs. */
-  typedef CloudDetectionFilter                           Self;
-  typedef typename itk::UnaryFunctorImageFilter < TInputImage, TOutputImage, TFunction >
-  Superclass;
+  typedef CloudDetectionFilter                          Self;
+  typedef typename itk::UnaryFunctorImageFilter < TInputImage, TOutputImage, TFunction > 
+                                                        Superclass;
   typedef itk::SmartPointer<Self>                       Pointer;
   typedef itk::SmartPointer<const Self>                 ConstPointer;
 
@@ -57,15 +55,18 @@ public:
 
   /** Getters/Setters */
   void SetReferencePixel( InputPixelType ref );
-  InputPixelType GetReferencePixel();
   void SetVariance( double var );
+  void SetMinThreshold(double threshold);
+  void SetMaxThreshold(double threshold);
+  InputPixelType GetReferencePixel();
+  double GetMinThreshold();
+  double GetMaxThreshold();
   double GetVariance();
 
-
 protected:
   CloudDetectionFilter();
 
-  virtual ~CloudDetectionFilter() {};
+  virtual ~CloudDetectionFilter(){};
 
   virtual void BeforeThreadedGenerateData();
 
diff --git a/Code/FeatureExtraction/otbCloudDetectionFilter.txx b/Code/FeatureExtraction/otbCloudDetectionFilter.txx
index 08f0a5d66bbed3277745916e7b742e5f4bf09a0a..3a9ea8c6f79f4a4c0e982572f4b0e0ced8058c03 100644
--- a/Code/FeatureExtraction/otbCloudDetectionFilter.txx
+++ b/Code/FeatureExtraction/otbCloudDetectionFilter.txx
@@ -41,9 +41,7 @@ void
 CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
-
   this->Superclass::PrintSelf(os,indent);
-
 }
 
 /**
@@ -54,7 +52,6 @@ void
 CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
 ::BeforeThreadedGenerateData()
 {
-
   unsigned int ReferencePixelNumberOfBands = 0;
   ReferencePixelNumberOfBands = this->GetReferencePixel().GetSize();
 
@@ -62,7 +59,6 @@ CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
   {
     itkExceptionMacro("The number of bands of the reference pixel is different from the number of bands of the input image. ");
   }
-
 }
 
 /**
@@ -109,6 +105,41 @@ CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
   return this->GetFunctor().GetReferencePixel();
 }
 
+/**
+ * SetMinThreshold
+ */
+template <class TInputImage, class TOutputImage, class TFunction>
+void
+CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
+::SetMinThreshold(double threshold){ this->GetFunctor().SetMinThreshold(threshold); }
+
+/**
+ * SetMaxThreshold
+ */
+template <class TInputImage, class TOutputImage, class TFunction>
+void
+CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
+::SetMaxThreshold(double threshold){ this->GetFunctor().SetMaxThreshold(threshold); }
+
+/**
+ * GetMinThreshold
+ */
+template <class TInputImage, class TOutputImage, class TFunction>
+double
+CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
+::GetMinThreshold(){  return this->GetFunctor().GetMinThreshold(); }
+
+/**
+ * GetMaxThreshold
+ */
+template <class TInputImage, class TOutputImage, class TFunction>
+double
+CloudDetectionFilter<TInputImage,TOutputImage,TFunction>
+::GetMaxThreshold()
+{
+  return this->GetFunctor().GetMaxThreshold();
+}
+
 }
 
 #endif
diff --git a/Code/FeatureExtraction/otbCloudDetectionFunctor.h b/Code/FeatureExtraction/otbCloudDetectionFunctor.h
index 5a71d53b4a4e5f982ca0f06e759fda69a9d929c3..2237335b9ae3fc78ccbd8cf6169ebe7826a069db 100644
--- a/Code/FeatureExtraction/otbCloudDetectionFunctor.h
+++ b/Code/FeatureExtraction/otbCloudDetectionFunctor.h
@@ -19,125 +19,56 @@
 #define __otbCloudDetectionFunctor_h
 
 #include "otbMath.h"
-#include "otbSpectralAngleFunctor.h"
+#include "otbCloudEstimatorFunctor.h"
 
 namespace otb
 {
-/** \class CloudDetectionFunctor
- *  \brief This functor first computes the spectral angle according to a reference pixel.
- *  \brief Then multiplies the result by a gaussian coefficient
- *  \brief Binarise the image with a threshold
- *  \brief And reverse the pixel values.
- */
+  /** \class CloudDetectionFunctor
+   *  \brief This functor first uses CloudEstimatorFunctor
+   *  \brief And then binarise the image with two thresholds
+   */
 namespace Functor
 {
 template<class TInput,class TOutputValue>
 class CloudDetectionFunctor
 {
-public:
-  typedef SpectralAngleFunctor<TInput, TOutputValue> SpectralAngleFunctorType;
+ public:
+  typedef CloudEstimatorFunctor<TInput, TOutputValue> CloudEstimatorFunctorType;
 
   CloudDetectionFunctor()
-  {
-    m_ReferencePixel.SetSize(4);
-    m_ReferencePixel.Fill(1);
-    m_RefNorm = 2.0;
-    m_Variance = 1.0;
-    m_Denom = 1.0;
-    m_Coef = 1.0;
-
-    maxigauss = 0;
-    maxi = 0;
-    minigauss = 100000;
-    mini = 100000;
-
-  };
-
-  ~CloudDetectionFunctor() {};
-  inline TOutputValue operator()(const TInput& inPix)
-  {
-
-    TOutputValue lOut;
-    double lRes = 0.0;
-    double lCurPixNorm = 0.0;
-    double lGaussianCoef = 1.0;
-
-    for (unsigned int i=0; i<std::min(inPix.Size(),m_ReferencePixel.Size()); i++)
-    {
-      lCurPixNorm += inPix[i]*inPix[i];
-    }
-    lCurPixNorm = vcl_sqrt(static_cast<double>(lCurPixNorm));
-    lGaussianCoef = m_Coef * vcl_exp(- vcl_pow(((lCurPixNorm-m_RefNorm)/m_RefNorm),2) / m_Denom ) ;
-    lRes =  lGaussianCoef * (M_PI-m_SpectralAngleFunctor(inPix));
-
-    if (lGaussianCoef > maxigauss)
-    {
-      maxigauss=lGaussianCoef;
-      std::cout <<"maxigauss" << maxigauss << std::endl;
-    }
-    if (lRes > maxi)
     {
-      maxi=lRes;
-      std::cout <<"maxi"<< maxi << std::endl;
-    }
+      m_MinThreshold = 1.0;
+      m_MaxThreshold = 1.0;
+    };
 
-    if (lGaussianCoef < minigauss)
-    {
-      minigauss=lGaussianCoef;
-      std::cout <<"minigauss"<< minigauss << std::endl;
-    }
-    if (lRes < mini)
+  ~CloudDetectionFunctor(){};
+  inline TOutputValue operator()(const TInput& inPix)
     {
-      mini=lRes;
-      std::cout <<"mini"<< mini << std::endl;
+      if( (m_CloudEstimatorFunctor(inPix)>m_MinThreshold) && (m_CloudEstimatorFunctor(inPix)<m_MaxThreshold) )
+      {
+        return 1;
+      }
+      else 
+      {
+        return 0;
+      }
     }
 
-//       lRes = ( (-1)*(lRes/M_PI) ) +1 ;
+  void SetReferencePixel( TInput ref ){ m_CloudEstimatorFunctor.SetReferencePixel(ref); };
+  void SetVariance(double variance){ m_CloudEstimatorFunctor.SetVariance(variance); };
+  void SetMinThreshold(double threshold){ m_MinThreshold = threshold; };
+  void SetMaxThreshold(double threshold){ m_MaxThreshold = threshold; };
+  double GetMinThreshold(){ return m_MinThreshold; };
+  double GetMaxThreshold(){ return m_MaxThreshold; };
+  double GetVariance(){ return m_CloudEstimatorFunctor.GetVariance(); };
+  TInput GetReferencePixel(){ return m_CloudEstimatorFunctor.GetReferencePixel(); };
 
-    lOut = static_cast<TOutputValue>(lRes);
-    return lOut;
 
-  }
+ protected:
+  CloudEstimatorFunctorType m_CloudEstimatorFunctor;
+  double m_MinThreshold;
+  double m_MaxThreshold;
 
-  void SetReferencePixel( TInput ref )
-  {
-    m_ReferencePixel = ref;
-    m_SpectralAngleFunctor.SetReferencePixel(ref);
-    m_RefNorm = 0.0;
-    for (unsigned int i = 0; i<ref.Size(); i++)
-    {
-      m_RefNorm += ref[i]*ref[i];
-    }
-    m_RefNorm = vcl_sqrt(static_cast<double>(m_RefNorm));
-  };
-  void SetVariance(double variance)
-  {
-    m_Variance = variance;
-    m_Denom = 2 * variance * variance;
-    m_Coef = 1/( variance * vcl_sqrt(2*M_PI) );
-  }
-
-  TInput GetReferencePixel()
-  {
-    return m_ReferencePixel;
-  };
-  double GetVariance()
-  {
-    return m_Variance;
-  };
-
-
-protected:
-  SpectralAngleFunctorType m_SpectralAngleFunctor;
-  TInput m_ReferencePixel;
-  double m_RefNorm;
-  double m_Variance;
-  double m_Denom;
-  double m_Coef;
-  double  maxi;
-  double maxigauss;
-  double  mini;
-  double minigauss;
 };
 
 } // end namespace functor
diff --git a/Code/FeatureExtraction/otbCloudEstimatorFilter.h b/Code/FeatureExtraction/otbCloudEstimatorFilter.h
index a32ded658fc163c999bd0c69a1847471fde6077b..5ba05ec53b6300910b58adb2e0710a8d78e338d1 100644
--- a/Code/FeatureExtraction/otbCloudEstimatorFilter.h
+++ b/Code/FeatureExtraction/otbCloudEstimatorFilter.h
@@ -28,15 +28,15 @@ namespace otb
  * \brief Multiplies by a gaussian coefficient
  * \brief Applies a color reversal.
  */
-template <class TInputImage, class TOutputImage, class TFunction = Functor::SpectralAngleFunctor<
-ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> >
+template <class TInputImage, class TOutputImage, class TFunction = Functor::SpectralAngleFunctor< 
+                                          ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> >
 class ITK_EXPORT CloudEstimatorFilter : public itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, TFunction >
 {
 public:
   /** Standard class typedefs. */
   typedef CloudEstimatorFilter                          Self;
-  typedef typename itk::UnaryFunctorImageFilter < TInputImage, TOutputImage, TFunction >
-  Superclass;
+  typedef typename itk::UnaryFunctorImageFilter < TInputImage, TOutputImage, TFunction > 
+                                                        Superclass;
   typedef itk::SmartPointer<Self>                       Pointer;
   typedef itk::SmartPointer<const Self>                 ConstPointer;
 
@@ -64,7 +64,7 @@ public:
 protected:
   CloudEstimatorFilter();
 
-  virtual ~CloudEstimatorFilter() {};
+  virtual ~CloudEstimatorFilter(){};
 
   virtual void BeforeThreadedGenerateData();
 
diff --git a/Code/FeatureExtraction/otbCloudEstimatorFunctor.h b/Code/FeatureExtraction/otbCloudEstimatorFunctor.h
index b50b41f98f416918b8bdd4d9a9b11724d81d5e51..d94db3d7be8fff58c8d36da72479a283539f8dcb 100644
--- a/Code/FeatureExtraction/otbCloudEstimatorFunctor.h
+++ b/Code/FeatureExtraction/otbCloudEstimatorFunctor.h
@@ -23,121 +23,84 @@
 
 namespace otb
 {
-/** \class CloudEstimatorFunctor
- *  \brief This functor first computes the spectral angle according to a reference pixel.
- *  \brief Then multiplies the result by a gaussian coefficient
- *  \brief Binarise the image with a threshold
- *  \brief And reverse the pixel values.
- */
+  /** \class CloudEstimatorFunctor
+   *  \brief This functor first computes the spectral angle according to a reference pixel.
+   *  \brief Then multiplies the result by a gaussian coefficient
+   *  \brief And reverse the pixel values.
+   */
 namespace Functor
 {
 template<class TInput,class TOutputValue>
 class CloudEstimatorFunctor
 {
-public:
+ public:
   typedef SpectralAngleFunctor<TInput, TOutputValue> SpectralAngleFunctorType;
 
   CloudEstimatorFunctor()
-  {
-    m_ReferencePixel.SetSize(4);
-    m_ReferencePixel.Fill(1);
-    m_RefNorm = 2.0;
-    m_Variance = 1.0;
-    m_Denom = 1.0;
-    m_Coef = 1.0;
-
-    maxigauss = 0;
-    maxi = 0;
-    minigauss = 100000;
-    mini = 100000;
-
-  };
-
-  ~CloudEstimatorFunctor() {};
+    {
+      m_ReferencePixel.SetSize(4);
+      m_ReferencePixel.Fill(1);
+      m_RefNorm = 2.0;
+      m_Variance = 1.0;
+      m_Denom = 1.0;
+      m_Coef = 1.0;
+    };
+
+  ~CloudEstimatorFunctor(){};
   inline TOutputValue operator()(const TInput& inPix)
-  {
-
-    TOutputValue lOut;
-    double lRes = 0.0;
-    double lCurPixNorm = 0.0;
-    double lGaussianCoef = 1.0;
-
-    for (unsigned int i=0; i<std::min(inPix.Size(),m_ReferencePixel.Size()); i++)
     {
-      lCurPixNorm += inPix[i]*inPix[i];
-    }
-    lCurPixNorm = vcl_sqrt(static_cast<double>(lCurPixNorm));
-    lGaussianCoef = m_Coef * vcl_exp(- vcl_pow(((lCurPixNorm-m_RefNorm)/m_RefNorm),2) / m_Denom ) ;
-    lRes =  lGaussianCoef * (M_PI-m_SpectralAngleFunctor(inPix));
 
-    if (lGaussianCoef > maxigauss)
-    {
-      maxigauss=lGaussianCoef;
-      std::cout << maxigauss << std::endl;
-    }
-    if (lRes > maxi)
-    {
-      maxi=lRes;
-      std::cout << maxi << std::endl;
-    }
+      TOutputValue lOut;
+      double lRes = 0.0;
+      double lCurPixNorm = 0.0;
+      double lGaussianCoef = 1.0;
 
-    if (lGaussianCoef < minigauss)
-    {
-      minigauss=lGaussianCoef;
-      std::cout << minigauss << std::endl;
-    }
-    if (lRes < mini)
-    {
-      mini=lRes;
-      std::cout << mini << std::endl;
-    }
+      // Compute the Gaussian Coef
+      for (unsigned int i=0; i<std::min(inPix.Size(),m_ReferencePixel.Size()); i++)
+      {
+        lCurPixNorm += inPix[i]*inPix[i];
+      }
+      lCurPixNorm = vcl_sqrt(static_cast<double>(lCurPixNorm));
+      lGaussianCoef = m_Coef * vcl_exp(- vcl_pow(((lCurPixNorm-m_RefNorm)/m_RefNorm),2) / m_Denom ) ;
 
-//       lRes = ( (-1)*(lRes/M_PI) ) +1 ;
+      // Reverse the SpectralAngle values and set them between [0;1]
+      lRes =  lGaussianCoef * ((M_PI-m_SpectralAngleFunctor(inPix)) / M_PI);
 
-    lOut = static_cast<TOutputValue>(lRes);
-    return lOut;
+      lOut = static_cast<TOutputValue>(lRes);
+      return lOut;
 
-  }
+    }
 
   void SetReferencePixel( TInput ref )
-  {
-    m_ReferencePixel = ref;
-    m_SpectralAngleFunctor.SetReferencePixel(ref);
-    m_RefNorm = 0.0;
-    for (unsigned int i = 0; i<ref.Size(); i++)
+    { 
+      m_ReferencePixel = ref;
+      m_SpectralAngleFunctor.SetReferencePixel(ref);
+      m_RefNorm = 0.0;
+      for(unsigned int i = 0; i<ref.Size(); i++)
     {
       m_RefNorm += ref[i]*ref[i];
     }
-    m_RefNorm = vcl_sqrt(static_cast<double>(m_RefNorm));
-  };
+      m_RefNorm = vcl_sqrt(static_cast<double>(m_RefNorm)); 
+    };
+
   void SetVariance(double variance)
-  {
-    m_Variance = variance;
-    m_Denom = 2 * variance * variance;
-    m_Coef = 1/( variance * vcl_sqrt(2*M_PI) );
-  }
-
-  TInput GetReferencePixel()
-  {
-    return m_ReferencePixel;
-  };
-  double GetVariance()
-  {
-    return m_Variance;
-  };
-
-
-protected:
+    {
+      m_Variance = variance;
+      m_Denom = 2 * variance * variance;
+      m_Coef = 1/( variance * vcl_sqrt(2*M_PI) );
+    }
+
+  TInput GetReferencePixel(){ return m_ReferencePixel; };
+  double GetVariance(){ return m_Variance; };
+
+ protected:
   SpectralAngleFunctorType m_SpectralAngleFunctor;
   TInput m_ReferencePixel;
   double m_RefNorm;
   double m_Variance;
   double m_Denom;
   double m_Coef;
-  double  maxi;
-  double maxigauss;
-  double  mini;
-  double minigauss;
+
 };
 
 } // end namespace functor
diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt
index f86e9fa9ac3cc6fc961054023c50885638257a99..374c6914d3dbbfada0e001ccdde38875d4b95617 100644
--- a/Testing/Code/FeatureExtraction/CMakeLists.txt
+++ b/Testing/Code/FeatureExtraction/CMakeLists.txt
@@ -981,10 +981,10 @@ ADD_TEST(feTuLandmarkNew ${FEATUREEXTRACTION_TESTS10}
 
 
 # -------            otb::CloudEstimatorFilterNew   -------------
-ADD_TEST(feTuCloudEstimatorFilterNew ${FEATUREEXTRACTION_TESTS11}
+ADD_TEST(feTuCloudEstimatorFilterNew ${FEATUREEXTRACTION_TESTS11} 
     otbCloudEstimatorFilterNew)
 
-ADD_TEST(feTvCloudEstimatorDefaultFilter ${FEATUREEXTRACTION_TESTS11}
+ADD_TEST(feTvCloudEstimatorDefaultFilter ${FEATUREEXTRACTION_TESTS11} 
 --compare-image ${EPS}
      ${BASELINE}/feTvSpectralAngleOutput.tif
      ${TEMP}/feTvSpectralAngleOutput.tif
@@ -997,7 +997,7 @@ ADD_TEST(feTvCloudEstimatorDefaultFilter ${FEATUREEXTRACTION_TESTS11}
     632
 )
 
-ADD_TEST(feTvCloudEstimatorFilter ${FEATUREEXTRACTION_TESTS11}
+ADD_TEST(feTvCloudEstimatorFilter ${FEATUREEXTRACTION_TESTS11} 
 --compare-image ${EPS}
      ${BASELINE}/feTvCloudEstimatorOutput.tif
      ${TEMP}/feTvCloudEstimatorOutput.tif
@@ -1008,25 +1008,29 @@ ADD_TEST(feTvCloudEstimatorFilter ${FEATUREEXTRACTION_TESTS11}
     731
     500
     632
-    10    # variance
+    0.20    # variance
 )
 
 # -------            otb::CloudDetectionFilterNew   -------------
 
-# ADD_TEST(feTvCloudEstimatorFilter ${FEATUREEXTRACTION_TESTS11}
-# --compare-image ${EPS}
-#      ${BASELINE}/feTvCloudDetectionOutput.tif
-#      ${TEMP}/feTvCloudDetectionOutput.tif
-#     otbCloudDetectionFilter
-#     ${INPUTDATA}/ExtrZoneNuageuse.tif
-#     ${TEMP}/feTvCloudDetectionOutput.tif
-#     500
-#     731
-#     500
-#     632
-#     10    # variance
-#     10    # threshold
-# )
+ADD_TEST(feTuCloudDetectionFilterNew ${FEATUREEXTRACTION_TESTS11} 
+    otbCloudDetectionFilterNew)
+
+ADD_TEST(feTvCloudDetectionFilter ${FEATUREEXTRACTION_TESTS11} 
+ --compare-image ${EPS}
+      ${BASELINE}/feTvCloudDetectionOutput.tif
+      ${TEMP}/feTvCloudDetectionOutput.tif
+     otbCloudDetectionFilter
+     ${INPUTDATA}/ExtrZoneNuageuse.tif
+     ${TEMP}/feTvCloudDetectionOutput.tif
+     500
+     731
+     500
+     632
+     0.20   # variance
+     1.2    # minthreshold
+     2.0    # maxthreshold
+ )
 
 
 ADD_TEST(feTpSimplifyManyPathListFilter ${FEATUREEXTRACTION_TESTS11}
@@ -1193,8 +1197,8 @@ SET(BasicFeatureExtraction_SRCS11
 otbCloudEstimatorFilterNew.cxx
 otbCloudEstimatorDefaultFilter.cxx
 otbCloudEstimatorFilter.cxx
-#otbCloudDetectionFilterNew.cxx
-#otbCloudDetectionFilter.cxx
+otbCloudDetectionFilterNew.cxx
+otbCloudDetectionFilter.cxx
 otbSimplifyManyPathListFilter.cxx
 otbEnergyTextureFunctor.cxx
 otbEnergyTextureImageFunctionNew.cxx
diff --git a/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx b/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
index 20dfa32b24f213ccfd94446e1c5f2df498122a47..5a0e0d5edf51ae874b4c0c201103ad80bf3885d3 100644
--- a/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
+++ b/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
@@ -19,7 +19,7 @@
 
 #include "otbVectorImage.h"
 #include "otbImage.h"
-#include "otbSpectralAngleFunctor.h"
+#include "otbCloudDetectionFunctor.h"
 #include "otbCloudDetectionFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
@@ -32,7 +32,8 @@ int otbCloudDetectionFilter(int argc, char * argv[])
   typedef otb::VectorImage<PixelType,Dimension>                                  VectorImageType;
   typedef otb::Image<PixelType,Dimension>                                        ImageType;
   typedef VectorImageType::PixelType                                             VectorPixelType;
-  typedef otb::CloudDetectionFilter<VectorImageType,ImageType >                  CloudDetectionFilterType;
+  typedef otb::Functor::CloudDetectionFunctor<VectorPixelType,PixelType >        FunctorType;
+  typedef otb::CloudDetectionFilter<VectorImageType,ImageType,FunctorType >      CloudDetectionFilterType;
   typedef otb::ImageFileReader<VectorImageType>                                  ReaderType;
   typedef otb::ImageFileWriter<ImageType>                                        WriterType;
 
@@ -49,10 +50,10 @@ int otbCloudDetectionFilter(int argc, char * argv[])
   referencePixel[3] = (atof(argv[6]));
 
   const double variance = (atof(argv[7]));
-  const double threshold = ::atof(argv[8]);
+  const double minThreshold = (atof(argv[8]));
+  const double maxThreshold = (atof(argv[9]));
 
-
-  // Instantiating object
+ // Instantiating object
   ReaderType::Pointer reader = ReaderType::New();
   CloudDetectionFilterType::Pointer cloudDetection = CloudDetectionFilterType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -62,13 +63,15 @@ int otbCloudDetectionFilter(int argc, char * argv[])
 
   cloudDetection->SetInput(reader->GetOutput());
   cloudDetection->SetReferencePixel(referencePixel);
+  cloudDetection->SetMinThreshold(minThreshold);
+  cloudDetection->SetMaxThreshold(maxThreshold);
   cloudDetection->SetVariance(variance);
-  cloudDetection->SetThreshold(threshold);
+
 
   writer->SetFileName(outputFileName);
   writer->SetInput(cloudDetection->GetOutput());
   writer->Update();
 
-
   return EXIT_SUCCESS;
+
 }
diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx
index 1d0d7b7c4a42122baf0ed537f7a3668bc1676a75..cba71ce7675948a7cfc687f08921fb47f774b2a3 100644
--- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx
+++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx
@@ -30,8 +30,8 @@ void RegisterTests()
 REGISTER_TEST(otbCloudEstimatorFilterNew);
 REGISTER_TEST(otbCloudEstimatorDefaultFilter);
 REGISTER_TEST(otbCloudEstimatorFilter);
-/*REGISTER_TEST(otbCloudDetectionFilterNew);
-REGISTER_TEST(otbCloudDetectionFilter);*/
+REGISTER_TEST(otbCloudDetectionFilterNew);
+REGISTER_TEST(otbCloudDetectionFilter);
 REGISTER_TEST(otbSimplifyManyPathListFilter);
 REGISTER_TEST(otbEnergyTextureFunctor);
 REGISTER_TEST(otbEnergyTextureImageFunctionNew);