diff --git a/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx index 4f953cabca01cdc084b021160ba86dc411b9a87d..c9f1112fe0009ea7a3f496b906aeb7bebfbea403 100644 --- a/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx +++ b/Testing/Code/Projections/otbGenericRSResampleImageFilter.cxx @@ -31,7 +31,7 @@ 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]); + double iGridSpacing = atof(argv[3]); // Images definition const unsigned int Dimension = 2; @@ -43,64 +43,51 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[]) typedef otb::Image<DeformationValueType, Dimension> DeformationFieldType; typedef otb::GenericRSResampleImageFilter<ImageType, ImageType, DeformationFieldType> ImageResamplerType; - typedef ImageResamplerType::OriginType OriginType; + 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(); + + // Read the input image + reader->SetFileName(infname); + reader->UpdateOutputInformation(); - // Fill the output size with the size selected by the user + // 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; - - - // 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; + // Build the ouput projection ref : UTM ref + OGRSpatialReference oSRS; + oSRS.SetProjCS("UTM"); + oSRS.SetUTM(31, true); + char * utmRef = NULL; + oSRS.exportToWkt(&utmRef); - -// 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(); + // Deformation Field spacing + SpacingType gridSpacing; + gridSpacing[0] = iGridSpacing; + gridSpacing[1] = -iGridSpacing; // Set the Resampler Parameters resampler->SetInput(reader->GetOutput()); - resampler->SetDeformationFieldSpacing(iGridSpacing); - resampler->SetOutputParametersFromImage(reader->GetOutput()); + resampler->SetDeformationFieldSpacing(gridSpacing); 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();