diff --git a/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx b/Testing/Code/Radiometry/otbAtmosphericCorrectionParametersNew.cxx index b268043abf13f1ea4d16ce7d17e5e33902917722..49be87b4dcd44c033514963e3ac347cf32051a4f 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 ad2338d2dce353792e80a3fae1d107f62ff6aa16..39139f2464479bc8dbe6f21a33c2594899bc49cb 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 db3d8547f418515f77476c62957ffe857cb09313..53cd613f6b8beaa94ba1d85d064d7e1330967237 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 aad7a1ba780ee01e4d1f1a420109fe81df643e0e..950d4dbd16ae6957f570c8f393e508d38e923173 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 93fec2b205e6e863a47ec2e1bd0c78ee605ec58a..8755f911b949d0b7275f99cdd82ee967743ad651 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 93e49aa77bdaf3e3e366cf70d9fbdce6173a73b4..714cf1881e2dddc2cbb1f77fcc5f717509f261d8 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 cf274bdf2de4dc0cd4fa0db6643694e775076245..bbef9211664dc5373ec3db7021b003c1178b1d95 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 45ec4e80dba9b549d498710d2132ace9f24b99b1..33cb938395379663c134fcbd418e169acdb37ae4 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 b0de89bd15cee565fb3425b36a33d4a5470459a5..32bf0328cc985372a516a099277dd173b252c527 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 63bc7af7ea4c7dd9ce7a2696ce2680471cad4a07..1bca7f37ebaa5f8cef9cdff2469aa3a56d815cd8 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 b9294f1a0e798c6c6aba8b9017095a0ecb67126a..b81d60107bce78656f22a2dee8c746976feac4da 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 9af26d39dda05a73ec6a6e27778bd19f2171d1f4..9046ef839c9222391e92c457b3f87f113c74bc2e 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 3b1a3528b9de0d134298a92c20f39a510f5fdc08..6a09bda67d837f7703e953e8d657cba81f93a644 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 5f129a186d96099b3e459c0712090660ce0b39a0..d329e95744e96654c1a25b53a1e22bd829c8d6db 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 2987d24743d9fae0f5b32d189dc892a89e70f3f3..b114aeb4a2ed36346618e36b16e9b9fd062489f3 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 113c59acfa7f2c8b31d3a2d94f23d40ab7d7505e..daec01d49d35db803b9cf3830d0fa8abbc18bc54 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 483460532549ae9d109797d1cb9ec48fb798be8c..0635c91464a1f2acada4f1596fcdc7e60d58ae8c 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 5b3adf6efe8f292ef2860ad3489ea09c5ae477b7..9eb6574c2b578cbf032fa8ba70f4091c8b9e5de0 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 525d055c953cbd6c84e0e43ef5f38aa9f70f113f..b14babd2937c17f81c34cb78220a5f61baffcfa4 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 c3d614351ea52050b2d366770251a51495b30908..a3b302f5f925458aa89ab5dd3bee06d0451f44ff 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 342af714d0d45291af7a28b7856411d7520a9502..4f1507314baa095e0def53ce63149d9fc73cb9fc 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 9a4a7c62f4fc836a4b4d2315c99d9ecbcc2d7441..86240268937dec1180320d4aebb954babde5cdd5 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 db248efb0fbe423b7fe4ef22fa1dc3a96e903332..dcd985f7e0a299f21be818b9fbe34b2f84520951 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 ac19965501b87c05212ed4792f2566c2e441b25e..a74a8a8f88bc83cf037f5679f848e1e8d23d6ddc 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 70c5143094647f572f945f9df6e1128e1b02cdd4..38973a6ba927c40bba3d850b5c447820af6f9726 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 5f9c57149af70993505a09c6eadfe3922a79050d..39aea374a3541237b41f3fef251082e79aad19a3 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 1dfe0a1ba8fbd05cf766603c2a63f56a1b5538ea..b0961a8994e7293a96f2f0c1c29215c5663c20c0 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 9a514d2735369090022f2340778dd49e53fe461b..b31027367a356d529372f0c7852cb9041afa1c77 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 4a76bc63d8aa3123a9ddad8e84cf0e270b2b9400..70314a25d669750d96522bb79fcb274a23079455 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; }