diff --git a/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx b/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx index e99d56c0c3c35af0e168f181271670796d1e5d2c..ba2c5bf3bcd4d633e5f4cdac6cf180f473ec4360 100644 --- a/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx +++ b/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx @@ -41,7 +41,6 @@ void FilterFunctionValues ::PrintSelf(std::ostream& os, itk::Indent indent) const { - Superclass::PrintSelf(os,indent); os << indent << "Minimum spectral value: " << m_MinSpectralValue << std::endl; os << indent << "Maximum spectral value: " << m_MaxSpectralValue << std::endl; os << indent << "User Step between each wavelenght spectral band values: " << m_UserStep << std::endl; @@ -95,20 +94,7 @@ AtmosphericCorrectionParameters reader->SetHour(hour); reader->SetMinute(minute); reader->SetEpsilon(epsi); - std::cout<<day<<std::endl; - std::cout<<month<<std::endl; - std::cout<<year<<std::endl; - std::cout<<hour<<std::endl; - std::cout<<minute<<std::endl; - std::cout<<epsi<<std::endl; - - std::cout<<reader->GetDay()<<std::endl; - std::cout<<reader->GetMonth()<<std::endl; - std::cout<<reader->GetYear()<<std::endl; - std::cout<<reader->GetHour()<<std::endl; - std::cout<<reader->GetMinute()<<std::endl; - std::cout<<reader->GetEpsilon()<<std::endl; - + reader->Update(); m_AerosolOptical = reader->GetOutput()->GetAerosolOpticalThickness(); @@ -121,21 +107,20 @@ void AtmosphericCorrectionParameters ::PrintSelf(std::ostream& os, itk::Indent indent) const { - Superclass::PrintSelf(os,indent); - os << indent << "Solar zenithal angle: " << m_SolarZenithalAngle << std::endl; - os << indent << "Solar azimutal angle: " << m_SolarAzimutalAngle << std::endl; - os << indent << "Viewing zenithal angle: " << m_ViewingZenithalAngle << std::endl; - os << indent << "Viewing azimutal angle: " << m_ViewingAzimutalAngle << std::endl; - os << indent << "Month: " << m_Month << std::endl; - os << indent << "Day: " << m_Day << std::endl; - os << indent << "Atmospheric pressure: " << m_AtmosphericPressure << std::endl; - os << indent << "Water vapor amount: " << m_WaterVaporAmount << std::endl; - os << indent << "Ozone amount: " << m_OzoneAmount << std::endl; - os << indent << "Aerosol model: " << m_AerosolModel << std::endl; - os << indent << "Aerosol optical : " << m_AerosolOptical << std::endl; + os << "Solar zenithal angle : " << m_SolarZenithalAngle << std::endl; + os << "Solar azimutal angle : " << m_SolarAzimutalAngle << std::endl; + os << "Viewing zenithal angle: " << m_ViewingZenithalAngle << std::endl; + os << "Viewing azimutal angle: " << m_ViewingAzimutalAngle << std::endl; + os << "Month : " << m_Month << std::endl; + os << "Day : " << m_Day << std::endl; + os << "Atmospheric pressure : " << m_AtmosphericPressure << std::endl; + os << "Water vapor amount : " << m_WaterVaporAmount << std::endl; + os << "Ozone amount : " << m_OzoneAmount << std::endl; + os << "Aerosol model : " << m_AerosolModel << std::endl; + os << "Aerosol optical : " << m_AerosolOptical << std::endl; // Function values print : - os << indent << "Filter function Values: " << std::endl; + os << "Filter function Values: " << std::endl; for (unsigned int i=0; i<m_WavelenghtSpectralBand.size(); ++i) { os << indent << "Channel : "<< i+1 <<" : " << std::endl; diff --git a/Code/Radiometry/otbAtmosphericRadiativeTerms.cxx b/Code/Radiometry/otbAtmosphericRadiativeTerms.cxx index 9f615440d749dee14e6052ced9f87b7060e61ebe..5db2bc598bcfa2f1a56b140f28e3d16fff0f3e53 100644 --- a/Code/Radiometry/otbAtmosphericRadiativeTerms.cxx +++ b/Code/Radiometry/otbAtmosphericRadiativeTerms.cxx @@ -503,7 +503,7 @@ AtmosphericRadiativeTerms { for (unsigned int i=0; i<m_Values.size(); ++i) { - os << indent << "Channel "<< i << " : "<< std::endl; + os << "Channel "<< i << " : "<< std::endl; //ValueType::(os,indent); os << indent << "Intrinsic Atmospheric Reflectance : " << m_Values[i]->GetIntrinsicAtmosphericReflectance() << std::endl; os << indent << "Shperical Albedo of the Atmosphere : " << m_Values[i]->GetSphericalAlbedo() << std::endl; diff --git a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.h b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.h index 8111427e48ad6d231c6e872443d1b723a2a73d67..8d444f2189d08356248bfe7b939d49d625681ec1 100644 --- a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.h +++ b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.h @@ -156,7 +156,8 @@ public: typedef AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms Parameters2RadiativeTermsType; typedef Parameters2RadiativeTermsType::Pointer Parameters2RadiativeTermsPointerType; typedef AtmosphericCorrectionParameters::Pointer CorrectionParametersPointerType; - typedef AtmosphericRadiativeTerms::Pointer AtmosphericRadiativeTermsPointerType; + typedef AtmosphericRadiativeTerms::Pointer AtmosphericRadiativeTermsPointerType; + typedef FilterFunctionValues FilterFunctionValuesType; typedef FilterFunctionValuesType::ValuesVectorType CoefVectorType; @@ -174,7 +175,7 @@ public: } /** Get/Set Atmospheric Correction Parameters. */ - itkGetConstObjectMacro(AtmosphericRadiativeTerms, AtmosphericRadiativeTerms); + itkGetObjectMacro(AtmosphericRadiativeTerms, AtmosphericRadiativeTerms); itkGetObjectMacro(CorrectionParameters, AtmosphericCorrectionParameters); /** Get/Set Aeronet file name. */ @@ -196,20 +197,22 @@ public: return m_FilterFunctionCoef; } + /** Fill AtmosphericRadiativeTerms using image metadata*/ + void UpdateAtmosphericRadiativeTerms(); + /** Update Functors parameters */ + void UpdateFunctors(); + protected: /** Constructor */ ReflectanceToSurfaceReflectanceImageFilter(); /** Destructor */ virtual ~ReflectanceToSurfaceReflectanceImageFilter() {}; - /** If empty, fill AtmosphericRadiativeTerms using image metadata*/ - void UpdateAtmosphericRadiativeTerms( const MetaDataDictionaryType dict ); - /** Read the aeronet data and extract aerosol optical and water vapor amount. */ - void UpdateAeronetData( const MetaDataDictionaryType dict ); + //void UpdateAeronetData( const MetaDataDictionaryType dict ); /** Initialize the functor vector */ - void BeforeThreadedGenerateData(); + void GenerateOutputInformation(); private: @@ -222,8 +225,6 @@ private: std::string m_FilterFunctionValuesFileName; /** Contains the filter function values (each element is a vector and represnts the values for each channel) */ FilterFunctionCoefVectorType m_FilterFunctionCoef; - /** BeforeThreadedGenerateData executed once or not */ - bool m_BeforeDone; }; } // end namespace otb diff --git a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx index dfd308f36017fd52aa28e06c9fa58e8fbfa79324..f461ea2c02fe31ec2c3f79515eddaa85d808261d 100644 --- a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx +++ b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx @@ -36,7 +36,6 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> m_AtmosphericRadiativeTerms = AtmosphericRadiativeTerms::New(); m_CorrectionParameters = AtmosphericCorrectionParameters::New(); m_IsSetAtmosphericRadiativeTerms = false; - m_BeforeDone = false; m_AeronetFileName = ""; m_FilterFunctionValuesFileName = ""; m_FilterFunctionCoef.clear(); @@ -46,9 +45,11 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> template <class TInputImage, class TOutputImage> void ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> -::UpdateAtmosphericRadiativeTerms( const MetaDataDictionaryType dict ) +::UpdateAtmosphericRadiativeTerms() { - ImageMetadataInterfaceBase::Pointer imageMetadataInterface = ImageMetadataInterfaceFactory::CreateIMI(dict); + MetaDataDictionaryType dict = this->GetInput()->GetMetaDataDictionary(); + std::cout<<"Tu passes?"<<std::endl; + ImageMetadataInterfaceBase::Pointer imageMetadataInterface = ImageMetadataInterfaceFactory::CreateIMI(dict); if ((m_CorrectionParameters->GetDay() == 0)) { @@ -103,7 +104,7 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> param2Terms->SetInput(m_CorrectionParameters); param2Terms->Update(); - + m_AtmosphericRadiativeTerms = param2Terms->GetOutput(); } @@ -111,20 +112,21 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> template <class TInputImage, class TOutputImage> void ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> -::BeforeThreadedGenerateData() +::GenerateOutputInformation() { - if(m_BeforeDone == true) - return; - - std::cout<<"BeforeThreadedGenerateData "<<this->GetNumberOfThreads()<<std::endl; - if(m_IsSetAtmosphericRadiativeTerms==false) - this->UpdateAtmosphericRadiativeTerms(this->GetInput()->GetMetaDataDictionary()); - - std::cout<<"m_CorrectionParameters: "<<std::endl; - std::cout<<m_CorrectionParameters<<std::endl; - std::cout<<"m_AtmosphericRadiativeTerms: "<<std::endl; - std::cout<<m_AtmosphericRadiativeTerms<<std::endl; + Superclass::GenerateOutputInformation(); + if(m_IsSetAtmosphericRadiativeTerms==false) + this->UpdateAtmosphericRadiativeTerms(); + + this->UpdateFunctors(); +} + +template <class TInputImage, class TOutputImage> +void +ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> +::UpdateFunctors() +{ this->GetFunctorVector().clear(); for (unsigned int i = 0;i<this->GetInput()->GetNumberOfComponentsPerPixel();++i) { @@ -143,8 +145,6 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> this->GetFunctorVector().push_back(functor); } - m_BeforeDone = true; - std::cout<<"BeforeThreadedGenerateData FIN"<<std::endl; } } diff --git a/Testing/Code/Radiometry/CMakeLists.txt b/Testing/Code/Radiometry/CMakeLists.txt index 6f6c3f489d4a920f4fa5f7bc5920cafff7724071..71eba271af342892b6f74bb8c0824206ceb477c4 100644 --- a/Testing/Code/Radiometry/CMakeLists.txt +++ b/Testing/Code/Radiometry/CMakeLists.txt @@ -24,6 +24,7 @@ SET(RADIOMETRY_TESTS5 ${CXX_TEST_PATH}/otbRadiometryTests5) SET(RADIOMETRY_TESTS6 ${CXX_TEST_PATH}/otbRadiometryTests6) SET(RADIOMETRY_TESTS7 ${CXX_TEST_PATH}/otbRadiometryTests7) SET(RADIOMETRY_TESTS8 ${CXX_TEST_PATH}/otbRadiometryTests8) +SET(RADIOMETRY_TESTS9 ${CXX_TEST_PATH}/otbRadiometryTests9) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbRADIOMETRY_TESTS1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1021,7 +1022,20 @@ ADD_TEST(raTvAeronet_ArcachonLevel10_ExtractData ${RADIOMETRY_TESTS8} ${TEMP}/raAeronetExtractData_ArcachonLevel10_16_08_2009_13_00_epsilon_1.txt ) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbRADIOMETRY_TESTS9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +IF(OTB_DATA_USE_LARGEINPUT) +ADD_TEST(raTvReflectanceToSurfaceReflectanceImageFilterQB ${RADIOMETRY_TESTS9} +# --compare-ascii ${EPSILON_10e6} ${BASELINE_FILES}/raAeronetExtractData_ArcachonLevel10_16_08_2009_13_00_epsilon_1.txt +# ${TEMP}/raAeronetExtractData_ArcachonLevel10_16_08_2009_13_00_epsilon_1.txt + otbReflectanceToSurfaceReflectanceImageFilterQB + ${LARGEINPUT}/TOULOUSE/QuickBird/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF + ${INPUTDATA}/AERONET/090101_091231_Seysses.lev15 + test.tif +) +ENDIF(OTB_DATA_USE_LARGEINPUT) @@ -1115,6 +1129,12 @@ otbAeronetExtractData.cxx otbAeronetExtractDataBadData.cxx ) + +SET(Radiometry_SRCS9 +otbRadiometryTests9.cxx +otbReflectanceToSurfaceReflectanceImageFilterQB.cxx +) + INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) OTB_ADD_EXECUTABLE(otbRadiometryTests1 "${Radiometry_SRCS1}" "OTBRadiometry;OTBIO;OTBTesting") @@ -1125,5 +1145,6 @@ OTB_ADD_EXECUTABLE(otbRadiometryTests5 "${Radiometry_SRCS5}" "OTBRadiometry;OTBI OTB_ADD_EXECUTABLE(otbRadiometryTests6 "${Radiometry_SRCS6}" "OTBRadiometry;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbRadiometryTests7 "${Radiometry_SRCS7}" "OTBRadiometry;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbRadiometryTests8 "${Radiometry_SRCS8}" "OTBRadiometry;OTBIO;OTBTesting") +OTB_ADD_EXECUTABLE(otbRadiometryTests9 "${Radiometry_SRCS9}" "OTBRadiometry;OTBIO;OTBTesting") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx index 6dd59fafdbc07cfab67dcb7339f1f5505b043c64..ef02581e124a5530aef7408e9a94e6b3ae92c93e 100644 --- a/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx +++ b/Testing/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.cxx @@ -54,7 +54,6 @@ int otbReflectanceToSurfaceReflectanceImageFilter(int argc, char * argv[]) 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])));