From af8db17cf2dd9b8dafd76234b91b6c50070f0438 Mon Sep 17 00:00:00 2001
From: Thomas Feuvrier <thomas.feuvrier@c-s.fr>
Date: Tue, 7 Apr 2009 19:01:28 +0200
Subject: [PATCH] TEST: add ImageOfVectorsToMonoChannelExtractROI class testing

---
 Testing/Code/Common/CMakeLists.txt            | 16 ++++++
 Testing/Code/Common/otbCommonTests8.cxx       |  2 +
 ...bImageOfVectorsToMonoChannelExtractROI.cxx | 56 +++++++++++++++++++
 ...ageOfVectorsToMonoChannelExtractROINew.cxx | 35 ++++++++++++
 4 files changed, 109 insertions(+)
 create mode 100644 Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROI.cxx
 create mode 100644 Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROINew.cxx

diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt
index c8d435aacd..786d33ff60 100755
--- a/Testing/Code/Common/CMakeLists.txt
+++ b/Testing/Code/Common/CMakeLists.txt
@@ -651,7 +651,21 @@ ADD_TEST(coTvImageRegionTileMapSplitter ${COMMON_TESTS8}
     ${TEMP}/coImageRegionTileMapSplitter.txt
 )
 
+# -------------  otb::ImageOfVectorsToMonoChannelExtractROI ----------------------------
+ADD_TEST(coTuImageOfVectorsToMonoChannelExtractROINew ${COMMON_TESTS8}
+otbImageOfVectorsToMonoChannelExtractROINew
+)
 
+ADD_TEST(coTvImageOfVectorsToMonoChannelExtractROI ${COMMON_TESTS8}
+  --compare-image ${TOL}   ${BASELINE}/coImageOfVectorsToMonoChannelExtractROI.png
+                           ${TEMP}/coImageOfVectorsToMonoChannelExtractROI.png
+        otbImageOfVectorsToMonoChannelExtractROI
+        ${INPUTDATA}/couleurs_extrait.png
+        300 10  # Start X Y
+        250 50  # Size X Y
+        1       # Channel
+        ${TEMP}/coImageOfVectorsToMonoChannelExtractROI.png
+)
 
 # -------       Fichiers sources CXX -----------------------------------
 SET(BasicCommon_SRCS1
@@ -749,6 +763,8 @@ otbQuickLookImageGeneratorNew.cxx
 otbQuickLookImageGenerator.cxx
 otbImageRegionTileMapSplitterNew.cxx
 otbImageRegionTileMapSplitter.cxx
+otbImageOfVectorsToMonoChannelExtractROINew.cxx
+otbImageOfVectorsToMonoChannelExtractROI.cxx
 )
 
 INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
diff --git a/Testing/Code/Common/otbCommonTests8.cxx b/Testing/Code/Common/otbCommonTests8.cxx
index ac43f530a7..2e30f407b5 100644
--- a/Testing/Code/Common/otbCommonTests8.cxx
+++ b/Testing/Code/Common/otbCommonTests8.cxx
@@ -30,4 +30,6 @@ REGISTER_TEST(otbQuickLookImageGeneratorNew);
 REGISTER_TEST(otbQuickLookImageGenerator);
 REGISTER_TEST(otbImageRegionTileMapSplitterNew);
 REGISTER_TEST(otbImageRegionTileMapSplitter);
+REGISTER_TEST(otbImageOfVectorsToMonoChannelExtractROINew);
+REGISTER_TEST(otbImageOfVectorsToMonoChannelExtractROI);
 }
diff --git a/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROI.cxx b/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROI.cxx
new file mode 100644
index 0000000000..87576ac837
--- /dev/null
+++ b/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROI.cxx
@@ -0,0 +1,56 @@
+/*=========================================================================
+
+  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 "otbImageOfVectorsToMonoChannelExtractROI.h"
+#include "otbImageFileReader.h"
+#include "otbImageFileWriter.h"
+#include "otbImage.h"
+
+int otbImageOfVectorsToMonoChannelExtractROI(int argc, char * argv[])
+{
+  const int Dimension = 2;
+  typedef unsigned char ScalarPixelType;
+  typedef itk::Vector<unsigned char,Dimension>    VectorPixelType;
+
+  const char * inputImageFileName = argv[1];
+  const char * outputImageFileName = argv[7];
+  typedef otb::Image<ScalarPixelType,Dimension> ScalarImageType;
+  typedef otb::Image<VectorPixelType,Dimension> VectorImageType;
+  typedef otb::ImageOfVectorsToMonoChannelExtractROI<VectorImageType, ScalarImageType> FilterType;
+
+  typedef otb::ImageFileReader< VectorImageType > ReaderType;
+  typedef otb::ImageFileWriter< ScalarImageType > WriterType;
+
+  ReaderType::Pointer reader = ReaderType::New();
+  reader->SetFileName( inputImageFileName );
+  WriterType::Pointer writer = WriterType::New();
+  writer->SetFileName( outputImageFileName );
+  // Instantiating object
+  FilterType::Pointer object = FilterType::New();
+
+  object->SetStartX(atoi(argv[2]));
+  object->SetStartY(atoi(argv[3]));
+  object->SetSizeX(atoi(argv[4]));
+  object->SetSizeY(atoi(argv[5]));
+  object->SetChannel(atoi(argv[6]));
+
+  object->SetInput(reader->GetOutput());
+  writer->SetInput(object->GetOutput());
+  writer->Update();
+
+  return EXIT_SUCCESS;
+}
diff --git a/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROINew.cxx b/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROINew.cxx
new file mode 100644
index 0000000000..52843ff011
--- /dev/null
+++ b/Testing/Code/Common/otbImageOfVectorsToMonoChannelExtractROINew.cxx
@@ -0,0 +1,35 @@
+/*=========================================================================
+
+  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 "otbImageOfVectorsToMonoChannelExtractROI.h"
+#include "otbImage.h"
+
+int otbImageOfVectorsToMonoChannelExtractROINew(int argc, char * argv[])
+{
+  const int Dimension = 2;
+  typedef unsigned char ScalarPixelType;
+  typedef itk::Vector<double,Dimension>    VectorPixelType;
+
+  typedef otb::Image<ScalarPixelType,Dimension> ScalarImageType;
+  typedef otb::Image<VectorPixelType,Dimension> VectorImageType;
+  typedef otb::ImageOfVectorsToMonoChannelExtractROI<VectorImageType, ScalarImageType> FilterType;
+
+  // Instantiating object
+  FilterType::Pointer object = FilterType::New();
+
+  return EXIT_SUCCESS;
+}
-- 
GitLab