From 1d9af078bb07b0f29cc305b48bcaee8c03995ae8 Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Thu, 10 Sep 2009 09:10:15 +0200 Subject: [PATCH] ENH : add test for TRSX calibration --- .../Code/Radiometry/otbRadiometryTests9.cxx | 35 +++++++++ ...TerraSarIntraCalibrationImageFilterNew.cxx | 31 ++++++++ ...erraSarIntraCalibrationImageFilterTest.cxx | 74 +++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 Testing/Code/Radiometry/otbRadiometryTests9.cxx create mode 100644 Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterNew.cxx create mode 100644 Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterTest.cxx diff --git a/Testing/Code/Radiometry/otbRadiometryTests9.cxx b/Testing/Code/Radiometry/otbRadiometryTests9.cxx new file mode 100644 index 0000000000..a29214fdc9 --- /dev/null +++ b/Testing/Code/Radiometry/otbRadiometryTests9.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. + +=========================================================================*/ + +// 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 "otbTestMain.h" + +void RegisterTests() +{ +REGISTER_TEST(otbTerraSarIntraCalibrationImageFilterNew); +REGISTER_TEST(otbTerraSarIntraCalibrationImageFilterTest); +} + + + diff --git a/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterNew.cxx b/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterNew.cxx new file mode 100644 index 0000000000..e1d552fa92 --- /dev/null +++ b/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterNew.cxx @@ -0,0 +1,31 @@ +/*========================================================================= + + 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 "otbTerraSarIntraCalibrationImageFilter.h" +#include "otbImage.h" + +int otbTerraSarIntraCalibrationImageFilterNew(int argc, char * argv[]) +{ + typedef otb::Image<double, 2> ImageType; + typedef otb::TerraSarIntraCalibrationImageFilter<ImageType, ImageType> FilterType; + + FilterType::Pointer filter = FilterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterTest.cxx b/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterTest.cxx new file mode 100644 index 0000000000..e232dcc721 --- /dev/null +++ b/Testing/Code/Radiometry/otbTerraSarIntraCalibrationImageFilterTest.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 "otbTerraSarIntraCalibrationImageFilter.h" +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbVectorImageToAmplitudeImageFilter.h" + +int otbTerraSarIntraCalibrationImageFilterTest(int argc, char * argv[]) +{ + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + + typedef otb::Image<double, 2> ImageType; + typedef otb::VectorImage<double, 2> VectorImageType; + typedef otb::ImageFileReader<VectorImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::VectorImageToAmplitudeImageFilter<VectorImageType, ImageType> AmplitudeFilterType; + typedef otb::TerraSarIntraCalibrationImageFilter<ImageType, ImageType> FilterType; + typedef FilterType::DoubleVectorType DoubleVectorType; + typedef FilterType::DoubleVectorVectorType DoubleVectorVectorType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + AmplitudeFilterType::Pointer ampli = AmplitudeFilterType::New(); + FilterType::Pointer filter = FilterType::New(); + + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + std::cout<<"ouiiiiiiiii"<<std::endl; + reader->UpdateOutputInformation(); + //unsigned int nbChannel = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + std::cout<<reader->GetOutput()->GetNumberOfComponentsPerPixel()<<std::endl; + + DoubleVectorType coefs; + coefs.push_back(1.); + coefs.push_back(0.5); + coefs.push_back(1.); + coefs.push_back(0.1); + DoubleVectorVectorType coefVect(1, coefs); + + filter->SetNoisePolynomialCoefficientsList(coefVect); + filter->SetCalFactor( 10 ); + filter->SetNoiseRangeValidityMin( 0 ); + filter->SetNoiseRangeValidityMax( 1 ); + filter->SetNoiseRangeValidityRef( 0.5 ); + filter->SetLocalIncidentAngle( 15 ); + + ampli->SetInput(reader->GetOutput()); + filter->SetInput(ampli->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->SetNumberOfStreamDivisions(1); + writer->Update(); + + return EXIT_SUCCESS; +} -- GitLab