diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 548c0164447b74eb7085c7d35d6c719d1a3b0177..cd9f63456e6b371acc8d7c6a774dde4b1cba3ed8 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -602,17 +602,29 @@ ADD_TEST(prTuPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} otbPhysicalToRPCSensorModelImageFilterNew ) -IF(OTB_DATA_USE_LARGEINPUT) ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} otbPhysicalToRPCSensorModelImageFilter + ${INPUTDATA}/ToulouseExtract_WithGeom.tif + 15 + ${TEMP}/prTvotbPhysicalToRPCSensorModelImageFilter.tif + ) + +ADD_TEST(prTuotbGenericRSResampleImageFilter ${PROJECTIONS_TESTS4} + otbGenericRSResampleImageFilterNew + ) +IF(OTB_DATA_USE_LARGEINPUT) + + +ADD_TEST(prTvotbGenericRSResampleImageFilter ${PROJECTIONS_TESTS4} + otbGenericRSResampleImageFilter ${LARGEINPUT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF 1000 - ${TEMP}/prTvotbPhysicalToRPCSensorModelImageFilter.tif + 15 + ${TEMP}/prTvotbGenericRSResampleImageFilterOutput.tif ) ENDIF(OTB_DATA_USE_LARGEINPUT) - #======================================================================================= SET(Projections_SRCS1 otbProjectionsTests1.cxx @@ -665,6 +677,8 @@ otbOptResampleImageFilterNew.cxx otbOptResampleImageFilter.cxx otbPhysicalToRPCSensorModelImageFilterNew.cxx otbPhysicalToRPCSensorModelImageFilter.cxx +otbGenericRSResampleImageFilterNew.cxx +otbGenericRSResampleImageFilter.cxx ) OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting") diff --git a/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3e12c9a79db8b3ba8e6446072fc4ad5425d634ea --- /dev/null +++ b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx @@ -0,0 +1,111 @@ +/*========================================================================= + + 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 "otbGenericRSResampleImageFilter.h" +#include "otbVectorImage.h" +#include "itkVector.h" +#include "otbImage.h" + +#include "otbImageFileReader.h" +#include "otbStreamingImageFileWriter.h" + +#include <ogr_spatialref.h> + +int otbGenericRSResampleImageFilter(int argc, char* argv[]) +{ + const char * infname = argv[1]; + const char * outfname = argv[4]; + unsigned int isize = atoi(argv[2]); + unsigned int iGridSpacing = atoi(argv[3]); + + // Images definition + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType, Dimension> ImageType; + typedef ImageType::SizeType SizeType; + + typedef itk::Vector<PixelType, 2> DeformationValueType; + typedef otb::Image<DeformationValueType, Dimension> DeformationFieldType; + + typedef otb::GenericRSResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; + typedef ImageResamplerType::OriginType OriginType; + typedef ImageResamplerType::SpacingType SpacingType; + + typedef otb::ImageFileReader<ImageType> ReaderType; + + ReaderType::Pointer reader = ReaderType::New(); + ImageResamplerType::Pointer resampler = ImageResamplerType::New(); + + // Fill the output size with the size selected by the user + SizeType size; + size.Fill(isize); + + OriginType origin; + origin.Fill(1500); + + // Build the ouput projection ref : Lambert II ref + OGRSpatialReference oSRS; + + // Build UTM ref + oSRS.SetProjCS("UTM"); + oSRS.SetUTM(31, true); + char * utmRef = NULL; + oSRS.exportToWkt(&utmRef); + + SpacingType spacing; + spacing[0] = 0.6; + spacing[1] = -0.6; + + + +// double stdParallel1 = 45.89891944; +// double stdParallel2 = 47.69601389; +// double originLatL2 = 46.8; +// double originLongL2 = 2.33722778; +// double falseEastingL2 = 600000; +// double falseNorthingL2 = 2200000; +// oSRS.SetProjCS("Lambert II "); +// oSRS.SetLCC(stdParallel1, stdParallel2, originLatL2, originLongL2, falseEastingL2, falseNorthingL2); +// char * lambertRef = NULL; +// oSRS.exportToWkt(&lambertRef); + + // Read the input image + reader->SetFileName(infname); + reader->UpdateOutputInformation(); + + // Set the Resampler Parameters + resampler->SetInput(reader->GetOutput()); + resampler->SetDeformationFieldSpacing(iGridSpacing); + resampler->SetOutputParametersFromImage(reader->GetOutput()); + resampler->SetOutputOrigin(origin); + resampler->SetOutputSize(size); + resampler->SetOutputSpacing(spacing); + resampler->SetOutputProjectionRef(utmRef); + + + // Write the resampled image + typedef otb::StreamingImageFileWriter<ImageType> WriterType; + WriterType::Pointer writer= WriterType::New(); + writer->SetTilingStreamDivisions(); + writer->WriteGeomFileOn(); + writer->SetFileName(outfname); + writer->SetInput(resampler->GetOutput()); + writer->Update(); + + return 0; +} diff --git a/Testing/Code/Projections/otbGenericRSResampleImageFilterNew.cxx b/Testing/Code/Projections/otbGenericRSResampleImageFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8ea8785b9cd1b13ea2a957ec957942b874eb6544 --- /dev/null +++ b/Testing/Code/Projections/otbGenericRSResampleImageFilterNew.cxx @@ -0,0 +1,38 @@ +/*========================================================================= + + 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 "otbGenericRSResampleImageFilter.h" +#include "otbVectorImage.h" +#include "itkVector.h" +#include "otbImage.h" + +int otbGenericRSResampleImageFilterNew(int argc, char* argv[]) +{ + // Images definition + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType, Dimension> ImageType; + typedef itk::Vector<PixelType, 2> DeformationValueType; + typedef otb::Image<DeformationValueType, Dimension> DeformationFieldType; + typedef otb::GenericRSResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; + + ImageResamplerType::Pointer resampler = ImageResamplerType::New(); + + + return 0; +} diff --git a/Testing/Code/Projections/otbProjectionsTests4.cxx b/Testing/Code/Projections/otbProjectionsTests4.cxx index aa921f90c57255bf508e2e9b23309e47848f4a0a..2d60ff00e1be7b43ae80ef8473f5848e26d34207 100644 --- a/Testing/Code/Projections/otbProjectionsTests4.cxx +++ b/Testing/Code/Projections/otbProjectionsTests4.cxx @@ -30,4 +30,6 @@ void RegisterTests() REGISTER_TEST(otbOptResampleImageFilter); REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilterNew); REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilter); + REGISTER_TEST(otbGenericRSResampleImageFilterNew); + REGISTER_TEST(otbGenericRSResampleImageFilter); }