From ce4792013d50913159c9832d0c8320ace4bf0daf Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Tue, 9 Sep 2008 09:02:26 +0000 Subject: [PATCH] STYLE : try/catch blocs supression in Radiometry testing. --- .../otbAtmosphericCorrectionParametersNew.cxx | 27 +- ...metersTo6SAtmosphericRadiativeTermsNew.cxx | 9 +- .../otbAtmosphericCorrectionSequencement.cxx | 27 +- .../otbAtmosphericRadiativeTermsNew.cxx | 25 +- .../otbDEMCaracteristicsExtractor.cxx | 107 +++---- .../otbDEMCaracteristicsExtractorNew.cxx | 25 +- .../Radiometry/otbFilterFunctionValues.cxx | 88 +++--- .../otbImageToLuminanceImageFilter.cxx | 88 +++--- .../otbImageToLuminanceImageFilterNew.cxx | 33 +-- .../otbImageToReflectanceImageFilter.cxx | 147 +++++----- .../otbImageToReflectanceImageFilterNew.cxx | 33 +-- .../otbLuminanceToReflectanceImageFilter.cxx | 127 ++++----- ...tbLuminanceToReflectanceImageFilterNew.cxx | 34 +-- ...lRAndBAndNIRVegetationIndexImageFilter.cxx | 105 +++---- ...ndBAndNIRVegetationIndexImageFilterNew.cxx | 33 +-- ...annelRAndNIRVegetationIndexImageFilter.cxx | 142 ++++------ ...elRAndNIRVegetationIndexImageFilterNew.cxx | 31 +- ...bRAndBAndNIRVegetationIndexImageFilter.cxx | 122 ++++---- ...ndBAndNIRVegetationIndexImageFilterNew.cxx | 40 +-- .../otbRAndNIRVegetationIndexImageFilter.cxx | 153 +++++----- ...tbRAndNIRVegetationIndexImageFilterNew.cxx | 37 +-- .../Code/Radiometry/otbRadiometryTests4.cxx | 2 +- ...ectanceToSurfaceReflectanceImageFilter.cxx | 113 ++++---- ...anceToSurfaceReflectanceImageFilterNew.cxx | 33 +-- ...ToRomaniaSurfaceReflectanceImageFilter.cxx | 239 ++++++++-------- ...SIXSTraitsComputeAtmosphericParameters.cxx | 266 +++++++++--------- ...annelRAndNIRVegetationIndexImageFilter.cxx | 112 +++----- ...ASetBRAndNIRVegetationIndexImageFilter.cxx | 118 ++++---- ...jencyEffect6SCorrectionSchemeFilterNew.cxx | 32 +-- 29 files changed, 971 insertions(+), 1377 deletions(-) diff --git a/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx b/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx index b268043abf..49be87b4dc 100644 --- a/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx +++ b/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx @@ -26,26 +26,11 @@ int otbAtmosphericCorrectionParametersNew(int argc, char * argv[]) { - try - { - typedef otb::AtmosphericCorrectionParameters AtmosphericCorrectionParametersType; - typedef otb::FilterFunctionValues FilterFunctionValuesType; - // Instantiating object - AtmosphericCorrectionParametersType::Pointer objectAtmo = AtmosphericCorrectionParametersType::New(); - FilterFunctionValuesType::Pointer objectFilter = FilterFunctionValuesType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::AtmosphericCorrectionParameters AtmosphericCorrectionParametersType; + typedef otb::FilterFunctionValues FilterFunctionValuesType; + // Instantiating object + AtmosphericCorrectionParametersType::Pointer objectAtmo = AtmosphericCorrectionParametersType::New(); + FilterFunctionValuesType::Pointer objectFilter = FilterFunctionValuesType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew.cxx b/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew.cxx index ad2338d2dc..39139f2464 100644 --- a/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew.cxx +++ b/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew.cxx @@ -21,8 +21,9 @@ int otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew(int argc, char * argv[]) { - typedef otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType; - // Instantiating object - AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType::Pointer object = AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType::New(); - return EXIT_SUCCESS; + typedef otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType; + // Instantiating object + AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType::Pointer object = AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsType::New(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbAtmosphericCorrectionSequencement.cxx b/Testing/Code/Radiometry/otbAtmosphericCorrectionSequencement.cxx index db3d8547f4..53cd613f6b 100755 --- a/Testing/Code/Radiometry/otbAtmosphericCorrectionSequencement.cxx +++ b/Testing/Code/Radiometry/otbAtmosphericCorrectionSequencement.cxx @@ -62,32 +62,9 @@ int otbAtmosphericCorrectionSequencementTest( int argc, char *argv[] ) ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); - // Software Guide : BeginLatex - // - // The invocation of the \code{GenerateOutputInformation()} method on the reader - // to known the number of component per pixel of the image. It is recommended to - // place GenerateOutputInformation calls in a \code{try/catch} block in case - // errors occur and exceptions are thrown. - // - // Software Guide : EndLatex - // Software Guide : BeginCodeSnippet - try - { - reader->GenerateOutputInformation(); - } - catch( itk::ExceptionObject & excep ) - { - std::cerr << "Exception caught !" << std::endl; - std::cerr << excep << std::endl; - } - // Software Guide : EndCodeSnippet - catch( ... ) - { - std::cout << "Unknown exception !" << std::endl; - return EXIT_FAILURE; - } - + reader->GenerateOutputInformation(); + unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); diff --git a/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsNew.cxx b/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsNew.cxx index aad7a1ba78..950d4dbd16 100644 --- a/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsNew.cxx +++ b/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsNew.cxx @@ -25,25 +25,10 @@ int otbAtmosphericRadiativeTermsNew(int argc, char * argv[]) { - try - { - typedef otb::AtmosphericRadiativeTerms AtmosphericRadiativeTermsType; - - // Instantiating object - AtmosphericRadiativeTermsType::Pointer object = AtmosphericRadiativeTermsType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::AtmosphericRadiativeTerms AtmosphericRadiativeTermsType; + + // Instantiating object + AtmosphericRadiativeTermsType::Pointer object = AtmosphericRadiativeTermsType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbDEMCaracteristicsExtractor.cxx b/Testing/Code/Radiometry/otbDEMCaracteristicsExtractor.cxx index 93fec2b205..8755f911b9 100644 --- a/Testing/Code/Radiometry/otbDEMCaracteristicsExtractor.cxx +++ b/Testing/Code/Radiometry/otbDEMCaracteristicsExtractor.cxx @@ -25,68 +25,53 @@ int otbDEMCaracteristicsExtractor(int argc, char * argv[]) { - try - { - const char * inputFileName = argv[1]; - const char * outputSlotFileName = argv[6]; - const char * outputAspectFileName = argv[7]; - const char * outputIncidenceFileName = argv[8]; - const char * outputExitanceFileName = argv[9]; + const char * inputFileName = argv[1]; + const char * outputSlotFileName = argv[6]; + const char * outputAspectFileName = argv[7]; + const char * outputIncidenceFileName = argv[8]; + const char * outputExitanceFileName = argv[9]; - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::Image<PixelType, Dimension> InputImageType; - - typedef otb::DEMCaracteristicsExtractor< InputImageType, InputImageType > DEMCaracteristicsExtractorType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::StreamingImageFileWriter<InputImageType> WriterType; - - ReaderType::Pointer input = ReaderType::New(); - WriterType::Pointer slotWriter = WriterType::New(); - WriterType::Pointer aspectWriter = WriterType::New(); - WriterType::Pointer incidenceWriter = WriterType::New(); - WriterType::Pointer exitanceWriter = WriterType::New(); - DEMCaracteristicsExtractorType::Pointer filter = DEMCaracteristicsExtractorType::New(); - - slotWriter->SetNumberOfStreamDivisions(1); - aspectWriter->SetNumberOfStreamDivisions(1); - incidenceWriter->SetNumberOfStreamDivisions(1); - exitanceWriter->SetNumberOfStreamDivisions(1); - - input->SetFileName(inputFileName); - slotWriter->SetFileName(outputSlotFileName); - aspectWriter->SetFileName(outputAspectFileName); - incidenceWriter->SetFileName(outputIncidenceFileName); - exitanceWriter->SetFileName(outputExitanceFileName); - filter->SetInput(input->GetOutput()); - filter->SetViewAzimut(static_cast<double>(atof(argv[2]))); - filter->SetViewAngle(static_cast<double>(atof(argv[3]))); - filter->SetSolarAzimut(static_cast<double>(atof(argv[4]))); - filter->SetSolarAngle(static_cast<double>(atof(argv[5]))); - - slotWriter->SetInput(filter->GetSlopOutput()); - aspectWriter->SetInput(filter->GetAspectOutput()); - incidenceWriter->SetInput(filter->GetIncidenceOutput()); - exitanceWriter->SetInput(filter->GetExitanceOutput()); - - slotWriter->Update(); - aspectWriter->Update(); - incidenceWriter->Update(); - exitanceWriter->Update(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType, Dimension> InputImageType; + + typedef otb::DEMCaracteristicsExtractor< InputImageType, InputImageType > DEMCaracteristicsExtractorType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::StreamingImageFileWriter<InputImageType> WriterType; + + ReaderType::Pointer input = ReaderType::New(); + WriterType::Pointer slotWriter = WriterType::New(); + WriterType::Pointer aspectWriter = WriterType::New(); + WriterType::Pointer incidenceWriter = WriterType::New(); + WriterType::Pointer exitanceWriter = WriterType::New(); + DEMCaracteristicsExtractorType::Pointer filter = DEMCaracteristicsExtractorType::New(); + + slotWriter->SetNumberOfStreamDivisions(1); + aspectWriter->SetNumberOfStreamDivisions(1); + incidenceWriter->SetNumberOfStreamDivisions(1); + exitanceWriter->SetNumberOfStreamDivisions(1); + + input->SetFileName(inputFileName); + slotWriter->SetFileName(outputSlotFileName); + aspectWriter->SetFileName(outputAspectFileName); + incidenceWriter->SetFileName(outputIncidenceFileName); + exitanceWriter->SetFileName(outputExitanceFileName); + filter->SetInput(input->GetOutput()); + filter->SetViewAzimut(static_cast<double>(atof(argv[2]))); + filter->SetViewAngle(static_cast<double>(atof(argv[3]))); + filter->SetSolarAzimut(static_cast<double>(atof(argv[4]))); + filter->SetSolarAngle(static_cast<double>(atof(argv[5]))); + + slotWriter->SetInput(filter->GetSlopOutput()); + aspectWriter->SetInput(filter->GetAspectOutput()); + incidenceWriter->SetInput(filter->GetIncidenceOutput()); + exitanceWriter->SetInput(filter->GetExitanceOutput()); + + slotWriter->Update(); + aspectWriter->Update(); + incidenceWriter->Update(); + exitanceWriter->Update(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbDEMCaracteristicsExtractorNew.cxx b/Testing/Code/Radiometry/otbDEMCaracteristicsExtractorNew.cxx index 93e49aa77b..714cf1881e 100644 --- a/Testing/Code/Radiometry/otbDEMCaracteristicsExtractorNew.cxx +++ b/Testing/Code/Radiometry/otbDEMCaracteristicsExtractorNew.cxx @@ -23,27 +23,12 @@ int otbDEMCaracteristicsExtractorNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::Image<PixelType, Dimension> InputImageType; - typedef otb::DEMCaracteristicsExtractor< InputImageType, InputImageType > DEMCaracteristicsExtractorType; - - DEMCaracteristicsExtractorType::Pointer filter = DEMCaracteristicsExtractorType::New(); - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType, Dimension> InputImageType; + typedef otb::DEMCaracteristicsExtractor< InputImageType, InputImageType > DEMCaracteristicsExtractorType; - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } + DEMCaracteristicsExtractorType::Pointer filter = DEMCaracteristicsExtractorType::New(); - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbFilterFunctionValues.cxx b/Testing/Code/Radiometry/otbFilterFunctionValues.cxx index cf274bdf2d..bbef921166 100644 --- a/Testing/Code/Radiometry/otbFilterFunctionValues.cxx +++ b/Testing/Code/Radiometry/otbFilterFunctionValues.cxx @@ -27,65 +27,51 @@ int otbFilterFunctionValuesTest(int argc, char * argv[]) { - try - { - char * outname = argv[1]; - const double SIXSStepOfWavelenghtSpectralBandValues(0.0025); + char * outname = argv[1]; + const double SIXSStepOfWavelenghtSpectralBandValues(0.0025); - typedef otb::FilterFunctionValues FilterFunctionValuesType; - // Instantiating object - FilterFunctionValuesType::Pointer object = FilterFunctionValuesType::New(); - FilterFunctionValuesType::ValuesVectorType vect; + typedef otb::FilterFunctionValues FilterFunctionValuesType; + // Instantiating object + FilterFunctionValuesType::Pointer object = FilterFunctionValuesType::New(); + FilterFunctionValuesType::ValuesVectorType vect; - for(int i=5; i<argc; i++) - { - vect.push_back(atof(argv[i])); - } + for(int i=5; i<argc; i++) + { + vect.push_back(atof(argv[i])); + } - object->SetMinSpectralValue(atof(argv[2])); - object->SetMaxSpectralValue(atof(argv[3])); - object->SetUserStep(atof(argv[4])); - object->SetFilterFunctionValues(vect); + object->SetMinSpectralValue(atof(argv[2])); + object->SetMaxSpectralValue(atof(argv[3])); + object->SetUserStep(atof(argv[4])); + object->SetFilterFunctionValues(vect); - // Call interpolate - otb::SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S( - SIXSStepOfWavelenghtSpectralBandValues, - object); + // Call interpolate + otb::SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S( + SIXSStepOfWavelenghtSpectralBandValues, + object); - // Writing output file - std::ofstream file; - file.open(outname); - - file <<"Input Vector :"<<std::endl; - for (unsigned int i=0; i<vect.size(); i++) - { - file<< vect[i] <<std::endl; - } - file<<std::endl; - file<<"Output vector :"<<std::endl; - for (unsigned int i=0; i<object->GetFilterFunctionValues6S().size(); i++) - { - file<< object->GetFilterFunctionValues6S()[i] <<std::endl; - } - file<<std::endl; - file<<"L_min :"<<object->GetMinSpectralValue()<<std::endl; - file<<"L_max :"<<object->GetMaxSpectralValue()<<std::endl; + // Writing output file + std::ofstream file; + file.open(outname); - file.close(); + file <<"Input Vector :"<<std::endl; + for (unsigned int i=0; i<vect.size(); i++) + { + file<< vect[i] <<std::endl; + } + file<<std::endl; + file<<"Output vector :"<<std::endl; + for (unsigned int i=0; i<object->GetFilterFunctionValues6S().size(); i++) + { + file<< object->GetFilterFunctionValues6S()[i] <<std::endl; } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } + file<<std::endl; + file<<"L_min :"<<object->GetMinSpectralValue()<<std::endl; + file<<"L_max :"<<object->GetMaxSpectralValue()<<std::endl; + + file.close(); + - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbImageToLuminanceImageFilter.cxx b/Testing/Code/Radiometry/otbImageToLuminanceImageFilter.cxx index 45ec4e80db..33cb938395 100644 --- a/Testing/Code/Radiometry/otbImageToLuminanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbImageToLuminanceImageFilter.cxx @@ -26,62 +26,48 @@ int otbImageToLuminanceImageFilter(int argc, char * argv[]) { - try + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::VectorImage<PixelType,Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + typedef otb::ImageToLuminanceImageFilter<InputImageType,OutputImageType> ImageToLuminanceImageFilterType; + typedef ImageToLuminanceImageFilterType::VectorType VectorType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + reader->GenerateOutputInformation(); + + unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + + VectorType alpha(nbOfComponent); + VectorType beta(nbOfComponent); + alpha.Fill(0); + beta.Fill(0); + + for (unsigned int i=0;i<nbOfComponent;i++) { - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::VectorImage<PixelType,Dimension> OutputImageType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; - typedef otb::ImageToLuminanceImageFilter<InputImageType,OutputImageType> ImageToLuminanceImageFilterType; - typedef ImageToLuminanceImageFilterType::VectorType VectorType; - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - reader->GenerateOutputInformation(); - - unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); - - VectorType alpha(nbOfComponent); - VectorType beta(nbOfComponent); - alpha.Fill(0); - beta.Fill(0); - - for (unsigned int i=0;i<nbOfComponent;i++) - { - alpha[i] = static_cast<double>(atof(argv[i+3])); - beta[i] = static_cast<double>(atof(argv[i+7])); - } + alpha[i] = static_cast<double>(atof(argv[i+3])); + beta[i] = static_cast<double>(atof(argv[i+7])); + } - // Instantiating object - ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New(); - filter->SetAlpha(alpha); - filter->SetBeta(beta); - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); + // Instantiating object + ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New(); + filter->SetAlpha(alpha); + filter->SetBeta(beta); + filter->SetInput(reader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); + - } - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbImageToLuminanceImageFilterNew.cxx b/Testing/Code/Radiometry/otbImageToLuminanceImageFilterNew.cxx index b0de89bd15..32bf0328cc 100644 --- a/Testing/Code/Radiometry/otbImageToLuminanceImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbImageToLuminanceImageFilterNew.cxx @@ -23,29 +23,14 @@ int otbImageToLuminanceImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - - typedef otb::ImageToLuminanceImageFilter<InputImageType,InputImageType> ImageToLuminanceImageFilterType; - - // Instantiating object - ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + + typedef otb::ImageToLuminanceImageFilter<InputImageType,InputImageType> ImageToLuminanceImageFilterType; + + // Instantiating object + ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbImageToReflectanceImageFilter.cxx b/Testing/Code/Radiometry/otbImageToReflectanceImageFilter.cxx index 63bc7af7ea..1bca7f37eb 100644 --- a/Testing/Code/Radiometry/otbImageToReflectanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbImageToReflectanceImageFilter.cxx @@ -26,92 +26,77 @@ int otbImageToReflectanceImageFilter(int argc, char * argv[]) { - try + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + const double angle = static_cast<double>(atof(argv[3])); + double flux = 0.; + int day = 1; + int month = 1; + + if (argc==17) { - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - const double angle = static_cast<double>(atof(argv[3])); - double flux = 0.; - int day = 1; - int month = 1; - - if (argc==17) - { - flux = static_cast<double>(atof(argv[16])); - } - else - { - day = atoi(argv[16]); - month = atoi(argv[17]); - } - - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::VectorImage<PixelType,Dimension> OutputImageType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; - typedef otb::ImageToReflectanceImageFilter<InputImageType,OutputImageType> ImageToReflectanceImageFilterType; - typedef ImageToReflectanceImageFilterType::VectorType VectorType; - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - reader->GenerateOutputInformation(); - - unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); - - VectorType alpha(nbOfComponent); - VectorType beta(nbOfComponent); - VectorType solarIllumination(nbOfComponent); - alpha.Fill(0); - beta.Fill(0); - solarIllumination.Fill(0); - - for (unsigned int i=0; i<nbOfComponent; i++) - { - alpha[i] = static_cast<double>(atof(argv[i+4])); - beta[i] = static_cast<double>(atof(argv[i+8])); - solarIllumination[i] = static_cast<double>(atof(argv[i+12])); - } + flux = static_cast<double>(atof(argv[16])); + } + else + { + day = atoi(argv[16]); + month = atoi(argv[17]); + } + + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::VectorImage<PixelType,Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + typedef otb::ImageToReflectanceImageFilter<InputImageType,OutputImageType> ImageToReflectanceImageFilterType; + typedef ImageToReflectanceImageFilterType::VectorType VectorType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + reader->GenerateOutputInformation(); + + unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + + VectorType alpha(nbOfComponent); + VectorType beta(nbOfComponent); + VectorType solarIllumination(nbOfComponent); + alpha.Fill(0); + beta.Fill(0); + solarIllumination.Fill(0); + + for (unsigned int i=0; i<nbOfComponent; i++) + { + alpha[i] = static_cast<double>(atof(argv[i+4])); + beta[i] = static_cast<double>(atof(argv[i+8])); + solarIllumination[i] = static_cast<double>(atof(argv[i+12])); + } - // Instantiating object - ImageToReflectanceImageFilterType::Pointer filter = ImageToReflectanceImageFilterType::New(); - - filter->SetAlpha(alpha); - filter->SetBeta(beta); - filter->SetZenithalSolarAngle(angle); - filter->SetSolarIllumination(solarIllumination); - - if (argc==17) - { - filter->SetFluxNormalizationCoefficient(flux); - } - else - { - filter->SetDay(day); - filter->SetMonth(month); - } - - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); + // Instantiating object + ImageToReflectanceImageFilterType::Pointer filter = ImageToReflectanceImageFilterType::New(); + filter->SetAlpha(alpha); + filter->SetBeta(beta); + filter->SetZenithalSolarAngle(angle); + filter->SetSolarIllumination(solarIllumination); + + if (argc==17) + { + filter->SetFluxNormalizationCoefficient(flux); + } + else + { + filter->SetDay(day); + filter->SetMonth(month); } - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + filter->SetInput(reader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbImageToReflectanceImageFilterNew.cxx b/Testing/Code/Radiometry/otbImageToReflectanceImageFilterNew.cxx index b9294f1a0e..b81d60107b 100644 --- a/Testing/Code/Radiometry/otbImageToReflectanceImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbImageToReflectanceImageFilterNew.cxx @@ -23,29 +23,14 @@ int otbImageToReflectanceImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - - typedef otb::ImageToReflectanceImageFilter<InputImageType,InputImageType> ImageToReflectanceImageFilterType; - - // Instantiating object - ImageToReflectanceImageFilterType::Pointer filter = ImageToReflectanceImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + + typedef otb::ImageToReflectanceImageFilter<InputImageType,InputImageType> ImageToReflectanceImageFilterType; + + // Instantiating object + ImageToReflectanceImageFilterType::Pointer filter = ImageToReflectanceImageFilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilter.cxx b/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilter.cxx index 9af26d39dd..9046ef839c 100755 --- a/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilter.cxx @@ -26,82 +26,67 @@ int otbLuminanceToReflectanceImageFilter(int argc, char * argv[]) { - try + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + const double angle = static_cast<double>(atof(argv[3])); + double flux = 0.; + int day = 1; + int month = 1; + + if (argc==9) { - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - const double angle = static_cast<double>(atof(argv[3])); - double flux = 0.; - int day = 1; - int month = 1; - - if (argc==9) - { - flux = static_cast<double>(atof(argv[8])); - } - else - { - day = atoi(argv[8]); - month = atoi(argv[9]); - } - - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::VectorImage<PixelType,Dimension> OutputImageType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; - typedef otb::LuminanceToReflectanceImageFilter<InputImageType,OutputImageType> LuminanceToReflectanceImageFilterType; - typedef LuminanceToReflectanceImageFilterType::VectorType VectorType; - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - reader->GenerateOutputInformation(); - - unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); - // WARNING : 1 ELEMENT FOR EACH PIXEL IMAGE COMPONENT - VectorType solarIllumination(nbOfComponent); - solarIllumination.Fill(0); - solarIllumination[0] = static_cast<double>(atof(argv[4])); - solarIllumination[1] = static_cast<double>(atof(argv[5])); - solarIllumination[2] = static_cast<double>(atof(argv[6])); - solarIllumination[3] = static_cast<double>(atof(argv[7])); + flux = static_cast<double>(atof(argv[8])); + } + else + { + day = atoi(argv[8]); + month = atoi(argv[9]); + } + + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::VectorImage<PixelType,Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + typedef otb::LuminanceToReflectanceImageFilter<InputImageType,OutputImageType> LuminanceToReflectanceImageFilterType; + typedef LuminanceToReflectanceImageFilterType::VectorType VectorType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + reader->GenerateOutputInformation(); + + unsigned int nbOfComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + // WARNING : 1 ELEMENT FOR EACH PIXEL IMAGE COMPONENT + VectorType solarIllumination(nbOfComponent); + solarIllumination.Fill(0); + solarIllumination[0] = static_cast<double>(atof(argv[4])); + solarIllumination[1] = static_cast<double>(atof(argv[5])); + solarIllumination[2] = static_cast<double>(atof(argv[6])); + solarIllumination[3] = static_cast<double>(atof(argv[7])); - // Instantiating object - LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New(); - - filter->SetZenithalSolarAngle(angle); - filter->SetSolarIllumination(solarIllumination); - if (argc==9) - { - filter->SetFluxNormalizationCoefficient(flux); - } - else - { - filter->SetDay(day); - filter->SetMonth(month); - } - - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); + // Instantiating object + LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New(); + filter->SetZenithalSolarAngle(angle); + filter->SetSolarIllumination(solarIllumination); + if (argc==9) + { + filter->SetFluxNormalizationCoefficient(flux); + } + else + { + filter->SetDay(day); + filter->SetMonth(month); } + + filter->SetInput(reader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilterNew.cxx b/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilterNew.cxx index 3b1a3528b9..6a09bda67d 100644 --- a/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbLuminanceToReflectanceImageFilterNew.cxx @@ -23,29 +23,15 @@ int otbLuminanceToReflectanceImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - - typedef otb::LuminanceToReflectanceImageFilter<InputImageType,InputImageType> LuminanceToReflectanceImageFilterType; - - // Instantiating object - LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + + typedef otb::LuminanceToReflectanceImageFilter<InputImageType,InputImageType> LuminanceToReflectanceImageFilterType; + + // Instantiating object + LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx index 5f129a186d..d329e95744 100644 --- a/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx @@ -27,71 +27,54 @@ template<class TInputImage, class TOutputImage, class TFunction> int generic_MultiChannelRAndBAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputImage> ReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::MultiChannelRAndBAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> - MultiChannelRAndBAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename MultiChannelRAndBAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndBAndNIRVegetationIndexImageFilterType::New(); - typename ReaderType::Pointer reader = ReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); - - const char * inputFilename = argv[1]; - const char * outputFilename = argv[2]; - unsigned int redChannel(::atoi(argv[3])); - unsigned int blueChannel(::atoi(argv[4])); - unsigned int nirChannel(::atoi(argv[5])); - double gamma(::atof(argv[6])); - reader->SetFileName( inputFilename ); - writer->SetFileName( outputFilename ); - filter->SetRedIndex(redChannel); - filter->SetBlueIndex(blueChannel); - filter->SetNIRIndex(nirChannel); - filter->GetFunctor().SetGamma(gamma); - filter->SetInput( reader->GetOutput() ); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::ImageFileReader<TInputImage> ReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::MultiChannelRAndBAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> + MultiChannelRAndBAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename MultiChannelRAndBAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndBAndNIRVegetationIndexImageFilterType::New(); + typename ReaderType::Pointer reader = ReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; + unsigned int redChannel(::atoi(argv[3])); + unsigned int blueChannel(::atoi(argv[4])); + unsigned int nirChannel(::atoi(argv[5])); + double gamma(::atof(argv[6])); + reader->SetFileName( inputFilename ); + writer->SetFileName( outputFilename ); + filter->SetRedIndex(redChannel); + filter->SetBlueIndex(blueChannel); + filter->SetNIRIndex(nirChannel); + filter->GetFunctor().SetGamma(gamma); + filter->SetInput( reader->GetOutput() ); + writer->SetInput( filter->GetOutput() ); + writer->Update(); + + return EXIT_SUCCESS; - - } int otbMultiChannelRAndBAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef otb::VectorImage<unsigned char ,Dimension> InputImageType; - typedef otb::Image<float,Dimension> OutputImageType; - - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "ARVI" ) return( generic_MultiChannelRAndBAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::ARVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - InputImageType::InternalPixelType, + const unsigned int Dimension = 2; + typedef otb::VectorImage<unsigned char ,Dimension> InputImageType; + typedef otb::Image<float,Dimension> OutputImageType; + + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "ARVI" ) return( generic_MultiChannelRAndBAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::ARVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + InputImageType::InternalPixelType, OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + (argc,argv) ); + else + return EXIT_FAILURE; + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilterNew.cxx b/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilterNew.cxx index 2987d24743..b114aeb4a2 100644 --- a/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilterNew.cxx @@ -21,30 +21,17 @@ #include "otbImage.h" #include "otbVectorImage.h" + int otbMultiChannelRAndBAndNIRVegetationIndexImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef otb::VectorImage<unsigned char,Dimension> InputImageType; - typedef otb::Image<float,Dimension> OutputImageType; - typedef otb::MultiChannelRAndBAndNIRVegetationIndexImageFilter<InputImageType,OutputImageType> MultiChannelRAndBAndNIRVegetationIndexImageFilterType; - - // Instantiating object - MultiChannelRAndBAndNIRVegetationIndexImageFilterType::Pointer object = MultiChannelRAndBAndNIRVegetationIndexImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef otb::VectorImage<unsigned char,Dimension> InputImageType; + typedef otb::Image<float,Dimension> OutputImageType; + typedef otb::MultiChannelRAndBAndNIRVegetationIndexImageFilter<InputImageType,OutputImageType> MultiChannelRAndBAndNIRVegetationIndexImageFilterType; + + // Instantiating object + MultiChannelRAndBAndNIRVegetationIndexImageFilterType::Pointer object = MultiChannelRAndBAndNIRVegetationIndexImageFilterType::New(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.cxx index 113c59acfa..daec01d49d 100644 --- a/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.cxx @@ -24,94 +24,76 @@ #include "otbImageFileWriter.h" #include "otbVegetationIndex.h" + template<class TInputImage, class TOutputImage, class TFunction> int generic_MultiChannelRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputImage> ReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> - MultiChannelRAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); - typename ReaderType::Pointer reader = ReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); + typedef otb::ImageFileReader<TInputImage> ReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> + MultiChannelRAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); + typename ReaderType::Pointer reader = ReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; + unsigned int redChannel(::atoi(argv[3])); + unsigned int nirChannel(::atoi(argv[4])); + reader->SetFileName( inputFilename ); + writer->SetFileName( outputFilename ); + filter->SetRedIndex(redChannel); + filter->SetNIRIndex(nirChannel); + filter->SetInput( reader->GetOutput() ); + writer->SetInput( filter->GetOutput() ); + writer->Update(); - const char * inputFilename = argv[1]; - const char * outputFilename = argv[2]; - unsigned int redChannel(::atoi(argv[3])); - unsigned int nirChannel(::atoi(argv[4])); - reader->SetFileName( inputFilename ); - writer->SetFileName( outputFilename ); - filter->SetRedIndex(redChannel); - filter->SetNIRIndex(nirChannel); - filter->SetInput( reader->GetOutput() ); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; - - } int otbMultiChannelRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef otb::VectorImage<unsigned char ,Dimension> InputImageType; - typedef otb::Image<float,Dimension> OutputImageType; + const unsigned int Dimension = 2; + typedef otb::VectorImage<unsigned char ,Dimension> InputImageType; + typedef otb::Image<float,Dimension> OutputImageType; - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "NDVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::NDVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else if ( strArgv == "RVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::RVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); -/* else if ( strArgv == "PVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::PVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) );*/ - else if ( strArgv == "SAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::SAVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); -/* else if ( strArgv == "TSAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::TSAVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) );*/ - else if ( strArgv == "MSAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::MSAVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "NDVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::NDVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else if ( strArgv == "RVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::RVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + /* else if ( strArgv == "PVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::PVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) );*/ + else if ( strArgv == "SAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::SAVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + /* else if ( strArgv == "TSAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::TSAVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) );*/ + else if ( strArgv == "MSAVI" ) return( generic_MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::MSAVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilterNew.cxx b/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilterNew.cxx index 4834605325..0635c91464 100644 --- a/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilterNew.cxx @@ -23,28 +23,13 @@ int otbMultiChannelRAndNIRVegetationIndexImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef otb::VectorImage<unsigned char,Dimension> InputImageType; - typedef otb::Image<float,Dimension> OutputImageType; - typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType,OutputImageType> MultiChannelRAndNIRVegetationIndexImageFilterType; - - // Instantiating object - MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer object = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef otb::VectorImage<unsigned char,Dimension> InputImageType; + typedef otb::Image<float,Dimension> OutputImageType; + typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<InputImageType,OutputImageType> MultiChannelRAndNIRVegetationIndexImageFilterType; + + // Instantiating object + MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer object = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilter.cxx index 5b3adf6efe..9eb6574c2b 100644 --- a/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilter.cxx @@ -23,82 +23,66 @@ #include "otbImageFileWriter.h" #include "otbVegetationIndex.h" + template<class TInputRImage, class TInputBImage, class TInputNIRImage, class TOutputImage, class TFunction> int generic_RAndBAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputRImage> RReaderType; - typedef otb::ImageFileReader<TInputBImage> BReaderType; - typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::RAndBAndNIRVegetationIndexImageFilter<TInputRImage,TInputBImage,TInputNIRImage,TOutputImage,TFunction> - RAndBAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename RAndBAndNIRVegetationIndexImageFilterType::Pointer filter = RAndBAndNIRVegetationIndexImageFilterType::New(); - typename RReaderType::Pointer readerR = RReaderType::New(); - typename BReaderType::Pointer readerB = BReaderType::New(); - typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); - - const char * inputFilenameR = argv[1]; - const char * inputFilenameB = argv[2]; - const char * inputFilenameNIR = argv[3]; - const char * outputFilename = argv[4]; - double gamma(::atof(argv[5])); - - readerR->SetFileName( inputFilenameR ); - readerB->SetFileName( inputFilenameB ); - readerNIR->SetFileName( inputFilenameNIR ); - writer->SetFileName( outputFilename ); - filter->SetInputR( readerR->GetOutput() ); - filter->SetInputB( readerB->GetOutput() ); - filter->SetInputNIR( readerNIR->GetOutput() ); - filter->GetFunctor().SetGamma(gamma); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::ImageFileReader<TInputRImage> RReaderType; + typedef otb::ImageFileReader<TInputBImage> BReaderType; + typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::RAndBAndNIRVegetationIndexImageFilter<TInputRImage,TInputBImage,TInputNIRImage,TOutputImage,TFunction> + RAndBAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename RAndBAndNIRVegetationIndexImageFilterType::Pointer filter = RAndBAndNIRVegetationIndexImageFilterType::New(); + typename RReaderType::Pointer readerR = RReaderType::New(); + typename BReaderType::Pointer readerB = BReaderType::New(); + typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + + const char * inputFilenameR = argv[1]; + const char * inputFilenameB = argv[2]; + const char * inputFilenameNIR = argv[3]; + const char * outputFilename = argv[4]; + double gamma(::atof(argv[5])); + + readerR->SetFileName( inputFilenameR ); + readerB->SetFileName( inputFilenameB ); + readerNIR->SetFileName( inputFilenameNIR ); + writer->SetFileName( outputFilename ); + filter->SetInputR( readerR->GetOutput() ); + filter->SetInputB( readerB->GetOutput() ); + filter->SetInputNIR( readerNIR->GetOutput() ); + filter->GetFunctor().SetGamma(gamma); + writer->SetInput( filter->GetOutput() ); + writer->Update(); + + return EXIT_SUCCESS; - - } + int otbRAndBAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - typedef otb::Image<PixelType,Dimension> InputRImageType; - typedef otb::Image<PixelType,Dimension> InputBImageType; - typedef otb::Image<PixelType,Dimension> InputNIRImageType; - typedef otb::Image<float,Dimension> OutputImageType; + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + typedef otb::Image<PixelType,Dimension> InputRImageType; + typedef otb::Image<PixelType,Dimension> InputBImageType; + typedef otb::Image<PixelType,Dimension> InputNIRImageType; + typedef otb::Image<float,Dimension> OutputImageType; - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "ARVI" ) return( generic_RAndBAndNIRVegetationIndexImageFilter<InputRImageType, InputBImageType, InputNIRImageType, OutputImageType, - otb::Functor::ARVI< InputRImageType::PixelType, - InputBImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "ARVI" ) return( generic_RAndBAndNIRVegetationIndexImageFilter<InputRImageType, InputBImageType, InputNIRImageType, OutputImageType, + otb::Functor::ARVI< InputRImageType::PixelType, + InputBImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilterNew.cxx b/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilterNew.cxx index 525d055c95..b14babd293 100644 --- a/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbRAndBAndNIRVegetationIndexImageFilterNew.cxx @@ -26,32 +26,18 @@ int otbRAndBAndNIRVegetationIndexImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - typedef otb::Image<PixelType,Dimension> InputRImageType; - typedef otb::Image<PixelType,Dimension> InputBImageType; - typedef otb::Image<PixelType,Dimension> InputNIRImageType; - typedef otb::Image<PixelType,Dimension> OutputImageType; - - typedef otb::RAndBAndNIRVegetationIndexImageFilter<InputRImageType,InputBImageType,InputNIRImageType,OutputImageType> RAndBAndNIRVegetationIndexImageFilterType; - - // Instantiating object - RAndBAndNIRVegetationIndexImageFilterType::Pointer object = RAndBAndNIRVegetationIndexImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + typedef otb::Image<PixelType,Dimension> InputRImageType; + typedef otb::Image<PixelType,Dimension> InputBImageType; + typedef otb::Image<PixelType,Dimension> InputNIRImageType; + typedef otb::Image<PixelType,Dimension> OutputImageType; + + typedef otb::RAndBAndNIRVegetationIndexImageFilter<InputRImageType,InputBImageType,InputNIRImageType,OutputImageType> RAndBAndNIRVegetationIndexImageFilterType; + + // Instantiating object + RAndBAndNIRVegetationIndexImageFilterType::Pointer object = RAndBAndNIRVegetationIndexImageFilterType::New(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilter.cxx index c3d614351e..a3b302f5f9 100644 --- a/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilter.cxx @@ -26,95 +26,78 @@ template<class TInputRImage, class TInputNIRImage, class TOutputImage, class TFunction> int generic_RAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputRImage> RReaderType; - typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::RAndNIRVegetationIndexImageFilter<TInputRImage,TInputNIRImage,TOutputImage,TFunction> - RAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename RAndNIRVegetationIndexImageFilterType::Pointer filter = RAndNIRVegetationIndexImageFilterType::New(); - typename RReaderType::Pointer readerR = RReaderType::New(); - typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); - - const char * inputFilenameR = argv[1]; - const char * inputFilenameNIR = argv[2]; - const char * outputFilename = argv[3]; - - readerR->SetFileName( inputFilenameR ); - readerNIR->SetFileName( inputFilenameNIR ); - writer->SetFileName( outputFilename ); - filter->SetInputR( readerR->GetOutput() ); - filter->SetInputNIR( readerNIR->GetOutput() ); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::ImageFileReader<TInputRImage> RReaderType; + typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::RAndNIRVegetationIndexImageFilter<TInputRImage,TInputNIRImage,TOutputImage,TFunction> + RAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename RAndNIRVegetationIndexImageFilterType::Pointer filter = RAndNIRVegetationIndexImageFilterType::New(); + typename RReaderType::Pointer readerR = RReaderType::New(); + typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + + const char * inputFilenameR = argv[1]; + const char * inputFilenameNIR = argv[2]; + const char * outputFilename = argv[3]; + + readerR->SetFileName( inputFilenameR ); + readerNIR->SetFileName( inputFilenameNIR ); + writer->SetFileName( outputFilename ); + filter->SetInputR( readerR->GetOutput() ); + filter->SetInputNIR( readerNIR->GetOutput() ); + writer->SetInput( filter->GetOutput() ); + writer->Update(); + + return EXIT_SUCCESS; - - } + int otbRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - typedef otb::Image<PixelType,Dimension> InputRImageType; - typedef otb::Image<PixelType,Dimension> InputNIRImageType; - typedef otb::Image<float,Dimension> OutputImageType; + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + typedef otb::Image<PixelType,Dimension> InputRImageType; + typedef otb::Image<PixelType,Dimension> InputNIRImageType; + typedef otb::Image<float,Dimension> OutputImageType; - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "NDVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::NDVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else if ( strArgv == "RVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::RVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); -/* else if ( strArgv == "PVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::PVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) );*/ - else if ( strArgv == "SAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::SAVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); -/* else if ( strArgv == "TSAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::TSAVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) );*/ - else if ( strArgv == "MSAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::MSAVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "NDVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::NDVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else if ( strArgv == "RVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::RVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + /* else if ( strArgv == "PVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::PVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) );*/ + else if ( strArgv == "SAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::SAVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + /* else if ( strArgv == "TSAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::TSAVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) );*/ + else if ( strArgv == "MSAVI" ) return( generic_RAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::MSAVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilterNew.cxx b/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilterNew.cxx index 342af714d0..4f1507314b 100644 --- a/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbRAndNIRVegetationIndexImageFilterNew.cxx @@ -27,31 +27,16 @@ int otbRAndNIRVegetationIndexImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - typedef otb::Image<PixelType,Dimension> InputRImageType; - typedef itk::Image<PixelType,Dimension> InputNIRImageType; - typedef itk::Image<PixelType,Dimension> OutputImageType; - - typedef otb::RAndNIRVegetationIndexImageFilter<InputRImageType,InputNIRImageType,OutputImageType> RAndNIRVegetationIndexImageFilterType; - - // Instantiating object - RAndNIRVegetationIndexImageFilterType::Pointer object = RAndNIRVegetationIndexImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + typedef otb::Image<PixelType,Dimension> InputRImageType; + typedef itk::Image<PixelType,Dimension> InputNIRImageType; + typedef itk::Image<PixelType,Dimension> OutputImageType; + + typedef otb::RAndNIRVegetationIndexImageFilter<InputRImageType,InputNIRImageType,OutputImageType> RAndNIRVegetationIndexImageFilterType; + + // Instantiating object + RAndNIRVegetationIndexImageFilterType::Pointer object = RAndNIRVegetationIndexImageFilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRadiometryTests4.cxx b/Testing/Code/Radiometry/otbRadiometryTests4.cxx index 9a4a7c62f4..8624026893 100644 --- a/Testing/Code/Radiometry/otbRadiometryTests4.cxx +++ b/Testing/Code/Radiometry/otbRadiometryTests4.cxx @@ -26,7 +26,7 @@ #include "otbTestMain.h" void RegisterTests() -{; +{ REGISTER_TEST(otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTermsNew); REGISTER_TEST(otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms); REGISTER_TEST(otbAtmosphericCorrectionSequencementTest); diff --git a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx index db248efb0f..dcd985f7e0 100644 --- a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx @@ -25,74 +25,59 @@ int otbReflectanceToSurfaceReflectanceImageFilter(int argc, char * argv[]) { - try - { - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - - - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::VectorImage<PixelType,Dimension> OutputImageType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; - typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType, OutputImageType> ReflectanceToSurfaceReflectanceImageFilterType; - typedef otb::AtmosphericRadiativeTerms::DataVectorType DataVectorType; - otb::AtmosphericRadiativeTerms::Pointer atmo = otb::AtmosphericRadiativeTerms::New(); - - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - - reader->GenerateOutputInformation(); - unsigned int nbChannel = reader->GetOutput()->GetNumberOfComponentsPerPixel(); - - DataVectorType intrinsic; - DataVectorType albedo; - DataVectorType gaseous; - DataVectorType downTrans; - DataVectorType upTrans; + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + + + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::VectorImage<PixelType,Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType, OutputImageType> ReflectanceToSurfaceReflectanceImageFilterType; + typedef otb::AtmosphericRadiativeTerms::DataVectorType DataVectorType; + otb::AtmosphericRadiativeTerms::Pointer atmo = otb::AtmosphericRadiativeTerms::New(); + + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + + reader->GenerateOutputInformation(); + unsigned int nbChannel = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + + DataVectorType intrinsic; + DataVectorType albedo; + DataVectorType gaseous; + DataVectorType downTrans; + DataVectorType upTrans; - std::cout<<nbChannel<<std::endl; - for( unsigned int j=0; j<nbChannel; j++) - { - intrinsic.push_back(static_cast<double>(atof(argv[3+j]))); - albedo.push_back(static_cast<double>(atof(argv[3+j+nbChannel]))); - gaseous.push_back(static_cast<double>(atof(argv[3+j+2*nbChannel]))); - downTrans.push_back(static_cast<double>(atof(argv[3+j+3*nbChannel]))); - upTrans.push_back(static_cast<double>(atof(argv[3+j+4*nbChannel]))); - } - - atmo->SetIntrinsicAtmosphericReflectances(intrinsic); - atmo->SetSphericalAlbedos(albedo); - atmo->SetTotalGaseousTransmissions(gaseous); - atmo->SetDownwardTransmittances(downTrans); - atmo->SetUpwardTransmittances(upTrans); + std::cout<<nbChannel<<std::endl; + for( unsigned int j=0; j<nbChannel; j++) + { + intrinsic.push_back(static_cast<double>(atof(argv[3+j]))); + albedo.push_back(static_cast<double>(atof(argv[3+j+nbChannel]))); + gaseous.push_back(static_cast<double>(atof(argv[3+j+2*nbChannel]))); + downTrans.push_back(static_cast<double>(atof(argv[3+j+3*nbChannel]))); + upTrans.push_back(static_cast<double>(atof(argv[3+j+4*nbChannel]))); + } + + atmo->SetIntrinsicAtmosphericReflectances(intrinsic); + atmo->SetSphericalAlbedos(albedo); + atmo->SetTotalGaseousTransmissions(gaseous); + atmo->SetDownwardTransmittances(downTrans); + atmo->SetUpwardTransmittances(upTrans); - // Instantiating object - ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); - filter->SetAtmosphericRadiativeTerms(atmo); - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); + // Instantiating object + ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); + filter->SetAtmosphericRadiativeTerms(atmo); + filter->SetInput(reader->GetOutput()); + writer->SetInput(filter->GetOutput()); - writer->Update(); + writer->Update(); - } - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilterNew.cxx b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilterNew.cxx index ac19965501..a74a8a8f88 100644 --- a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilterNew.cxx +++ b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilterNew.cxx @@ -23,29 +23,14 @@ int otbReflectanceToSurfaceReflectanceImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - - typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType,InputImageType> ReflectanceToSurfaceReflectanceImageFilterType; - - // Instantiating object - ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + + typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType,InputImageType> ReflectanceToSurfaceReflectanceImageFilterType; + + // Instantiating object + ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter.cxx b/Testing/Code/Radiometry/otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter.cxx index 70c5143094..38973a6ba9 100644 --- a/Testing/Code/Radiometry/otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter.cxx @@ -30,146 +30,131 @@ int otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter(int argc, char * argv[]) { - try - { - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - const char * paramFile = argv[3]; - std::vector<const char *> wavelenghFiles; + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + const char * paramFile = argv[3]; + std::vector<const char *> wavelenghFiles; - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::VectorImage<PixelType,Dimension> OutputImageType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; - - typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType, OutputImageType> ReflectanceToSurfaceReflectanceImageFilterType; - typedef otb::AtmosphericRadiativeTerms::DataVectorType DataVectorType; - typedef otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms CorrectionParametersTo6SRadiativeTermsType; - typedef otb::AtmosphericCorrectionParameters CorrectionParametersType; - typedef otb::AtmosphericRadiativeTerms RadiativeTermsType; - typedef otb::FilterFunctionValues FilterFunctionValuesType; - typedef CorrectionParametersType::AerosolModelType AerosolModelType; - typedef FilterFunctionValuesType::WavelenghtSpectralBandType ValueType; - typedef FilterFunctionValuesType::ValuesVectorType ValuesVectorType; - - RadiativeTermsType::Pointer radiative = RadiativeTermsType::New(); - CorrectionParametersType::Pointer param = CorrectionParametersType::New(); - CorrectionParametersTo6SRadiativeTermsType::Pointer corrToRadia = CorrectionParametersTo6SRadiativeTermsType::New(); - FilterFunctionValuesType::Pointer functionValues; + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::VectorImage<PixelType,Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + + typedef otb::ReflectanceToSurfaceReflectanceImageFilter<InputImageType, OutputImageType> ReflectanceToSurfaceReflectanceImageFilterType; + typedef otb::AtmosphericRadiativeTerms::DataVectorType DataVectorType; + typedef otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms CorrectionParametersTo6SRadiativeTermsType; + typedef otb::AtmosphericCorrectionParameters CorrectionParametersType; + typedef otb::AtmosphericRadiativeTerms RadiativeTermsType; + typedef otb::FilterFunctionValues FilterFunctionValuesType; + typedef CorrectionParametersType::AerosolModelType AerosolModelType; + typedef FilterFunctionValuesType::WavelenghtSpectralBandType ValueType; + typedef FilterFunctionValuesType::ValuesVectorType ValuesVectorType; + + RadiativeTermsType::Pointer radiative = RadiativeTermsType::New(); + CorrectionParametersType::Pointer param = CorrectionParametersType::New(); + CorrectionParametersTo6SRadiativeTermsType::Pointer corrToRadia = CorrectionParametersTo6SRadiativeTermsType::New(); + FilterFunctionValuesType::Pointer functionValues; - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - - reader->GenerateOutputInformation(); - unsigned int nbChannel = reader->GetOutput()->GetNumberOfComponentsPerPixel(); - for(unsigned int i=0; i<nbChannel; i++) - { - wavelenghFiles.push_back( argv[i+4] ); - } + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + reader->SetFileName(inputFileName); + writer->SetFileName(outputFileName); + + reader->GenerateOutputInformation(); + unsigned int nbChannel = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + for(unsigned int i=0; i<nbChannel; i++) + { + wavelenghFiles.push_back( argv[i+4] ); + } - ValueType val = 0.0025; + ValueType val = 0.0025; - // Correction parameters initialization - double solarZenithalAngle(0.); - double solarAzimutalAngle(0.); - double viewingZenithalAngle(0.); - double viewingAzimutalAngle(0.); - unsigned int month(0); - unsigned int day(0); - double atmosphericPressure(0.); - double waterVaporAmount(0.); - double ozoneAmount(0.); - double aerosolOptical(0.); + // Correction parameters initialization + double solarZenithalAngle(0.); + double solarAzimutalAngle(0.); + double viewingZenithalAngle(0.); + double viewingAzimutalAngle(0.); + unsigned int month(0); + unsigned int day(0); + double atmosphericPressure(0.); + double waterVaporAmount(0.); + double ozoneAmount(0.); + double aerosolOptical(0.); + std::ifstream fin; + fin.open(paramFile); + //Read input file parameters + fin >> solarZenithalAngle;//asol; + fin >> solarAzimutalAngle;//phi0; + fin >> viewingZenithalAngle;//avis; + fin >> viewingAzimutalAngle;//phiv; + fin >> month;//month; + fin >> day;//jday; + fin >> atmosphericPressure;//pressure; + fin >> waterVaporAmount;//uw; + fin >> ozoneAmount;//uo3; + unsigned int aer(0); + fin >> aer;//iaer; + AerosolModelType aerosolModel = static_cast<AerosolModelType>(aer); + fin >> aerosolOptical;//taer55; + fin.close(); + // Set atmospheric parameters + param->SetSolarZenithalAngle(static_cast<double>(solarZenithalAngle)); + param->SetSolarAzimutalAngle(static_cast<double>(solarAzimutalAngle)); + param->SetViewingZenithalAngle(static_cast<double>(viewingZenithalAngle)); + param->SetViewingAzimutalAngle(static_cast<double>(viewingAzimutalAngle)); + param->SetMonth(month); + param->SetDay(day); + param->SetAtmosphericPressure(static_cast<double>(atmosphericPressure)); + param->SetWaterVaporAmount(static_cast<double>(waterVaporAmount)); + param->SetOzoneAmount(static_cast<double>(ozoneAmount)); + param->SetAerosolModel(aerosolModel); + param->SetAerosolOptical(static_cast<double>(aerosolOptical)); + + + ValuesVectorType vect; + for(unsigned int j=0; j<nbChannel; j++) + { + functionValues = FilterFunctionValuesType::New(); + vect.clear(); + + // Filter function values initialization + float minSpectralValue(0.); + float maxSpectralValue(0.); + float value(0.); + std::ifstream fin; - fin.open(paramFile); //Read input file parameters - fin >> solarZenithalAngle;//asol; - fin >> solarAzimutalAngle;//phi0; - fin >> viewingZenithalAngle;//avis; - fin >> viewingAzimutalAngle;//phiv; - fin >> month;//month; - fin >> day;//jday; - fin >> atmosphericPressure;//pressure; - fin >> waterVaporAmount;//uw; - fin >> ozoneAmount;//uo3; - unsigned int aer(0); - fin >> aer;//iaer; - AerosolModelType aerosolModel = static_cast<AerosolModelType>(aer); - fin >> aerosolOptical;//taer55; - fin.close(); - // Set atmospheric parameters - param->SetSolarZenithalAngle(static_cast<double>(solarZenithalAngle)); - param->SetSolarAzimutalAngle(static_cast<double>(solarAzimutalAngle)); - param->SetViewingZenithalAngle(static_cast<double>(viewingZenithalAngle)); - param->SetViewingAzimutalAngle(static_cast<double>(viewingAzimutalAngle)); - param->SetMonth(month); - param->SetDay(day); - param->SetAtmosphericPressure(static_cast<double>(atmosphericPressure)); - param->SetWaterVaporAmount(static_cast<double>(waterVaporAmount)); - param->SetOzoneAmount(static_cast<double>(ozoneAmount)); - param->SetAerosolModel(aerosolModel); - param->SetAerosolOptical(static_cast<double>(aerosolOptical)); - - - ValuesVectorType vect; - for(unsigned int j=0; j<nbChannel; j++) + fin.open(wavelenghFiles[j]); + fin >> minSpectralValue;//wlinf; + fin >> maxSpectralValue;//wlsup; + + while (!fin.eof() && fin.good()) { - functionValues = FilterFunctionValuesType::New(); - vect.clear(); - - // Filter function values initialization - float minSpectralValue(0.); - float maxSpectralValue(0.); - float value(0.); - - std::ifstream fin; - //Read input file parameters - fin.open(wavelenghFiles[j]); - fin >> minSpectralValue;//wlinf; - fin >> maxSpectralValue;//wlsup; - - while (!fin.eof() && fin.good()) - { - fin >> value; - vect.push_back(value); - } - fin.close(); - functionValues->SetFilterFunctionValues(vect); - functionValues->SetMinSpectralValue(minSpectralValue); - functionValues->SetMaxSpectralValue(maxSpectralValue); - functionValues->SetUserStep( val ); - - param->SetWavelenghtSpectralBandWithIndex(j, functionValues); + fin >> value; + vect.push_back(value); } + fin.close(); + functionValues->SetFilterFunctionValues(vect); + functionValues->SetMinSpectralValue(minSpectralValue); + functionValues->SetMaxSpectralValue(maxSpectralValue); + functionValues->SetUserStep( val ); + + param->SetWavelenghtSpectralBandWithIndex(j, functionValues); + } - corrToRadia->SetInput( param ); + corrToRadia->SetInput( param ); - // Instantiating object - ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); - filter->SetAtmosphericRadiativeTerms( corrToRadia->GetOutput() ); - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); + // Instantiating object + ReflectanceToSurfaceReflectanceImageFilterType::Pointer filter = ReflectanceToSurfaceReflectanceImageFilterType::New(); + filter->SetAtmosphericRadiativeTerms( corrToRadia->GetOutput() ); + filter->SetInput(reader->GetOutput()); + writer->SetInput(filter->GetOutput()); - writer->Update(); - - } + writer->Update(); - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbSIXSTraitsComputeAtmosphericParameters.cxx b/Testing/Code/Radiometry/otbSIXSTraitsComputeAtmosphericParameters.cxx index 5f9c57149a..39aea374a3 100644 --- a/Testing/Code/Radiometry/otbSIXSTraitsComputeAtmosphericParameters.cxx +++ b/Testing/Code/Radiometry/otbSIXSTraitsComputeAtmosphericParameters.cxx @@ -28,144 +28,144 @@ int otbSIXSTraitsComputeAtmosphericParametersTest(int argc, char * argv[]) { - const char * inname = argv[1]; - const char * outname = argv[2]; - - typedef otb::AtmosphericCorrectionParameters AtmosphericCorrectionParametersType; - // Instantiating object - typedef otb::FilterFunctionValues FilterFunctionValuesType; - FilterFunctionValuesType::Pointer functionValues = FilterFunctionValuesType::New(); - FilterFunctionValuesType::ValuesVectorType vect; + const char * inname = argv[1]; + const char * outname = argv[2]; + + typedef otb::AtmosphericCorrectionParameters AtmosphericCorrectionParametersType; + // Instantiating object + typedef otb::FilterFunctionValues FilterFunctionValuesType; + FilterFunctionValuesType::Pointer functionValues = FilterFunctionValuesType::New(); + FilterFunctionValuesType::ValuesVectorType vect; - double SolarZenithalAngle(0.); - double SolarAzimutalAngle(0.); - double ViewingZenithalAngle(0.); - double ViewingAzimutalAngle(0.); - unsigned int Month(0); - unsigned int Day(0); - double AtmosphericPressure(0.); - double WaterVaporAmount(0.); - double OzoneAmount(0.); - typedef AtmosphericCorrectionParametersType::AerosolModelType AerosolModelType; + double SolarZenithalAngle(0.); + double SolarAzimutalAngle(0.); + double ViewingZenithalAngle(0.); + double ViewingAzimutalAngle(0.); + unsigned int Month(0); + unsigned int Day(0); + double AtmosphericPressure(0.); + double WaterVaporAmount(0.); + double OzoneAmount(0.); + typedef AtmosphericCorrectionParametersType::AerosolModelType AerosolModelType; - AerosolModelType AerosolModel; - double AerosolOptical(0.); - double AtmosphericReflectance(0.); - double AtmosphericSphericalAlbedo(0.); - double TotalGaseousTransmission(0.); - double DownwardTransmittance(0.); - double UpwardTransmittance(0.); - double UpwardDiffuseTransmittance(0.); - double UpwardDirectTransmittance(0.); - double UpwardDiffuseTransmittanceForRayleigh(0.); - double UpwardDiffuseTransmittanceForAerosol(0.); - - std::ifstream fin; - std::ofstream fout; + AerosolModelType AerosolModel; + double AerosolOptical(0.); + double AtmosphericReflectance(0.); + double AtmosphericSphericalAlbedo(0.); + double TotalGaseousTransmission(0.); + double DownwardTransmittance(0.); + double UpwardTransmittance(0.); + double UpwardDiffuseTransmittance(0.); + double UpwardDirectTransmittance(0.); + double UpwardDiffuseTransmittanceForRayleigh(0.); + double UpwardDiffuseTransmittanceForAerosol(0.); + + std::ifstream fin; + std::ofstream fout; - //Read input file parameters - fin.open(inname); - fin >> SolarZenithalAngle;//asol; - fin >> SolarAzimutalAngle;//phi0; - fin >> ViewingZenithalAngle;//avis; - fin >> ViewingAzimutalAngle;//phiv; - fin >> Month;//month; - fin >> Day;//jday; - - fin >> AtmosphericPressure;//pressure; - fin >> WaterVaporAmount;//uw; - fin >> OzoneAmount;//uo3; - unsigned int aer(0); - fin >> aer;//iaer; - AerosolModel = static_cast<AerosolModelType>(aer); - fin >> AerosolOptical;//taer55; + //Read input file parameters + fin.open(inname); + fin >> SolarZenithalAngle;//asol; + fin >> SolarAzimutalAngle;//phi0; + fin >> ViewingZenithalAngle;//avis; + fin >> ViewingAzimutalAngle;//phiv; + fin >> Month;//month; + fin >> Day;//jday; + + fin >> AtmosphericPressure;//pressure; + fin >> WaterVaporAmount;//uw; + fin >> OzoneAmount;//uo3; + unsigned int aer(0); + fin >> aer;//iaer; + AerosolModel = static_cast<AerosolModelType>(aer); + fin >> AerosolOptical;//taer55; - float MinSpectralValue(0.); - float MaxSpectralValue(0.); - float value(0.); + float MinSpectralValue(0.); + float MaxSpectralValue(0.); + float value(0.); - fin >> MinSpectralValue;//wlinf; - fin >> MaxSpectralValue;//wlsup; + fin >> MinSpectralValue;//wlinf; + fin >> MaxSpectralValue;//wlsup; - while (!fin.eof() && fin.good()) - { - fin >> value; - vect.push_back(value); - } - fin.close(); - - functionValues->SetFilterFunctionValues(vect); - functionValues->SetMinSpectralValue(MinSpectralValue); - functionValues->SetMaxSpectralValue(MaxSpectralValue); - functionValues->SetUserStep(.0025); - - otb::SIXSTraits::ComputeAtmosphericParameters( - SolarZenithalAngle, - SolarAzimutalAngle, - ViewingZenithalAngle, - ViewingAzimutalAngle, - Month, - Day, - AtmosphericPressure, - WaterVaporAmount, - OzoneAmount, - AerosolModel, - AerosolOptical, - functionValues, - AtmosphericReflectance, - AtmosphericSphericalAlbedo, - TotalGaseousTransmission, - DownwardTransmittance, - UpwardTransmittance, - UpwardDiffuseTransmittance, - UpwardDirectTransmittance, - UpwardDiffuseTransmittanceForRayleigh, - UpwardDiffuseTransmittanceForAerosol ); - - fout.open(outname); - fout <<" ---------------------------------------------------------"<<std::endl; - fout << "Inputs values:"<<std::setprecision(10)<<std::endl; - fout << " -----> SolarZenithalAngle : "<<SolarZenithalAngle<<std::endl; - fout << " -----> SolarAzimutalAngle : "<<SolarAzimutalAngle<<std::endl; - fout << " -----> ViewingZenithalAngle : "<<ViewingZenithalAngle<<std::endl; - fout << " -----> ViewingAzimutalAngle : "<<ViewingAzimutalAngle<<std::endl; - fout << " -----> Month : "<<Month<<std::endl; - fout << " -----> Day : "<<Day<<std::endl; - fout << " -----> AtmosphericPressure : "<<AtmosphericPressure<<std::endl; - fout << " -----> WaterVaporAmount : "<<WaterVaporAmount<<std::endl; - fout << " -----> OzoneAmount : "<<OzoneAmount<<std::endl; - fout << " -----> AerosolModel : "<<aer<<std::endl; - fout << " -----> AerosolOptical : "<<AerosolOptical<<std::endl; - fout << " -----> MinSpectralValue : "<<MinSpectralValue<<std::endl; - fout << " -----> MaxSpectralValue : "<<MaxSpectralValue<<std::endl; - fout << " -----> UserStep : "<<functionValues->GetUserStep()<<std::endl; - fout <<" ---------------------------------------------------------"<<std::endl; - fout << "Outputs values:"<<std::endl; - fout << " -----> atmospheric reflectance : "<<AtmosphericReflectance<<std::endl; - fout << " -----> atmospheric spherical albedo : "<<AtmosphericSphericalAlbedo<<std::endl; - fout << " -----> total gaseous transmission : "<<TotalGaseousTransmission<<std::endl; - fout << " -----> downward transmittance : "<<DownwardTransmittance<<std::endl; - fout << " -----> upward transmittance : "<<UpwardTransmittance<<std::endl; - fout << " -----> upward diffuse transmittance : "<<UpwardDiffuseTransmittance<<std::endl; - fout << " -----> upward direct transmittance : "<<UpwardDirectTransmittance<<std::endl; - fout << " -----> upward diffuse transmittance for rayleigh : "<<UpwardDiffuseTransmittanceForRayleigh<<std::endl; - fout << " -----> upward diffuse transmittance for aerosols : "<<UpwardDiffuseTransmittanceForAerosol<<std::endl; - fout << " -----> MinSpectralValue update: "<<functionValues->GetMinSpectralValue()<<std::endl; - fout << " -----> MaxSpectralValue update : "<<functionValues->GetMaxSpectralValue()<<std::endl; - fout <<" ---------------------------------------------------------"<<std::endl; - fout<<"Input wavelenght band values ["<<functionValues->GetFilterFunctionValues().size()<<"]:"<<std::endl; - for (unsigned int i=0; i<functionValues->GetFilterFunctionValues().size(); i++) - { - fout<< " "<<functionValues->GetFilterFunctionValues()[i] <<std::endl; - } - fout <<" ---------------------------------------------------------"<<std::endl; - fout<<"Output wavelenght band values 6S ["<<functionValues->GetFilterFunctionValues6S().size()<<"]:"<<std::endl; - for (unsigned int i=0; i<functionValues->GetFilterFunctionValues6S().size(); i++) - { - fout<< " "<<functionValues->GetFilterFunctionValues6S()[i] <<std::endl; - } - fout<<std::endl; - fout.close(); - return EXIT_SUCCESS; + while (!fin.eof() && fin.good()) + { + fin >> value; + vect.push_back(value); + } + fin.close(); + + functionValues->SetFilterFunctionValues(vect); + functionValues->SetMinSpectralValue(MinSpectralValue); + functionValues->SetMaxSpectralValue(MaxSpectralValue); + functionValues->SetUserStep(.0025); + + otb::SIXSTraits::ComputeAtmosphericParameters( + SolarZenithalAngle, + SolarAzimutalAngle, + ViewingZenithalAngle, + ViewingAzimutalAngle, + Month, + Day, + AtmosphericPressure, + WaterVaporAmount, + OzoneAmount, + AerosolModel, + AerosolOptical, + functionValues, + AtmosphericReflectance, + AtmosphericSphericalAlbedo, + TotalGaseousTransmission, + DownwardTransmittance, + UpwardTransmittance, + UpwardDiffuseTransmittance, + UpwardDirectTransmittance, + UpwardDiffuseTransmittanceForRayleigh, + UpwardDiffuseTransmittanceForAerosol ); + + fout.open(outname); + fout <<" ---------------------------------------------------------"<<std::endl; + fout << "Inputs values:"<<std::setprecision(10)<<std::endl; + fout << " -----> SolarZenithalAngle : "<<SolarZenithalAngle<<std::endl; + fout << " -----> SolarAzimutalAngle : "<<SolarAzimutalAngle<<std::endl; + fout << " -----> ViewingZenithalAngle : "<<ViewingZenithalAngle<<std::endl; + fout << " -----> ViewingAzimutalAngle : "<<ViewingAzimutalAngle<<std::endl; + fout << " -----> Month : "<<Month<<std::endl; + fout << " -----> Day : "<<Day<<std::endl; + fout << " -----> AtmosphericPressure : "<<AtmosphericPressure<<std::endl; + fout << " -----> WaterVaporAmount : "<<WaterVaporAmount<<std::endl; + fout << " -----> OzoneAmount : "<<OzoneAmount<<std::endl; + fout << " -----> AerosolModel : "<<aer<<std::endl; + fout << " -----> AerosolOptical : "<<AerosolOptical<<std::endl; + fout << " -----> MinSpectralValue : "<<MinSpectralValue<<std::endl; + fout << " -----> MaxSpectralValue : "<<MaxSpectralValue<<std::endl; + fout << " -----> UserStep : "<<functionValues->GetUserStep()<<std::endl; + fout <<" ---------------------------------------------------------"<<std::endl; + fout << "Outputs values:"<<std::endl; + fout << " -----> atmospheric reflectance : "<<AtmosphericReflectance<<std::endl; + fout << " -----> atmospheric spherical albedo : "<<AtmosphericSphericalAlbedo<<std::endl; + fout << " -----> total gaseous transmission : "<<TotalGaseousTransmission<<std::endl; + fout << " -----> downward transmittance : "<<DownwardTransmittance<<std::endl; + fout << " -----> upward transmittance : "<<UpwardTransmittance<<std::endl; + fout << " -----> upward diffuse transmittance : "<<UpwardDiffuseTransmittance<<std::endl; + fout << " -----> upward direct transmittance : "<<UpwardDirectTransmittance<<std::endl; + fout << " -----> upward diffuse transmittance for rayleigh : "<<UpwardDiffuseTransmittanceForRayleigh<<std::endl; + fout << " -----> upward diffuse transmittance for aerosols : "<<UpwardDiffuseTransmittanceForAerosol<<std::endl; + fout << " -----> MinSpectralValue update: "<<functionValues->GetMinSpectralValue()<<std::endl; + fout << " -----> MaxSpectralValue update : "<<functionValues->GetMaxSpectralValue()<<std::endl; + fout <<" ---------------------------------------------------------"<<std::endl; + fout<<"Input wavelenght band values ["<<functionValues->GetFilterFunctionValues().size()<<"]:"<<std::endl; + for (unsigned int i=0; i<functionValues->GetFilterFunctionValues().size(); i++) + { + fout<< " "<<functionValues->GetFilterFunctionValues()[i] <<std::endl; + } + fout <<" ---------------------------------------------------------"<<std::endl; + fout<<"Output wavelenght band values 6S ["<<functionValues->GetFilterFunctionValues6S().size()<<"]:"<<std::endl; + for (unsigned int i=0; i<functionValues->GetFilterFunctionValues6S().size(); i++) + { + fout<< " "<<functionValues->GetFilterFunctionValues6S()[i] <<std::endl; + } + fout<<std::endl; + fout.close(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbSetASetBMultiChannelRAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbSetASetBMultiChannelRAndNIRVegetationIndexImageFilter.cxx index 1dfe0a1ba8..b0961a8994 100644 --- a/Testing/Code/Radiometry/otbSetASetBMultiChannelRAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbSetASetBMultiChannelRAndNIRVegetationIndexImageFilter.cxx @@ -27,75 +27,55 @@ template<class TInputImage, class TOutputImage, class TFunction> int generic_SetASetBMultiChannelRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputImage> ReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> - MultiChannelRAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); - typename ReaderType::Pointer reader = ReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); - double a(::atof(argv[1])); - double b(::atof(argv[2])); - const char * inputFilename = argv[3]; - const char * outputFilename = argv[4]; - unsigned int redChannel(::atoi(argv[5])); - unsigned int nirChannel(::atoi(argv[6])); - - reader->SetFileName( inputFilename ); - writer->SetFileName( outputFilename ); - filter->SetInput( reader->GetOutput() ); - filter->SetRedIndex(redChannel); - filter->SetNIRIndex(nirChannel); - filter->GetFunctor().SetA(a); - filter->GetFunctor().SetB(b); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } - return EXIT_SUCCESS; - - + typedef otb::ImageFileReader<TInputImage> ReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::MultiChannelRAndNIRVegetationIndexImageFilter<TInputImage,TOutputImage,TFunction> + MultiChannelRAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename MultiChannelRAndNIRVegetationIndexImageFilterType::Pointer filter = MultiChannelRAndNIRVegetationIndexImageFilterType::New(); + typename ReaderType::Pointer reader = ReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + double a(::atof(argv[1])); + double b(::atof(argv[2])); + const char * inputFilename = argv[3]; + const char * outputFilename = argv[4]; + unsigned int redChannel(::atoi(argv[5])); + unsigned int nirChannel(::atoi(argv[6])); + + reader->SetFileName( inputFilename ); + writer->SetFileName( outputFilename ); + filter->SetInput( reader->GetOutput() ); + filter->SetRedIndex(redChannel); + filter->SetNIRIndex(nirChannel); + filter->GetFunctor().SetA(a); + filter->GetFunctor().SetB(b); + writer->SetInput( filter->GetOutput() ); + writer->Update(); } + int otbSetASetBMultiChannelRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef otb::VectorImage<unsigned char,Dimension> InputImageType; - typedef otb::Image<float,Dimension> OutputImageType; + const unsigned int Dimension = 2; + typedef otb::VectorImage<unsigned char,Dimension> InputImageType; + typedef otb::Image<float,Dimension> OutputImageType; - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "PVI" ) return( generic_SetASetBMultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::PVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else if ( strArgv == "TSAVI" ) return( generic_SetASetBMultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, - otb::Functor::TSAVI< InputImageType::InternalPixelType, - InputImageType::InternalPixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "PVI" ) return( generic_SetASetBMultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::PVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else if ( strArgv == "TSAVI" ) return( generic_SetASetBMultiChannelRAndNIRVegetationIndexImageFilter<InputImageType, OutputImageType, + otb::Functor::TSAVI< InputImageType::InternalPixelType, + InputImageType::InternalPixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbSetASetBRAndNIRVegetationIndexImageFilter.cxx b/Testing/Code/Radiometry/otbSetASetBRAndNIRVegetationIndexImageFilter.cxx index 9a514d2735..b31027367a 100644 --- a/Testing/Code/Radiometry/otbSetASetBRAndNIRVegetationIndexImageFilter.cxx +++ b/Testing/Code/Radiometry/otbSetASetBRAndNIRVegetationIndexImageFilter.cxx @@ -26,78 +26,62 @@ template<class TInputRImage, class TInputNIRImage, class TOutputImage, class TFunction> int generic_SetASetBRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - try - { - - typedef otb::ImageFileReader<TInputRImage> RReaderType; - typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; - typedef otb::ImageFileWriter<TOutputImage> WriterType; - - typedef otb::RAndNIRVegetationIndexImageFilter<TInputRImage,TInputNIRImage,TOutputImage,TFunction> - RAndNIRVegetationIndexImageFilterType; - - // Instantiating object - typename RAndNIRVegetationIndexImageFilterType::Pointer filter = RAndNIRVegetationIndexImageFilterType::New(); - typename RReaderType::Pointer readerR = RReaderType::New(); - typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); - typename WriterType::Pointer writer = WriterType::New(); - double a(::atof(argv[1])); - double b(::atof(argv[2])); - const char * inputFilenameR = argv[3]; - const char * inputFilenameNIR = argv[4]; - const char * outputFilename = argv[5]; - - readerR->SetFileName( inputFilenameR ); - readerNIR->SetFileName( inputFilenameNIR ); - writer->SetFileName( outputFilename ); - filter->SetInputR( readerR->GetOutput() ); - filter->SetInputNIR( readerNIR->GetOutput() ); - filter->GetFunctor().SetA(a); - filter->GetFunctor().SetB(b); - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + typedef otb::ImageFileReader<TInputRImage> RReaderType; + typedef otb::ImageFileReader<TInputNIRImage> NIRReaderType; + typedef otb::ImageFileWriter<TOutputImage> WriterType; + + typedef otb::RAndNIRVegetationIndexImageFilter<TInputRImage,TInputNIRImage,TOutputImage,TFunction> + RAndNIRVegetationIndexImageFilterType; + + // Instantiating object + typename RAndNIRVegetationIndexImageFilterType::Pointer filter = RAndNIRVegetationIndexImageFilterType::New(); + typename RReaderType::Pointer readerR = RReaderType::New(); + typename NIRReaderType::Pointer readerNIR = NIRReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + double a(::atof(argv[1])); + double b(::atof(argv[2])); + const char * inputFilenameR = argv[3]; + const char * inputFilenameNIR = argv[4]; + const char * outputFilename = argv[5]; + + readerR->SetFileName( inputFilenameR ); + readerNIR->SetFileName( inputFilenameNIR ); + writer->SetFileName( outputFilename ); + filter->SetInputR( readerR->GetOutput() ); + filter->SetInputNIR( readerNIR->GetOutput() ); + filter->GetFunctor().SetA(a); + filter->GetFunctor().SetB(b); + writer->SetInput( filter->GetOutput() ); + writer->Update(); + + return EXIT_SUCCESS; +} -} int otbSetASetBRAndNIRVegetationIndexImageFilter(int argc, char * argv[]) { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - typedef otb::Image<PixelType,Dimension> InputRImageType; - typedef otb::Image<PixelType,Dimension> InputNIRImageType; - typedef otb::Image<float,Dimension> OutputImageType; + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + typedef otb::Image<PixelType,Dimension> InputRImageType; + typedef otb::Image<PixelType,Dimension> InputNIRImageType; + typedef otb::Image<float,Dimension> OutputImageType; - std::string strArgv(argv[1]); - argc--; - argv++; - if ( strArgv == "PVI" ) return( generic_SetASetBRAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::PVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else if ( strArgv == "TSAVI" ) return( generic_SetASetBRAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, - otb::Functor::TSAVI< InputRImageType::PixelType, - InputNIRImageType::PixelType, - OutputImageType::PixelType> > - (argc,argv) ); - else - return EXIT_FAILURE; - return EXIT_SUCCESS; + std::string strArgv(argv[1]); + argc--; + argv++; + if ( strArgv == "PVI" ) return( generic_SetASetBRAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::PVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else if ( strArgv == "TSAVI" ) return( generic_SetASetBRAndNIRVegetationIndexImageFilter<InputRImageType, InputNIRImageType, OutputImageType, + otb::Functor::TSAVI< InputRImageType::PixelType, + InputNIRImageType::PixelType, + OutputImageType::PixelType> > + (argc,argv) ); + else + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/Testing/Code/Radiometry/otbSurfaceAdjencyEffect6SCorrectionSchemeFilterNew.cxx b/Testing/Code/Radiometry/otbSurfaceAdjencyEffect6SCorrectionSchemeFilterNew.cxx index 4a76bc63d8..70314a25d6 100644 --- a/Testing/Code/Radiometry/otbSurfaceAdjencyEffect6SCorrectionSchemeFilterNew.cxx +++ b/Testing/Code/Radiometry/otbSurfaceAdjencyEffect6SCorrectionSchemeFilterNew.cxx @@ -24,29 +24,13 @@ int otbSurfaceAdjencyEffect6SCorrectionSchemeFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> InputImageType; - typedef otb::SurfaceAdjencyEffect6SCorrectionSchemeFilter<InputImageType,InputImageType> SurfaceAdjencyEffect6SCorrectionSchemeFilterType; - - // Instantiating object - SurfaceAdjencyEffect6SCorrectionSchemeFilterType::Pointer filter = SurfaceAdjencyEffect6SCorrectionSchemeFilterType::New(); - - } - - catch( itk::ExceptionObject & err ) - { - std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; - std::cout << err << std::endl; - return EXIT_FAILURE; - } - - catch( ... ) - { - std::cout << "Unknown exception thrown !" << std::endl; - return EXIT_FAILURE; - } + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> InputImageType; + typedef otb::SurfaceAdjencyEffect6SCorrectionSchemeFilter<InputImageType,InputImageType> SurfaceAdjencyEffect6SCorrectionSchemeFilterType; + + // Instantiating object + SurfaceAdjencyEffect6SCorrectionSchemeFilterType::Pointer filter = SurfaceAdjencyEffect6SCorrectionSchemeFilterType::New(); + return EXIT_SUCCESS; } -- GitLab