Skip to content
Snippets Groups Projects
Commit 69c46063 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ADD : GenericRSResampler tests

parent e12ede76
No related branches found
No related tags found
No related merge requests found
...@@ -602,17 +602,29 @@ ADD_TEST(prTuPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} ...@@ -602,17 +602,29 @@ ADD_TEST(prTuPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4}
otbPhysicalToRPCSensorModelImageFilterNew otbPhysicalToRPCSensorModelImageFilterNew
) )
IF(OTB_DATA_USE_LARGEINPUT)
ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4} ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4}
otbPhysicalToRPCSensorModelImageFilter 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 ${LARGEINPUT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF
1000 1000
${TEMP}/prTvotbPhysicalToRPCSensorModelImageFilter.tif 15
${TEMP}/prTvotbGenericRSResampleImageFilterOutput.tif
) )
ENDIF(OTB_DATA_USE_LARGEINPUT) ENDIF(OTB_DATA_USE_LARGEINPUT)
#======================================================================================= #=======================================================================================
SET(Projections_SRCS1 SET(Projections_SRCS1
otbProjectionsTests1.cxx otbProjectionsTests1.cxx
...@@ -665,6 +677,8 @@ otbOptResampleImageFilterNew.cxx ...@@ -665,6 +677,8 @@ otbOptResampleImageFilterNew.cxx
otbOptResampleImageFilter.cxx otbOptResampleImageFilter.cxx
otbPhysicalToRPCSensorModelImageFilterNew.cxx otbPhysicalToRPCSensorModelImageFilterNew.cxx
otbPhysicalToRPCSensorModelImageFilter.cxx otbPhysicalToRPCSensorModelImageFilter.cxx
otbGenericRSResampleImageFilterNew.cxx
otbGenericRSResampleImageFilter.cxx
) )
OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting")
......
/*=========================================================================
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;
}
/*=========================================================================
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;
}
...@@ -30,4 +30,6 @@ void RegisterTests() ...@@ -30,4 +30,6 @@ void RegisterTests()
REGISTER_TEST(otbOptResampleImageFilter); REGISTER_TEST(otbOptResampleImageFilter);
REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilterNew); REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilterNew);
REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilter); REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilter);
REGISTER_TEST(otbGenericRSResampleImageFilterNew);
REGISTER_TEST(otbGenericRSResampleImageFilter);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment