diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 8383145fc76235159d6a69d52ea9bbf8dfd970b9..c0e2bc79e39852165eb777a6318e5a938580d06e 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -584,7 +584,7 @@ ENDIF(OTB_DATA_USE_LARGEINPUT) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ADD_TEST(prTuOptResampleImageFilterNew ${PROJECTIONS_TESTS4} - otbOptResampleImageFilterNew + otbOptResampleImageFilter ) IF(OTB_DATA_USE_LARGEINPUT) @@ -598,8 +598,8 @@ ENDIF(OTB_DATA_USE_LARGEINPUT) -ADD_TEST(prTuPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} - otbPhysicalToRPCSensorModelImageFilterNew +ADD_TEST(prTuPhysicalToRPCSensorModelImageFilterNew ${PROJECTIONS_TESTS4} + otbPhysicalToRPCSensorModelImageFilter ) ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} @@ -609,8 +609,8 @@ ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} ${TEMP}/prTvotbPhysicalToRPCSensorModelImageFilter.tif ) -ADD_TEST(prTuotbGenericRSResampleImageFilter ${PROJECTIONS_TESTS4} - otbGenericRSResampleImageFilterNew +ADD_TEST(prTuotbGenericRSResampleImageFilterNew ${PROJECTIONS_TESTS4} + otbGenericRSResampleImageFilter ) IF(OTB_DATA_USE_LARGEINPUT) @@ -674,11 +674,8 @@ otbVectorDataExtractROIandProjection.cxx SET(Projections_SRCS4 otbProjectionsTests4.cxx -otbOptResampleImageFilterNew.cxx otbOptResampleImageFilter.cxx -otbPhysicalToRPCSensorModelImageFilterNew.cxx otbPhysicalToRPCSensorModelImageFilter.cxx -otbGenericRSResampleImageFilterNew.cxx otbGenericRSResampleImageFilter.cxx ) diff --git a/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx index 3008cbba84d5960edcd4ce750b12c0d9485048f0..242e2e8ceb1a355d89ef07f071f51c78691c0279 100644 --- a/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx +++ b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx @@ -28,12 +28,6 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[]) { - const char * infname = argv[1]; - const char * outfname = argv[5]; - unsigned int isize = atoi(argv[2]); - double iGridSpacing = atof(argv[3]); - int useRpc = atoi(argv[4]); - // Images definition const unsigned int Dimension = 2; typedef double PixelType; @@ -46,63 +40,79 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[]) typedef otb::GenericRSResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; typedef ImageResamplerType::OriginType OriginType; typedef ImageResamplerType::SpacingType SpacingType; - typedef otb::ImageFileReader<ImageType> ReaderType; + // SmartPointer instanciation - ReaderType::Pointer reader = ReaderType::New(); ImageResamplerType::Pointer resampler = ImageResamplerType::New(); + + // Check if it's a unit test. + if (argc > 1) + { + const char * infname = argv[1]; + const char * outfname = argv[5]; + unsigned int isize = atoi(argv[2]); + double iGridSpacing = atof(argv[3]); + int useRpc = atoi(argv[4]); + + typedef otb::ImageFileReader<ImageType> ReaderType; + ReaderType::Pointer reader = ReaderType::New(); - // Read the input image - reader->SetFileName(infname); - reader->UpdateOutputInformation(); + // Read the input image + reader->SetFileName(infname); + reader->UpdateOutputInformation(); - // Fill the output size with the user selection - SizeType size; - size.Fill(isize); + // Fill the output size with the user selection + SizeType size; + size.Fill(isize); - // Set the origin & the spacing of the output - OriginType origin; - origin[0] = 367340; - origin[1] = 4.83467e+06; + // Set the origin & the spacing of the output + OriginType origin; + origin[0] = 367340; + origin[1] = 4.83467e+06; - SpacingType spacing; - spacing[0] = 0.6; - spacing[1] = -0.6; + SpacingType spacing; + spacing[0] = 0.6; + spacing[1] = -0.6; - // Build the ouput projection ref : UTM ref - OGRSpatialReference oSRS; - oSRS.SetProjCS("UTM"); - oSRS.SetUTM(31, true); - char * utmRef = NULL; - oSRS.exportToWkt(&utmRef); + // Build the ouput projection ref : UTM ref + OGRSpatialReference oSRS; + oSRS.SetProjCS("UTM"); + oSRS.SetUTM(31, true); + char * utmRef = NULL; + oSRS.exportToWkt(&utmRef); - // Deformation Field spacing - SpacingType gridSpacing; - gridSpacing[0] = iGridSpacing; - gridSpacing[1] = -iGridSpacing; + // Deformation Field spacing + SpacingType gridSpacing; + gridSpacing[0] = iGridSpacing; + gridSpacing[1] = -iGridSpacing; - // Set the Resampler Parameters - resampler->SetInput(reader->GetOutput()); - resampler->SetDeformationFieldSpacing(gridSpacing); - resampler->SetOutputOrigin(origin); - resampler->SetOutputSize(size); - resampler->SetOutputSpacing(spacing); - resampler->SetOutputProjectionRef(utmRef); - resampler->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef()); - resampler->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist()); - if (useRpc) + // Set the Resampler Parameters + resampler->SetInput(reader->GetOutput()); + resampler->SetDeformationFieldSpacing(gridSpacing); + resampler->SetOutputOrigin(origin); + resampler->SetOutputSize(size); + resampler->SetOutputSpacing(spacing); + resampler->SetOutputProjectionRef(utmRef); + resampler->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef()); + resampler->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist()); + if (useRpc) + { + resampler->SetGridSpacing(1000); + resampler->EstimateInputRpcModelOn(); + } + + // Write the resampled image + typedef otb::StreamingImageFileWriter<ImageType> WriterType; + WriterType::Pointer writer= WriterType::New(); + writer->SetTilingStreamDivisions(4); + writer->SetFileName(outfname); + writer->SetInput(resampler->GetOutput()); + writer->Update(); + } + else { - resampler->SetGridSpacing(1000); - resampler->EstimateInputRpcModelOn(); + std::cout <<"Unit Test " << std::endl; } - // Write the resampled image - typedef otb::StreamingImageFileWriter<ImageType> WriterType; - WriterType::Pointer writer= WriterType::New(); - writer->SetTilingStreamDivisions(4); - 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 deleted file mode 100644 index 8ea8785b9cd1b13ea2a957ec957942b874eb6544..0000000000000000000000000000000000000000 --- a/Testing/Code/Projections/otbGenericRSResampleImageFilterNew.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/*========================================================================= - - 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/otbOptResampleImageFilter.cxx b/Testing/Code/Projections/otbOptResampleImageFilter.cxx index fbe845e4e6e86e8a65f68b172eb9782fd5e72022..d2b3f975fe3dc8f94fc7c447062416baaefa618a 100644 --- a/Testing/Code/Projections/otbOptResampleImageFilter.cxx +++ b/Testing/Code/Projections/otbOptResampleImageFilter.cxx @@ -30,75 +30,81 @@ int otbOptResampleImageFilter(int argc, char* argv[]) { - const char * infname = argv[1]; - const char * outfname = argv[3]; - unsigned int isize = atoi(argv[2]); - // 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::Image<DeformationValueType, Dimension> DeformationFieldType; + typedef otb::OptResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; - typedef itk::Transform< - PixelType, Dimension, Dimension> TransformType; + // Istantiate a Resampler + ImageResamplerType::Pointer resampler = ImageResamplerType::New(); - typedef itk::AffineTransform< - PixelType, Dimension> AffineTransformType; + if (argc>1) + { + const char * infname = argv[1]; + const char * outfname = argv[3]; + unsigned int isize = atoi(argv[2]); - // - typedef otb::OptResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; + typedef itk::Transform< + PixelType, Dimension, Dimension> TransformType; - typedef otb::ImageFileReader<ImageType> ReaderType; + typedef itk::AffineTransform< + PixelType, Dimension> AffineTransformType; + typedef otb::ImageFileReader<ImageType> ReaderType; - // Instantiate an affine transformation Pointer - AffineTransformType::Pointer affineTransform = AffineTransformType::New(); - // Istantiate a Resampler - ImageResamplerType::Pointer resampler = ImageResamplerType::New(); - // Instanciate reader - ReaderType::Pointer reader = ReaderType::New(); + // Instantiate an affine transformation Pointer + AffineTransformType::Pointer affineTransform = AffineTransformType::New(); + + // Instanciate reader + ReaderType::Pointer reader = ReaderType::New(); - // Get the image file - reader->SetFileName(infname); - reader->UpdateOutputInformation(); + // Get the image file + reader->SetFileName(infname); + reader->UpdateOutputInformation(); - /** Set the options. */ - ImageResamplerType::OriginType centerOfRotation; - centerOfRotation[ 0 ] = -3.0; centerOfRotation[ 1 ] = -3.0; - affineTransform->SetCenter( centerOfRotation ); + /** Set the options. */ + ImageResamplerType::OriginType centerOfRotation; + centerOfRotation[ 0 ] = -3.0; centerOfRotation[ 1 ] = -3.0; + affineTransform->SetCenter( centerOfRotation ); - /** Create and set parameters. */ - AffineTransformType::ParametersType parameters( affineTransform->GetNumberOfParameters() ); - parameters[ 0 ] = 1.1; - parameters[ 1 ] = 0.1; - parameters[ 2 ] = -0.2; - parameters[ 3 ] = 0.9; - parameters[ 4 ] = 10.3; - parameters[ 5 ] = -33.8; - affineTransform->SetParameters( parameters ); + /** Create and set parameters. */ + AffineTransformType::ParametersType parameters( affineTransform->GetNumberOfParameters() ); + parameters[ 0 ] = 1.1; + parameters[ 1 ] = 0.1; + parameters[ 2 ] = -0.2; + parameters[ 3 ] = 0.9; + parameters[ 4 ] = 10.3; + parameters[ 5 ] = -33.8; + affineTransform->SetParameters( parameters ); - // Get the size specified by the user - ImageType::SizeType size; - size.Fill(isize); + // Get the size specified by the user + ImageType::SizeType size; + size.Fill(isize); - /** Set the OptResampler Parameters*/ - resampler->SetInput(reader->GetOutput()); - resampler->SetOutputParametersFromImage(reader->GetOutput()); - resampler->SetTransform(affineTransform); - resampler->SetDeformationFieldSpacing(5.); // TODO : add the spacing - // it to the - // command line - resampler->SetOutputSize(size); + /** Set the OptResampler Parameters*/ + resampler->SetInput(reader->GetOutput()); + resampler->SetOutputParametersFromImage(reader->GetOutput()); + resampler->SetTransform(affineTransform); + resampler->SetDeformationFieldSpacing(5.); // TODO : add the spacing + // it to the + // command line + resampler->SetOutputSize(size); - // Write the resampled image - typedef otb::StreamingImageFileWriter<ImageType> WriterType; - WriterType::Pointer writer= WriterType::New(); - writer->SetTilingStreamDivisions(4); - writer->WriteGeomFileOn(); - writer->SetFileName(outfname); - writer->SetInput(resampler->GetOutput()); - writer->Update(); + // Write the resampled image + typedef otb::StreamingImageFileWriter<ImageType> WriterType; + WriterType::Pointer writer= WriterType::New(); + writer->SetTilingStreamDivisions(4); + writer->WriteGeomFileOn(); + writer->SetFileName(outfname); + writer->SetInput(resampler->GetOutput()); + writer->Update(); + } + else + { + std::cout <<" Unit Test"<< std::endl; + } return EXIT_SUCCESS; diff --git a/Testing/Code/Projections/otbOptResampleImageFilterNew.cxx b/Testing/Code/Projections/otbOptResampleImageFilterNew.cxx deleted file mode 100644 index 7a5b99e94d9275687f1e24adeb19b3f10061f3a3..0000000000000000000000000000000000000000 --- a/Testing/Code/Projections/otbOptResampleImageFilterNew.cxx +++ /dev/null @@ -1,39 +0,0 @@ -/*========================================================================= - - 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 "otbOptResampleImageFilter.h" -#include "otbVectorImage.h" -#include "itkVector.h" -#include "otbImage.h" - -int otbOptResampleImageFilterNew(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::OptResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; - - // - ImageResamplerType::Pointer resampler = ImageResamplerType::New(); - return 0; -} diff --git a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx index c1fc4d13dd72af08a5df8e950e0d2b7d9c25d60b..758db74104512b853cc51708b5d76ec1709259e8 100644 --- a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx +++ b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx @@ -23,37 +23,46 @@ int otbPhysicalToRPCSensorModelImageFilter(int argc, char* argv[]) { - const char * infname = argv[1]; - unsigned int gridSpacing = atoi(argv[2]); - const char * outfname = argv[3]; - // Images definition const unsigned int Dimension = 2; typedef double PixelType; typedef otb::VectorImage<PixelType, Dimension> ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::PhysicalToRPCSensorModelImageFilter<ImageType> PhysicalToSensorModelType; // Object instanciation PhysicalToSensorModelType::Pointer estimator = PhysicalToSensorModelType::New(); - ReaderType::Pointer reader = ReaderType::New(); - - // Set the fileName - reader->SetFileName(infname); - reader->UpdateOutputInformation(); + + if(argc>1) + { + const char * infname = argv[1]; + unsigned int gridSpacing = atoi(argv[2]); + const char * outfname = argv[3]; + + // Reader + typedef otb::ImageFileReader<ImageType> ReaderType; + ReaderType::Pointer reader = ReaderType::New(); - estimator->SetInput(reader->GetOutput()); - estimator->SetGridSpacing(gridSpacing); - - // Write the resampled image - typedef otb::StreamingImageFileWriter<ImageType> WriterType; - WriterType::Pointer writer= WriterType::New(); - writer->SetTilingStreamDivisions(); - writer->WriteGeomFileOn(); - writer->SetFileName(outfname); - writer->SetInput(estimator->GetOutput()); - writer->Update(); + // Set the fileName + reader->SetFileName(infname); + reader->UpdateOutputInformation(); + + // wire the filter + estimator->SetInput(reader->GetOutput()); + estimator->SetGridSpacing(gridSpacing); + + // Write the resampled image + typedef otb::StreamingImageFileWriter<ImageType> WriterType; + WriterType::Pointer writer= WriterType::New(); + writer->SetTilingStreamDivisions(); + writer->WriteGeomFileOn(); + writer->SetFileName(outfname); + writer->SetInput(estimator->GetOutput()); + writer->Update(); + } + else + { + std::cout <<"Unit Test" << std::endl; + } return 0; } diff --git a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx deleted file mode 100644 index 3e0bd49bbba65c1e31fc53e54e3a7326441d59a7..0000000000000000000000000000000000000000 --- a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/*========================================================================= - - 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 "otbPhysicalToRPCSensorModelImageFilter.h" -#include "otbVectorImage.h" - -int otbPhysicalToRPCSensorModelImageFilterNew(int argc, char* argv[]) -{ - // Images definition - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType, Dimension> ImageType; - - typedef otb::PhysicalToRPCSensorModelImageFilter<ImageType> PhysicalToSensorModelType; - - // Instanciation of the filter - PhysicalToSensorModelType::Pointer resampler = PhysicalToSensorModelType::New(); - - return 0; -} diff --git a/Testing/Code/Projections/otbProjectionsTests4.cxx b/Testing/Code/Projections/otbProjectionsTests4.cxx index 2d60ff00e1be7b43ae80ef8473f5848e26d34207..40b05eb07225a2b9fc8747c547e2ea7f83ab7ba2 100644 --- a/Testing/Code/Projections/otbProjectionsTests4.cxx +++ b/Testing/Code/Projections/otbProjectionsTests4.cxx @@ -26,10 +26,7 @@ void RegisterTests() { - REGISTER_TEST(otbOptResampleImageFilterNew); REGISTER_TEST(otbOptResampleImageFilter); - REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilterNew); REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilter); - REGISTER_TEST(otbGenericRSResampleImageFilterNew); REGISTER_TEST(otbGenericRSResampleImageFilter); }