Skip to content
Snippets Groups Projects
Commit e38b7278 authored by Mickael Savinaud's avatar Mickael Savinaud
Browse files

ENH: add a new class to deal with Image Correction Parameters

parent 3c68b9d7
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbImageMetadataCorrectionParameters.h"
#include "otbSpectralSensitivityReader.h"
namespace otb
{
/*********************** ImageMetadataCorrectionParameters **************************/
/**
* Constructor
*/
ImageMetadataCorrectionParameters
::ImageMetadataCorrectionParameters()
{
m_SolarZenithalAngle = 361.;
m_SolarAzimutalAngle = 361.;
m_ViewingZenithalAngle = 361.;
m_ViewingAzimutalAngle = 361.;
m_Month = 0;
m_Day = 0;
m_Year = 0;
m_WavelengthSpectralBand = InternalWavelengthSpectralBandVectorType::New();
m_WavelengthSpectralBand->Clear();
}
/** Get data from filter function file*/
void
ImageMetadataCorrectionParameters
::LoadFilterFunctionValue(const std::string& filename)
{
m_WavelengthSpectralBand->Clear();
SpectralSensitivityReader::Pointer spectralSensitivityReader = SpectralSensitivityReader::New();
spectralSensitivityReader->SetFileName(filename);
spectralSensitivityReader->Update();
m_WavelengthSpectralBand = spectralSensitivityReader->GetOutput();
}
/**PrintSelf method */
void
ImageMetadataCorrectionParameters
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
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 << "Year : " << m_Year << std::endl;
// Function values print :
os << "Filter function values: " << std::endl;
for (unsigned int i = 0; i < m_WavelengthSpectralBand->Size(); ++i)
{
os << indent << "Channel " << i + 1 << " : " << std::endl;
os << indent << m_WavelengthSpectralBand->GetNthElement(i) << std::endl;
}
}
} // end namespace otb
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbAtmosphericCorrectionParameters_h
#define __otbAtmosphericCorrectionParameters_h
#include "itkObject.h"
#include "itkMacro.h"
#include "itkVariableSizeMatrix.h"
#include "itkVariableLengthVector.h"
#include "otbObjectList.h"
#include "otbFilterFunctionValues.h"
#include <vector>
#include <iostream>
namespace otb
{
/** \class ImageMetadataCorrectionParameters
* \brief This class contains all atmospheric correction parameters.
*
* Each value can be read in the metadata of an image (ex: SPOT5, ...) or directly set by the user.
*
* \ingroup Radiometry
*
*/
class ITK_EXPORT ImageMetadataCorrectionParameters : public itk::Object
{
public:
/** Standard typedefs */
typedef ImageMetadataCorrectionParameters Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkTypeMacro(ImageMetadataCorrectionParameters, Object);
/** Creation through object factory macro */
itkNewMacro(Self);
typedef ObjectList<FilterFunctionValues> InternalWavelengthSpectralBandVectorType;
typedef InternalWavelengthSpectralBandVectorType::Pointer WavelengthSpectralBandVectorType;
/**
* Set/Get the solar zenithal angle.
*/
itkSetMacro(SolarZenithalAngle, double);
itkGetMacro(SolarZenithalAngle, double);
/**
* Set/Get the solar azimutal angle.
*/
itkSetMacro(SolarAzimutalAngle, double);
itkGetMacro(SolarAzimutalAngle, double);
/**
* Set/Get the viewing zenithal angle.
*/
itkSetMacro(ViewingZenithalAngle, double);
itkGetMacro(ViewingZenithalAngle, double);
/**
* Set/Get the viewing azimutal angle.
*/
itkSetMacro(ViewingAzimutalAngle, double);
itkGetMacro(ViewingAzimutalAngle, double);
/**
* Set/Get the month.
*/
itkSetClampMacro(Month, unsigned int, 1, 12);
itkGetMacro(Month, unsigned int);
/**
* Set/Get the day.
*/
itkSetClampMacro(Day, unsigned int, 1, 31);
itkGetMacro(Day, unsigned int);
/**
* Set/Get the year.
*/
itkSetMacro(Year, unsigned int);
itkGetMacro(Year, unsigned int);
/**
* Set/Get the wavelength spectral band.
*/
void SetWavelengthSpectralBand(const WavelengthSpectralBandVectorType& waveband)
{
m_WavelengthSpectralBand = waveband;
}
void SetWavelengthSpectralBandWithIndex(unsigned int id, const FilterFunctionValues::Pointer& function)
{
if (m_WavelengthSpectralBand->Size() < id + 1)
{
for (unsigned int j = 0; j < (id + 1 - m_WavelengthSpectralBand->Size()); ++j)
{
FilterFunctionValues::Pointer temp;
m_WavelengthSpectralBand->PushBack(temp);
}
}
m_WavelengthSpectralBand->SetNthElement(id, function);
}
WavelengthSpectralBandVectorType GetWavelengthSpectralBand() const
{
return m_WavelengthSpectralBand;
}
const WavelengthSpectralBandVectorType * GetWavelengthSpectralBandRef() const
{
return &m_WavelengthSpectralBand;
}
/**
* Read a file that contains filter function values on the 6S format.
*/
void LoadFilterFunctionValue(const std::string& filename);
/** Constructor */
ImageMetadataCorrectionParameters();
/** Destructor */
~ImageMetadataCorrectionParameters() {}
protected:
/**PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
ImageMetadataCorrectionParameters(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
/** The Solar zenithal angle */
double m_SolarZenithalAngle;
/** The Solar azimutal angle */
double m_SolarAzimutalAngle;
/** The Viewing zenithal angle */
double m_ViewingZenithalAngle;
/** The Viewing azimutal angle */
double m_ViewingAzimutalAngle;
/** The Month */
unsigned int m_Month;
/** The Day (in the month) */
unsigned int m_Day;
/** The Year */
unsigned int m_Year;
/** Wavelength for the each spectral band definition */
WavelengthSpectralBandVectorType m_WavelengthSpectralBand;
};
} // end namespace otb
#endif
...@@ -780,6 +780,11 @@ add_test(raTuAtmosphericCorrectionParametersNew ${RADIOMETRY_TESTS3} ...@@ -780,6 +780,11 @@ add_test(raTuAtmosphericCorrectionParametersNew ${RADIOMETRY_TESTS3}
otbAtmosphericCorrectionParametersNew otbAtmosphericCorrectionParametersNew
) )
# ------- otb::ImageMetadataCorrectionParameters ------------------------------
add_test(raTuImageMetadataCorrectionParametersNew ${RADIOMETRY_TESTS3}
otbImageMetadataCorrectionParametersNew
)
########## otb::FilterFunctionValues ------------------- ########## otb::FilterFunctionValues -------------------
# in otbAtmosphericCorrectionParameters.h/.cxx # in otbAtmosphericCorrectionParameters.h/.cxx
add_test(raTuFilterFunctionValuesTest ${RADIOMETRY_TESTS3} add_test(raTuFilterFunctionValuesTest ${RADIOMETRY_TESTS3}
...@@ -2119,6 +2124,7 @@ otbRadiometryTests3.cxx ...@@ -2119,6 +2124,7 @@ otbRadiometryTests3.cxx
otbDEMCaracteristicsExtractorNew.cxx otbDEMCaracteristicsExtractorNew.cxx
otbDEMCaracteristicsExtractor.cxx otbDEMCaracteristicsExtractor.cxx
otbAtmosphericCorrectionParametersNew.cxx otbAtmosphericCorrectionParametersNew.cxx
otbImageMetadataCorrectionParametersNew.cxx
otbFilterFunctionValues.cxx otbFilterFunctionValues.cxx
otbSIXSTraitsTest.cxx otbSIXSTraitsTest.cxx
otbSIXSTraitsComputeAtmosphericParameters.cxx otbSIXSTraitsComputeAtmosphericParameters.cxx
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbImageMetadataCorrectionParameters.h"
int otbImageMetadataCorrectionParametersNew(int argc, char * argv[])
{
typedef otb::ImageMetadataCorrectionParameters CorrectionParametersType;
// Instantiating object
CorrectionParametersType::Pointer objectAtmo = CorrectionParametersType::New();
std::cout << objectAtmo << std::endl;
return EXIT_SUCCESS;
}
...@@ -27,6 +27,7 @@ void RegisterTests() ...@@ -27,6 +27,7 @@ void RegisterTests()
REGISTER_TEST(otbDEMCaracteristicsExtractorNew); REGISTER_TEST(otbDEMCaracteristicsExtractorNew);
REGISTER_TEST(otbDEMCaracteristicsExtractor); REGISTER_TEST(otbDEMCaracteristicsExtractor);
REGISTER_TEST(otbAtmosphericCorrectionParametersNew); REGISTER_TEST(otbAtmosphericCorrectionParametersNew);
REGISTER_TEST(otbImageMetadataCorrectionParametersNew);
REGISTER_TEST(otbFilterFunctionValuesTest); REGISTER_TEST(otbFilterFunctionValuesTest);
REGISTER_TEST(otbFilterFunctionValuesSpectralResponseTest); REGISTER_TEST(otbFilterFunctionValuesSpectralResponseTest);
REGISTER_TEST(otbFilterFunctionValuesDigitalGlobeTest); REGISTER_TEST(otbFilterFunctionValuesDigitalGlobeTest);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment