From 1d455956b496dd27c87e148d727bf7d0b0fec2ad Mon Sep 17 00:00:00 2001
From: Guillaume Borrut <guillaume.borrut@c-s.fr>
Date: Tue, 27 Jan 2009 18:12:34 +0100
Subject: [PATCH] ENH: Adding CloudDetectionFilter with SpectralAngle functor

---
 .../otbCloudDetectionFilter.h                 | 101 ++++++++++++++++++
 .../otbCloudDetectionFilter.txx               |  78 ++++++++++++++
 Testing/Code/FeatureExtraction/CMakeLists.txt |  99 ++++++++++++-----
 .../otbCloudDetectionFilter.cxx               |  74 +++++++++++++
 .../otbCloudDetectionFilterNew.cxx            |  36 +++++++
 .../otbFeatureExtractionTests10.cxx           |  39 +++++++
 .../otbFeatureExtractionTests11.cxx           |  32 ++++++
 .../otbFeatureExtractionTests9.cxx            |   9 --
 8 files changed, 430 insertions(+), 38 deletions(-)
 create mode 100644 Code/FeatureExtraction/otbCloudDetectionFilter.h
 create mode 100644 Code/FeatureExtraction/otbCloudDetectionFilter.txx
 create mode 100644 Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
 create mode 100644 Testing/Code/FeatureExtraction/otbCloudDetectionFilterNew.cxx
 create mode 100644 Testing/Code/FeatureExtraction/otbFeatureExtractionTests10.cxx
 create mode 100644 Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx

diff --git a/Code/FeatureExtraction/otbCloudDetectionFilter.h b/Code/FeatureExtraction/otbCloudDetectionFilter.h
new file mode 100644
index 0000000000..d8ed658abe
--- /dev/null
+++ b/Code/FeatureExtraction/otbCloudDetectionFilter.h
@@ -0,0 +1,101 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+#ifndef __otbCloudDetectionFilter_h
+#define __otbCloudDetectionFilter_h
+
+#include "otbSpectralAngleFunctor.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.
+ */
+template <class TInputImage, class TOutputImage>
+class ITK_EXPORT CloudDetectionFilter :  public itk::UnaryFunctorImageFilter< TInputImage, TOutputImage,                                       /* TFunction =*/ Functor::SpectralAngleFunctor< ITK_TYPENAME TInputImage::PixelType, 
+                                                    ITK_TYPENAME TOutputImage::PixelType> >
+{
+public:
+  /** Standard class typedefs. */
+  typedef CloudDetectionFilter                           Self;
+  typedef typename itk::UnaryFunctorImageFilter < TInputImage,
+                                                  TOutputImage,
+                                                    Functor::SpectralAngleFunctor < typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass;
+
+  typedef itk::SmartPointer<Self>                       Pointer;
+  typedef itk::SmartPointer<const Self>                 ConstPointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(CloudDetectionFilter,UnaryFunctorImageFilter);
+
+  /** Some convenient typedefs. */
+  typedef          TInputImage                    InputImageType;
+  typedef typename InputImageType::Pointer        InputImagePointer;
+  typedef typename InputImageType::PixelType      InputPixelType;
+  typedef          TOutputImage                   OutputImageType;
+  typedef typename OutputImageType::Pointer       OutputImagePointer;
+  typedef typename OutputImageType::RegionType    OutputImageRegionType;
+  typedef typename OutputImageType::PixelType     OutputPixelType;
+
+ 
+  itkSetMacro(Variance, double);
+  itkGetMacro(Variance, double);
+  itkSetMacro(Threshold, double);
+  itkGetMacro(Threshold, double);
+
+  void SetReferencePixel( InputPixelType ref ){ this->GetFunctor().SetReferencePixel( ref ); };
+  InputPixelType GetReferencePixel(){ return this->GetFunctor().GetReferencePixel(); };
+  
+/*  void SetVariance(double var){ this->GetFunctor().SetVariance( var ); };
+  double GetVariance(){ return this->GetFunctor().GetVariance();
+*/
+
+protected:
+  CloudDetectionFilter();
+
+  virtual ~CloudDetectionFilter(){};
+
+  virtual void BeforeThreadedGenerateData();
+
+  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
+
+private:
+  CloudDetectionFilter(const Self&); //purposely not implemented
+  void operator=(const Self&); //purposely not implemented
+
+  /** Gaussian parameter */
+  double m_Variance;
+
+  /** Threshold for the binary image */
+  double m_Threshold;
+
+};
+
+} // end namespace otb
+
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbCloudDetectionFilter.txx"
+#endif
+
+#endif
+
diff --git a/Code/FeatureExtraction/otbCloudDetectionFilter.txx b/Code/FeatureExtraction/otbCloudDetectionFilter.txx
new file mode 100644
index 0000000000..e984d526dd
--- /dev/null
+++ b/Code/FeatureExtraction/otbCloudDetectionFilter.txx
@@ -0,0 +1,78 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+#ifndef __otbCloudDetectionFilter_txx
+#define __otbCloudDetectionFilter_txx
+
+#include "otbCloudDetectionFilter.h"
+
+
+namespace otb
+{
+
+/**
+ * Constructor
+ */
+template <class TInputImage,class TOutputImage>
+CloudDetectionFilter<TInputImage,TOutputImage>
+::CloudDetectionFilter()
+{
+
+  this->SetThreshold(1000);
+  this->SetVariance(1);
+
+}
+
+/**
+ * Printself
+ */
+template <class TInputImage,class TOutputImage>
+void
+CloudDetectionFilter<TInputImage,TOutputImage>
+::PrintSelf(std::ostream& os, itk::Indent indent) const
+{
+
+  this->Superclass::PrintSelf(os,indent);
+  os << indent << "Variance  : " << m_Variance  <<std::endl;
+  os << indent << "Threshold : " << m_Threshold <<std::endl;
+
+}
+
+/**
+ * BeforeThreadedGenerateData
+ */
+template <class TInputImage,class TOutputImage >
+void
+CloudDetectionFilter<TInputImage,TOutputImage>
+::BeforeThreadedGenerateData()
+{
+
+  unsigned int ReferencePixelNumberOfBands = 0;
+  ReferencePixelNumberOfBands = this->GetReferencePixel().GetSize();
+
+  if ( ReferencePixelNumberOfBands != this->GetInput()->GetNumberOfComponentsPerPixel() )
+  {
+    itkExceptionMacro("The number of bands of the reference pixel is different from the number of bands of the input image. ");
+  }
+
+}
+
+
+}
+
+#endif
+
diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt
index 480ec30382..0948d9aa91 100644
--- a/Testing/Code/FeatureExtraction/CMakeLists.txt
+++ b/Testing/Code/FeatureExtraction/CMakeLists.txt
@@ -25,7 +25,8 @@ SET(FEATUREEXTRACTION_TESTS6 ${CXX_TEST_PATH}/otbFeatureExtractionTests6)
 SET(FEATUREEXTRACTION_TESTS7 ${CXX_TEST_PATH}/otbFeatureExtractionTests7)
 SET(FEATUREEXTRACTION_TESTS8 ${CXX_TEST_PATH}/otbFeatureExtractionTests8)
 SET(FEATUREEXTRACTION_TESTS9 ${CXX_TEST_PATH}/otbFeatureExtractionTests9)
-
+SET(FEATUREEXTRACTION_TESTS10 ${CXX_TEST_PATH}/otbFeatureExtractionTests10)
+SET(FEATUREEXTRACTION_TESTS11 ${CXX_TEST_PATH}/otbFeatureExtractionTests11)
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbFeatureExtractionTests1 ~~~~~~~~~~~~~~~~~~~~~
@@ -874,13 +875,34 @@ ADD_TEST(feTvImageToHessianDeterminantImageFilter ${FEATUREEXTRACTION_TESTS9}
 	 1.5
 		 )
 
+
+# -------            otb::ImageFittingPolygonListFilter   -------------
+ADD_TEST(feTuImageFittingPolygonListFilterNew ${FEATUREEXTRACTION_TESTS9} 
+         otbImageFittingPolygonListFilterNew)
+
+ADD_TEST(feTvImageFittingPolygonListFilter ${FEATUREEXTRACTION_TESTS9}
+--compare-ascii ${EPS}
+        ${BASELINE_FILES}/feTvImageFittingPolygonListFilter_Output.kml
+        ${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
+         otbImageFittingPolygonListFilter
+        ${INPUTDATA}/polygon.png
+        ${INPUTDATA}/polygon-start.kml
+        ${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
+        5 10
+)
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbFeatureExtractionTests10 ~~~~~~~~~~~~~~~~~~~~~
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+
 # -------            otb::ImageToSURFKeyPointSetFilterNew   -------------
 
-ADD_TEST(feTuImageToSURFKeyPointSetFilterNew ${FEATUREEXTRACTION_TESTS9} 
+ADD_TEST(feTuImageToSURFKeyPointSetFilterNew ${FEATUREEXTRACTION_TESTS10} 
          otbImageToSURFKeyPointSetFilterNew)
 
 
-ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputInterestPointAscii ${FEATUREEXTRACTION_TESTS9}
+ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputInterestPointAscii ${FEATUREEXTRACTION_TESTS10}
 --compare-ascii ${EPS}
 		${BASELINE_FILES}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputInterestPoint.txt
 		${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputInterestPoint.txt
@@ -890,7 +912,7 @@ ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputInterestPointAscii ${FEATURE
 		1 3 
 )
 
-ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUREEXTRACTION_TESTS9}
+ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUREEXTRACTION_TESTS10}
 --compare-ascii ${EPS}
 		${BASELINE_FILES}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputDescriptor.txt
 		${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputDescriptor.txt
@@ -900,27 +922,14 @@ ADD_TEST(feTvImageToSURFKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUREEXT
 		1 3 
 )
 	 
-# -------            otb::ImageFittingPolygonListFilter   -------------
-ADD_TEST(feTuImageFittingPolygonListFilterNew ${FEATUREEXTRACTION_TESTS9} 
-         otbImageFittingPolygonListFilterNew)
 
-ADD_TEST(feTvImageFittingPolygonListFilter ${FEATUREEXTRACTION_TESTS9}
---compare-ascii ${EPS}
-		${BASELINE_FILES}/feTvImageFittingPolygonListFilter_Output.kml
-		${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
-         otbImageFittingPolygonListFilter
-		${INPUTDATA}/polygon.png
-		${INPUTDATA}/polygon-start.kml
-		${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
-		5 10
-)
 
 # -------            otb::ImageToFastSIFTKeyPointSetFilter   -------------
 
-ADD_TEST(feTuImageToFastSIFTKeyPointSetFilterNew ${FEATUREEXTRACTION_TESTS9} 
+ADD_TEST(feTuImageToFastSIFTKeyPointSetFilterNew ${FEATUREEXTRACTION_TESTS10} 
          otbImageToFastSIFTKeyPointSetFilterNew)
 
-ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUREEXTRACTION_TESTS9}
+ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUREEXTRACTION_TESTS10}
 --compare-ascii ${EPS}
 		${BASELINE_FILES}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
 		${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
@@ -930,7 +939,7 @@ ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputDescriptorAscii ${FEATUR
 		6  
 )
 
-ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputInterestPointAscii ${FEATUREEXTRACTION_TESTS9}
+ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputInterestPointAscii ${FEATUREEXTRACTION_TESTS10}
 --compare-ascii ${EPS}
 		${BASELINE_FILES}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
 		${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
@@ -942,13 +951,11 @@ ADD_TEST(feTvImageToFastSIFTKeyPointSetFilterSceneOutputInterestPointAscii ${FEA
 
 
 
-
-
 # --------- MatchingFilter ----------------
-ADD_TEST(KeyPointSetsMatchingFilterNew ${FEATUREEXTRACTION_TESTS9} 
+ADD_TEST(feTuKeyPointSetsMatchingFilterNew ${FEATUREEXTRACTION_TESTS10} 
 	otbKeyPointSetsMatchingFilterNew)
 
-ADD_TEST(KeyPointSetsMatchingFilter ${FEATUREEXTRACTION_TESTS9}
+ADD_TEST(feTvKeyPointSetsMatchingFilter ${FEATUREEXTRACTION_TESTS10}
 --compare-ascii ${EPS}				   
 	${BASELINE}/feTvKeyPointSetsMatchingFilterOutputAscii.txt
 	${TEMP}/feTvKeyPointSetsMatchingFilterOutputAscii.txt	
@@ -958,8 +965,32 @@ ADD_TEST(KeyPointSetsMatchingFilter ${FEATUREEXTRACTION_TESTS9}
 )
 	
 #--------- LandMark
-ADD_TEST(LandmarkNew ${FEATUREEXTRACTION_TESTS9} 
-	otbLandmarkNew)			     
+ADD_TEST(feTuLandmarkNew ${FEATUREEXTRACTION_TESTS10} 
+	otbLandmarkNew)
+
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbFeatureExtractionTests11 ~~~~~~~~~~~~~~~~~~~~~
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+
+
+# -------            otb::CloudDetectionFilterNew   -------------
+ADD_TEST(feTuCloudDetectionFilterNew ${FEATUREEXTRACTION_TESTS11} 
+    otbCloudDetectionFilterNew)
+
+ADD_TEST(feTvCloudDetectionFilter ${FEATUREEXTRACTION_TESTS11} 
+    otbCloudDetectionFilter
+    ${INPUTDATA}/ExtrZoneNuageuse.tif
+    ${TEMP}/feTvSpectralAngleOutput.tif
+    500
+    731
+    500
+    632
+    1    # variance
+    1000 # threshold
+)
+
 
 # A enrichir
 SET(BasicFeatureExtraction_SRCS1
@@ -1065,22 +1096,28 @@ otbImageToSIFTKeyPointSetFilterValid.cxx
 otbImageToSIFTKeyPointSetFilterDistanceMap.cxx
 otbImageToSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
 otbImageToSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
+otbImageToSIFTKeyPointSetFilterOutputAscii.cxx
+otbImageToSIFTKeyPointSetFilterOutputImage.cxx
 otbImageToHessianDeterminantImageFilterNew.cxx
 otbImageToHessianDeterminantImageFilter.cxx
 otbImageFittingPolygonListFilter.cxx
 otbImageFittingPolygonListFilterNew.cxx
-otbImageToSURFKeyPointSetFilterNew.cxx	
+)
+SET(BasicFeatureExtraction_SRCS10
+otbImageToSURFKeyPointSetFilterNew.cxx
 otbImageToSURFKeyPointSetFilterOutputInterestPointAscii.cxx
 otbImageToSURFKeyPointSetFilterOutputDescriptorAscii.cxx
 otbImageToFastSIFTKeyPointSetFilterNew.cxx
 otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
 otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
-otbImageToSIFTKeyPointSetFilterOutputAscii.cxx
-otbImageToSIFTKeyPointSetFilterOutputImage.cxx
 otbKeyPointSetsMatchingFilterNew.cxx
 otbKeyPointSetsMatchingFilter.cxx
 otbLandmarkNew.cxx
 )
+SET(BasicFeatureExtraction_SRCS11
+otbCloudDetectionFilterNew.cxx
+otbCloudDetectionFilter.cxx
+)
 
 INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
 
@@ -1102,6 +1139,10 @@ ADD_EXECUTABLE(otbFeatureExtractionTests8 otbFeatureExtractionTests8.cxx ${Basic
 TARGET_LINK_LIBRARIES(otbFeatureExtractionTests8  OTBFeatureExtraction OTBIO)
 ADD_EXECUTABLE(otbFeatureExtractionTests9 otbFeatureExtractionTests9.cxx ${BasicFeatureExtraction_SRCS9})
 TARGET_LINK_LIBRARIES(otbFeatureExtractionTests9  OTBFeatureExtraction OTBIO)
+ADD_EXECUTABLE(otbFeatureExtractionTests10 otbFeatureExtractionTests10.cxx ${BasicFeatureExtraction_SRCS10})
+TARGET_LINK_LIBRARIES(otbFeatureExtractionTests10  OTBFeatureExtraction OTBIO)
+ADD_EXECUTABLE(otbFeatureExtractionTests11 otbFeatureExtractionTests11.cxx ${BasicFeatureExtraction_SRCS11})
+TARGET_LINK_LIBRARIES(otbFeatureExtractionTests11  OTBFeatureExtraction OTBIO)
 
 # ADD_EXECUTABLE(roadDetect roadDetect.cxx)
 # TARGET_LINK_LIBRARIES(roadDetect  OTBFeatureExtraction OTBIO)
diff --git a/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx b/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
new file mode 100644
index 0000000000..20dfa32b24
--- /dev/null
+++ b/Testing/Code/FeatureExtraction/otbCloudDetectionFilter.cxx
@@ -0,0 +1,74 @@
+/*=========================================================================
+
+  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 "itkExceptionObject.h"
+
+#include "otbVectorImage.h"
+#include "otbImage.h"
+#include "otbSpectralAngleFunctor.h"
+#include "otbCloudDetectionFilter.h"
+#include "otbImageFileReader.h"
+#include "otbImageFileWriter.h"
+
+
+int otbCloudDetectionFilter(int argc, char * argv[])
+{
+  const unsigned int Dimension                                                   = 2;
+  typedef double                                                                 PixelType;
+  typedef otb::VectorImage<PixelType,Dimension>                                  VectorImageType;
+  typedef otb::Image<PixelType,Dimension>                                        ImageType;
+  typedef VectorImageType::PixelType                                             VectorPixelType;
+  typedef otb::CloudDetectionFilter<VectorImageType,ImageType >                  CloudDetectionFilterType;
+  typedef otb::ImageFileReader<VectorImageType>                                  ReaderType;
+  typedef otb::ImageFileWriter<ImageType>                                        WriterType;
+
+  //Parameters
+  const char * inputFileName(argv[1]);
+  const char * outputFileName(argv[2]);
+  VectorPixelType referencePixel;
+  referencePixel.SetSize(4);
+  referencePixel.Fill(0.);
+
+  referencePixel[0] = (atof(argv[3]));
+  referencePixel[1] = (atof(argv[4]));
+  referencePixel[2] = (atof(argv[5]));
+  referencePixel[3] = (atof(argv[6]));
+
+  const double variance = (atof(argv[7]));
+  const double threshold = ::atof(argv[8]);
+
+
+  // Instantiating object
+  ReaderType::Pointer reader = ReaderType::New();
+  CloudDetectionFilterType::Pointer cloudDetection = CloudDetectionFilterType::New();
+  WriterType::Pointer writer = WriterType::New();
+
+  //Initialisation parameters
+  reader->SetFileName(inputFileName);
+
+  cloudDetection->SetInput(reader->GetOutput());
+  cloudDetection->SetReferencePixel(referencePixel);
+  cloudDetection->SetVariance(variance);
+  cloudDetection->SetThreshold(threshold);
+
+  writer->SetFileName(outputFileName);
+  writer->SetInput(cloudDetection->GetOutput());
+  writer->Update();
+
+
+  return EXIT_SUCCESS;
+}
diff --git a/Testing/Code/FeatureExtraction/otbCloudDetectionFilterNew.cxx b/Testing/Code/FeatureExtraction/otbCloudDetectionFilterNew.cxx
new file mode 100644
index 0000000000..ad7bd471f3
--- /dev/null
+++ b/Testing/Code/FeatureExtraction/otbCloudDetectionFilterNew.cxx
@@ -0,0 +1,36 @@
+/*=========================================================================
+
+  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 "otbImage.h"
+#include "otbVectorImage.h"
+#include "otbCloudDetectionFilter.h"
+
+int otbCloudDetectionFilterNew(int argc, char * argv[])
+{
+  const unsigned int Dimension                                  = 2;
+  typedef double                                                PixelType;
+  typedef otb::Image<PixelType,Dimension>                       ImageType;
+  typedef otb::VectorImage<PixelType,Dimension>                 VectorImageType;
+  typedef otb::CloudDetectionFilter<VectorImageType,ImageType > CloudDetectionFilterType;
+
+
+  // Instantiating object
+  CloudDetectionFilterType::Pointer cloudDetection = CloudDetectionFilterType::New();
+
+
+  return EXIT_SUCCESS;
+}
diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests10.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests10.cxx
new file mode 100644
index 0000000000..4177f94b7d
--- /dev/null
+++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests10.cxx
@@ -0,0 +1,39 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+
+// this file defines the otbCommonTest for the test driver
+// and all it expects is that you have a function called RegisterTests
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4786 )
+#endif
+
+#include <iostream>
+#include "otbTestMain.h"
+
+void RegisterTests()
+{
+REGISTER_TEST(otbImageToSURFKeyPointSetFilterNew);
+REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputInterestPointAscii);
+REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputDescriptorAscii);
+REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterNew);
+REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii);
+REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii);
+REGISTER_TEST(otbKeyPointSetsMatchingFilterNew);
+REGISTER_TEST(otbKeyPointSetsMatchingFilter);
+REGISTER_TEST(otbLandmarkNew);
+}
diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx
new file mode 100644
index 0000000000..00f52bf021
--- /dev/null
+++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests11.cxx
@@ -0,0 +1,32 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+
+// this file defines the otbCommonTest for the test driver
+// and all it expects is that you have a function called RegisterTests
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4786 )
+#endif
+
+#include <iostream>
+#include "otbTestMain.h"
+
+void RegisterTests()
+{
+REGISTER_TEST(otbCloudDetectionFilterNew);
+REGISTER_TEST(otbCloudDetectionFilter);
+}
diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx
index cb9a3a2a0d..8d1ea3567e 100644
--- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx
+++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx
@@ -39,13 +39,4 @@ REGISTER_TEST(otbImageToHessianDeterminantImageFilterNew);
 REGISTER_TEST(otbImageToHessianDeterminantImageFilter);
 REGISTER_TEST(otbImageFittingPolygonListFilter);
 REGISTER_TEST(otbImageFittingPolygonListFilterNew);
-REGISTER_TEST(otbImageToSURFKeyPointSetFilterNew);
-REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputInterestPointAscii);
-REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputDescriptorAscii);
-REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterNew);
-REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii);
-REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii);
-REGISTER_TEST(otbKeyPointSetsMatchingFilterNew);
-REGISTER_TEST(otbKeyPointSetsMatchingFilter);
-REGISTER_TEST(otbLandmarkNew);
 }
-- 
GitLab