Commit 8f54185b authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

MRG

parents ab65ec35 809f9c32
......@@ -20,15 +20,13 @@
#include "otbAtmosphericCorrectionParameters.h"
//#include "otbSurfaceReflectanceToReflectanceFilter.h"
namespace otb
{
/** \class AtmosphericEffects
* \brief This class applies atmospheric effects, computed from otbAtmosphericCorrectionParametersTo6SRadiativeTerms to an input spectrum (otbSpectralResponse) using the otbSurfaceReflectanceToReflectanceFilter.
*
* The two templates indicate:
* - the SpectralResponse input (from the JPL ASTER spectral library for example)
* - the SpectralResponse input (from the JPL ASTER spectral library for example see : http://speclib.jpl.nasa.gov/)
* - the SatelliteRSR relatives spectral response of a sensor (RSR).
*
* \sa itk::DataObject
......
......@@ -21,30 +21,30 @@
namespace otb
{
/** \struct DataSpec
* \brief This struct contains the specific absorption coefficients of each constituent and the refractive index of leaf materia
*
* [1] = wavelength (nm)
* [2] = refractive index of leaf material
* [3] = specific absorption coefficient of chlorophyll (a+b) (cm2.microg-1)
* [4] = specific absorption coefficient of carotenoids (cm2.microg-1)
* [5] = specific absorption coefficient of brown pigments (arbitrary units)
* [6] = specific absorption coefficient of water (cm-1)
* [7] = specific absorption coefficient of dry matter (g.cm-1)
* [8] = direct light
* [9] = diffuse light
* [10] = dry soil
* [11] = wet soil
* Feret et al. (2008), PROSPECT-4 and 5: Advances in the Leaf Optical
* Properties Model Separating Photosynthetic Pigments, Remote Sensing of
* Environment
* The specific absorption coefficient corresponding to brown pigment is
* provided by Frederic Baret (EMMAH, INRA Avignon, baret@avignon.inra.fr)
* and used with his autorization.
*/
// ***********************************************************************
// dataSpec_P5.m - (february, 25th 2008)
// ***********************************************************************
// [1] = wavelength (nm)
// [2] = refractive index of leaf material
// [3] = specific absorption coefficient of chlorophyll (a+b) (cm2.microg-1)
// [4] = specific absorption coefficient of carotenoids (cm2.microg-1)
// [5] = specific absorption coefficient of brown pigments (arbitrary units)
// [6] = specific absorption coefficient of water (cm-1)
// [7] = specific absorption coefficient of dry matter (g.cm-1)
// [8] = direct light
// [9] = diffuse light
// [10] = dry soil
// [11] = wet soil
// Feret et al. (2008), PROSPECT-4 and 5: Advances in the Leaf Optical
// Properties Model Separating Photosynthetic Pigments, Remote Sensing of
// Environment
// The specific absorption coefficient corresponding to brown pigment is
// provided by Frederic Baret (EMMAH, INRA Avignon, baret@avignon.inra.fr)
// and used with his autorization.
// ***********************************************************************
struct DataSpec {
struct DataSpec
{
double lambda;
double refLeafMatInd;
double chlAbsCoef;
......
......@@ -33,7 +33,7 @@
#include "otbImageList.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbStreamingResampleImageFilter.h"
//#include "otbStreamingResampleImageFilter.h"
#include "itkResampleImageFilter.h"
#include "otbProlateInterpolateImageFunction.h"
#include "itkLabelMapToLabelImageFilter.h"
......@@ -45,10 +45,10 @@ namespace otb
* \class ImageSimulationMethod
* \brief Image simulation method
*
* ImageSimulationMethod converts a vectorData describing spatial distibution of materials into an image of reflectance.
* ImageSimulationMethod converts a vectorData describing spatial distribution of materials into an image of reflectance.
* Reflectance image is computed by applying the RSR (relatives spectral response) of the satellite to the spectra obtained
* by the spectrum simulator. Then the satellite FTM is applied to compute spatial distribution of spectra.
* FTM is computed using otbThreamingResampleImageFilter and a ProlateInterpolateImageFunction.
* FTM is computed using otbResampleImageFilter and a ProlateInterpolateImageFunction.
* This method is not a true composite filter and the method UpdateData() must be called in a main program using this class.
*
*In order to avoid homogenous regions of a material, for each pixel in the region a noise is added to the reference sprectrum obtained from the spectrum simulator (see LabelMapToSimulatedImageFilter).
......@@ -62,132 +62,140 @@ class ITK_EXPORT ImageSimulationMethod :
{
public:
/**
/**
* Standard "Self" & Superclass typedef.
*/
typedef ImageSimulationMethod Self;
typedef itk::ImageSource <TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef TInputVectorData InputVectorDataType;
typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
typedef TSpatialisation SpatialisationType;
typedef typename SpatialisationType::Pointer SpatialisationPointer;
typedef typename SpatialisationType::OutputLabelMapType LabelMapType;
typedef typename LabelMapType::LabelObjectType::LabelType LabelType;
typedef TSimulationStep1 SimulationStep1Type;
typedef typename SimulationStep1Type::Pointer SimulationStep1Pointer;
typedef TSimulationStep2 SimulationStep2Type;
typedef typename SimulationStep2Type::Pointer SimulationStep2Pointer;
typedef TFTM FTMType;
typedef typename FTMType::Pointer FTMPointer;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::IndexType IndexType;
typedef typename OutputImageType::InternalPixelType InternalPixelType;
typedef otb::Image<LabelType, 2> OutputLabelImageType;
typedef otb::LabelMapToSimulatedImageFilter<LabelMapType,
SimulationStep1Type, SimulationStep2Type, OutputImageType> LabelMapToSimulatedImageFilterType;
typedef typename LabelMapToSimulatedImageFilterType::Pointer LabelMapToSimulatedImageFilterPointer;
typedef otb::MultiToMonoChannelExtractROI<double, double> MultiToMonoChannelFilterType;
typedef typename MultiToMonoChannelFilterType::Pointer MultiToMonoChannelFilterPointer;
typedef MultiToMonoChannelFilterType::OutputImageType SingleImageType;
typedef otb::ImageList<SingleImageType> ImageListType;
typedef typename ImageListType::Pointer ImageListPointer;
typedef otb::ImageListToVectorImageFilter<ImageListType, OutputImageType> ImageListToVectorImageFilterType;
typedef typename ImageListToVectorImageFilterType::Pointer ImageListToVectorImageFilterPointer;
typedef otb::ProlateInterpolateImageFunction<SingleImageType> InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointer;
typedef itk::ResampleImageFilter<SingleImageType, SingleImageType, double> FTMFilterType;
// typedef otb::StreamingResampleImageFilter<SingleImageType, SingleImageType, double> FTMFilterType;
typedef typename FTMFilterType::Pointer FTMFilterPointer;
typedef itk::LabelMapToLabelImageFilter<LabelMapType, OutputLabelImageType> LabelMapToLabelImageFilterType;
typedef typename LabelMapToLabelImageFilterType::Pointer LabelMapToLabelImageFilterPointer;
/** Standard Macro*/
itkTypeMacro(ImageSimulationMethod, ImageSource);
itkNewMacro(Self);
itkSetMacro(NumberOfComponentsPerPixel, unsigned int);
itkGetMacro(NumberOfComponentsPerPixel, unsigned int);
//prolate radius
itkSetMacro(Radius, unsigned int);
itkGetMacro(Radius, unsigned int);
itkSetMacro(SatRSRFilename, std::string);
itkGetMacro(SatRSRFilename, std::string);
itkSetMacro(PathRoot, std::string);
itkGetMacro(PathRoot, std::string);
itkSetMacro(Mean, double);
itkGetMacro(Mean, double);
itkSetMacro(Variance, double);
itkGetMacro(Variance, double);
itkSetObjectMacro(Spatialisation, SpatialisationType);
// itkSetObjectMacro(LabelMapToSimulatedImage, LabelMapToSimulatedImageType);
// itkSetObjectMacro(FTM, FTMType);
/** Set/Get Input */
itkSetObjectMacro(InputVectorData, InputVectorDataType);
itkGetConstObjectMacro(InputVectorData, InputVectorDataType);
// void SetInput(const InputVectorDataType *object);
// InputVectorDataType * GetInput();
/** Get outputs */
virtual OutputLabelImageType * GetOutputLabelImage();
virtual OutputImageType * GetOutputReflectanceImage();
void UpdateData();
typedef ImageSimulationMethod Self;
typedef itk::ImageSource<TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef TInputVectorData InputVectorDataType;
typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
typedef TSpatialisation SpatialisationType;
typedef typename SpatialisationType::Pointer SpatialisationPointer;
typedef typename SpatialisationType::OutputLabelMapType LabelMapType;
typedef typename LabelMapType::LabelObjectType::LabelType LabelType;
typedef TSimulationStep1 SimulationStep1Type;
typedef typename SimulationStep1Type::Pointer SimulationStep1Pointer;
typedef TSimulationStep2 SimulationStep2Type;
typedef typename SimulationStep2Type::Pointer SimulationStep2Pointer;
typedef TFTM FTMType;
typedef typename FTMType::Pointer FTMPointer;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::IndexType IndexType;
typedef typename OutputImageType::InternalPixelType InternalPixelType;
typedef otb::Image<LabelType, 2> OutputLabelImageType;
typedef otb::LabelMapToSimulatedImageFilter<LabelMapType, SimulationStep1Type, SimulationStep2Type, OutputImageType>
LabelMapToSimulatedImageFilterType;
typedef typename LabelMapToSimulatedImageFilterType::Pointer LabelMapToSimulatedImageFilterPointer;
typedef otb::MultiToMonoChannelExtractROI<double, double> MultiToMonoChannelFilterType;
typedef typename MultiToMonoChannelFilterType::Pointer MultiToMonoChannelFilterPointer;
typedef MultiToMonoChannelFilterType::OutputImageType SingleImageType;
typedef otb::ImageList<SingleImageType> ImageListType;
typedef typename ImageListType::Pointer ImageListPointer;
typedef otb::ImageListToVectorImageFilter<ImageListType, OutputImageType> ImageListToVectorImageFilterType;
typedef typename ImageListToVectorImageFilterType::Pointer ImageListToVectorImageFilterPointer;
typedef otb::ProlateInterpolateImageFunction<SingleImageType> InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointer;
typedef itk::ResampleImageFilter<SingleImageType, SingleImageType, double> FTMFilterType;
// typedef otb::StreamingResampleImageFilter<SingleImageType, SingleImageType, double> FTMFilterType;
typedef typename FTMFilterType::Pointer FTMFilterPointer;
typedef itk::LabelMapToLabelImageFilter<LabelMapType, OutputLabelImageType> LabelMapToLabelImageFilterType;
typedef typename LabelMapToLabelImageFilterType::Pointer LabelMapToLabelImageFilterPointer;
/** Standard Macro*/
itkTypeMacro(ImageSimulationMethod, ImageSource)
;itkNewMacro(Self)
;
itkSetMacro(NumberOfComponentsPerPixel, unsigned int)
;itkGetMacro(NumberOfComponentsPerPixel, unsigned int)
;
//prolate radius
itkSetMacro(Radius, unsigned int)
;itkGetMacro(Radius, unsigned int)
;
itkSetMacro(SatRSRFilename, std::string)
;itkGetMacro(SatRSRFilename, std::string)
;
itkSetMacro(PathRoot, std::string)
;itkGetMacro(PathRoot, std::string)
;
itkSetMacro(Mean, double)
;itkGetMacro(Mean, double)
;
itkSetMacro(Variance, double)
;itkGetMacro(Variance, double)
;
itkSetObjectMacro(Spatialisation, SpatialisationType)
;
// itkSetObjectMacro(LabelMapToSimulatedImage, LabelMapToSimulatedImageType);
// itkSetObjectMacro(FTM, FTMType);
/** Set/Get Input */
itkSetObjectMacro(InputVectorData, InputVectorDataType)
;itkGetConstObjectMacro(InputVectorData, InputVectorDataType)
;
// void SetInput(const InputVectorDataType *object);
// InputVectorDataType * GetInput();
/** Get outputs */
virtual OutputLabelImageType * GetOutputLabelImage();
virtual OutputImageType * GetOutputReflectanceImage();
void UpdateData();
protected:
ImageSimulationMethod();
virtual ~ImageSimulationMethod() {}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
ImageSimulationMethod();
virtual ~ImageSimulationMethod()
{
}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
// virtual void GenerateData();
virtual void GenerateOutputInformation();
// virtual void GenerateData();
virtual void GenerateOutputInformation();
private:
ImageSimulationMethod(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
unsigned int m_NumberOfComponentsPerPixel;
unsigned int m_Radius; //radius of prolate interpolate
std::string m_SatRSRFilename;
std::string m_PathRoot;
double m_Mean;
double m_Variance;
InputVectorDataPointer m_InputVectorData;
SpatialisationPointer m_Spatialisation;
LabelMapToSimulatedImageFilterPointer m_LabelMapToSimulatedImageFilter;
// FTMPointer m_FTM;
std::vector<MultiToMonoChannelFilterPointer> m_MultiToMonoChannelFilterList;
ImageListPointer m_ImageList;
ImageListToVectorImageFilterPointer m_ImageListToVectorImageFilter;
std::vector<FTMFilterPointer> m_FTMFilterList;
std::vector<InterpolatorPointer> m_InterpolatorList;
LabelMapToLabelImageFilterPointer m_LabelMapToLabelImageFilter;
ImageSimulationMethod(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
unsigned int m_NumberOfComponentsPerPixel;
unsigned int m_Radius; //radius of prolate interpolate
std::string m_SatRSRFilename;
std::string m_PathRoot;
double m_Mean;
double m_Variance;
InputVectorDataPointer m_InputVectorData;
SpatialisationPointer m_Spatialisation;
LabelMapToSimulatedImageFilterPointer m_LabelMapToSimulatedImageFilter;
// FTMPointer m_FTM;
std::vector<MultiToMonoChannelFilterPointer> m_MultiToMonoChannelFilterList;
ImageListPointer m_ImageList;
ImageListToVectorImageFilterPointer m_ImageListToVectorImageFilter;
std::vector<FTMFilterPointer> m_FTMFilterList;
std::vector<InterpolatorPointer> m_InterpolatorList;
LabelMapToLabelImageFilterPointer m_LabelMapToLabelImageFilter;
};
......
......@@ -27,31 +27,30 @@ template <class TInputVectorData, class TSpatialisation, class TSimulationStep1,
ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
::ImageSimulationMethod()
{
//instanciation
m_Spatialisation = SpatialisationType::New();
m_LabelMapToSimulatedImageFilter = LabelMapToSimulatedImageFilterType::New();
m_LabelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New();
// this->SetNumberOfRequiredOutputs(2);
// this->SetNthOutput(0, OutputImageType::New());
// this->SetNthOutput(1, OutputLabelImageType::New());
//TODO a changer mais pour le moment obligatoire car ProlateInterpolateImageFunction
// ne fonctionne qu'avec des image mono canal.
// m_FTMFilter = FTMFilterType::New();
// m_Interpolator = InterpolatorType::New();
// m_MultiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
m_ImageList = ImageListType::New();
m_ImageListToVectorImageFilter = ImageListToVectorImageFilterType::New();
//default value
m_NumberOfComponentsPerPixel = 3;
m_Radius = 3;
m_SatRSRFilename="";
m_PathRoot="";
m_Mean=0.0;
m_Variance=1e-8;
//instanciation
m_Spatialisation = SpatialisationType::New();
m_LabelMapToSimulatedImageFilter = LabelMapToSimulatedImageFilterType::New();
m_LabelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New();
// this->SetNumberOfRequiredOutputs(2);
// this->SetNthOutput(0, OutputImageType::New());
// this->SetNthOutput(1, OutputLabelImageType::New());
//TODO a changer mais pour le moment obligatoire car ProlateInterpolateImageFunction
// ne fonctionne qu'avec des images mono canal.
// m_FTMFilter = FTMFilterType::New();
// m_Interpolator = InterpolatorType::New();
// m_MultiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
m_ImageList = ImageListType::New();
m_ImageListToVectorImageFilter = ImageListToVectorImageFilterType::New();
//default value
m_NumberOfComponentsPerPixel = 3;
m_Radius = 3;
m_SatRSRFilename = "";
m_PathRoot = "";
m_Mean = 0.0;
m_Variance = 1e-8;
}
//The 3 commented methods are needed for a true composite filters.
......@@ -144,54 +143,52 @@ void
ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
::UpdateData()
{
// m_Spatialisation->SetInput(m_InputVectorData);
// m_Spatialisation->SetInitialLabel(1);
// m_Spatialisation->SetBackgroundValue(0);
m_LabelMapToSimulatedImageFilter->SetInput(m_Spatialisation->GetOutput());
m_LabelMapToSimulatedImageFilter->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
m_LabelMapToSimulatedImageFilter->SetSatRSRFilename(m_SatRSRFilename);
m_LabelMapToSimulatedImageFilter->SetNumberOfThreads(1);
m_LabelMapToSimulatedImageFilter->SetPathRoot(m_PathRoot);
m_LabelMapToSimulatedImageFilter->SetMean(m_Mean);
m_LabelMapToSimulatedImageFilter->SetVariance(m_Variance);
m_LabelMapToLabelImageFilter->SetInput(m_Spatialisation->GetOutput());
for(unsigned int i = 0; i<m_NumberOfComponentsPerPixel; i++)
{
MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
InterpolatorPointer interpolator = InterpolatorType::New();
FTMFilterPointer FTMFilter = FTMFilterType::New();
multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
multiToMonoChannelFilter->SetChannel(i+1);
multiToMonoChannelFilter->SetExtractionRegion(m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
//TODO comment changer interpolateur !
interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
interpolator->SetRadius(m_Radius);
interpolator->Initialize();
multiToMonoChannelFilter->UpdateOutputInformation();
FTMFilter->SetInterpolator(interpolator);
// FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
FTMFilter->Update();
m_ImageList->PushBack(FTMFilter->GetOutput());
}
m_ImageListToVectorImageFilter->SetInput(m_ImageList);
// m_Spatialisation->SetInput(m_InputVectorData);
// m_Spatialisation->SetInitialLabel(1);
// m_Spatialisation->SetBackgroundValue(0);
m_LabelMapToSimulatedImageFilter->SetInput(m_Spatialisation->GetOutput());
m_LabelMapToSimulatedImageFilter->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
m_LabelMapToSimulatedImageFilter->SetSatRSRFilename(m_SatRSRFilename);
m_LabelMapToSimulatedImageFilter->SetNumberOfThreads(1);
m_LabelMapToSimulatedImageFilter->SetPathRoot(m_PathRoot);
m_LabelMapToSimulatedImageFilter->SetMean(m_Mean);
m_LabelMapToSimulatedImageFilter->SetVariance(m_Variance);
m_LabelMapToLabelImageFilter->SetInput(m_Spatialisation->GetOutput());
for (unsigned int i = 0; i < m_NumberOfComponentsPerPixel; i++)
{
MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
InterpolatorPointer interpolator = InterpolatorType::New();
FTMFilterPointer FTMFilter = FTMFilterType::New();
multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
multiToMonoChannelFilter->SetChannel(i + 1);
multiToMonoChannelFilter->SetExtractionRegion(
m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
//TODO comment changer interpolateur !
interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
interpolator->SetRadius(m_Radius);
interpolator->Initialize();
multiToMonoChannelFilter->UpdateOutputInformation();
FTMFilter->SetInterpolator(interpolator);
// FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
FTMFilter->Update();
m_ImageList->PushBack(FTMFilter->GetOutput());
}
m_ImageListToVectorImageFilter->SetInput(m_ImageList);
}
//In case of a true composite filter
......
......@@ -33,10 +33,10 @@ namespace otb
/**
* \class LabelMapToSimulatedImageFilter
* \brief Transform a labelMap into an image
* \brief Transform a labelMap into an image.
*
* LabelMapToSimulatedImageFilter convert a label map into a reflectance image.
* Reflectance of the image are computed by applying the RSR (relative spectral response) of the satellite to the spectrum obtained
* Reflectance of the image is computed by applying the RSR (relative spectral response) of the satellite to the spectrum obtained
* by the spectrum simulator (or read in the database). A gaussian noise is added to the reflectance value of
* each pixel of the object. However the method used to add this noise (itk::Statistics::MersenneTwisterRandomVariateGenerator)
* is not thread safe, and then (even if all the remaining is multithread) the number of thread must be set to 1.
......
......@@ -69,73 +69,72 @@ void
LabelMapToSimulatedImageFilter<TInputLabelMap, TSimuStep1, TSimuStep2, TOutputImage>
::ThreadedProcessLabelObject( LabelObjectType * labelObject )
{
ReduceSpectralResponsePointer reduceSpectralResponse = ReduceSpectralResponseType::New();
SatelliteRSRPointer satRSR = SatelliteRSRType::New();
//Compute the spectral response associated to this object.
SpectralResponsePointer readSpectrum = SpectralResponseType::New();
bool hasPath=false;
//Check if the spectrum associated to this object is given by a database.
for(unsigned int i=0; i<labelObject->GetNumberOfAttributes(); i++)
{
if(labelObject->GetAvailableAttributes()[i].compare("path")==0) hasPath=true;
}
if(hasPath==true)
{
// std::cout<<"had path : "<< m_PathRoot + labelObject->GetAttribute("path") << std::endl;
readSpectrum->Load( m_PathRoot + labelObject->GetAttribute("path"), 100 );
reduceSpectralResponse->SetInputSpectralResponse(readSpectrum);
}
else //compute the spectrum using ProSail
{
LabelToParametersPointer labelToParams = LabelToParametersType::New();
SimulationStep1Pointer simuStep1 = SimulationStep1Type::New();
SimulationStep2Pointer simuStep2 = SimulationStep2Type::New();
//Compute params needed to the spectrum simulator
labelToParams->SetLabel(labelObject->GetAttribute("area"));
labelToParams->GenerateData();
simuStep1->SetInput(labelToParams->GetStep1Parameters());
simuStep2->SetParameters(labelToParams->GetStep2Parameters());
simuStep2->SetReflectance(simuStep1->GetReflectance());
simuStep2->SetTransmittance(simuStep1->GetTransmittance());
simuStep2->Update();
reduceSpectralResponse->SetInputSpectralResponse(simuStep2->GetViewingReflectance());
}
//compute the satellite response of this spectrum
satRSR->Clear();
satRSR->SetNbBands(m_NumberOfComponentsPerPixel);
satRSR->Load(m_SatRSRFilename);
reduceSpectralResponse->SetInputSatRSR(satRSR);
reduceSpectralResponse->CalculateResponse();
typename InputLabelMapType::LabelObjectType::LineContainerType::const_iterator lit;
typename InputLabelMapType::LabelObjectType::LineContainerType & lineContainer = labelObject->GetLineContainer();
typename OutputImageType::PixelType pixel;
pixel.SetSize(m_NumberOfComponentsPerPixel);
//TODO Change with a multithreaded method
RandomGeneratorPointer randomGen = RandomGeneratorType::New();
for( lit = lineContainer.begin(); lit != lineContainer.end(); lit++ )
{
IndexType idx = lit->GetIndex();
unsigned long length = lit->GetLength();
for( unsigned int i=0; i<length; i++)
ReduceSpectralResponsePointer reduceSpectralResponse = ReduceSpectralResponseType::New();
SatelliteRSRPointer satRSR = SatelliteRSRType::New();
//Compute the spectral response associated to this object.
SpectralResponsePointer readSpectrum = SpectralResponseType::New();
bool hasPath = false;
//Check if the spectrum associated to this object is given by a database.
for (unsigned int i = 0; i < labelObject->GetNumberOfAttributes(); i++)
{
if (labelObject->GetAvailableAttributes()[i].compare("path") == 0) hasPath = true;
}
if (hasPath == true)
{
readSpectrum->Load(m_PathRoot + labelObject->GetAttribute("path"), 100);
reduceSpectralResponse->SetInputSpectralResponse(readSpectrum);
}
else //compute the spectrum using ProSail
{
LabelToParametersPointer labelToParams = LabelToParametersType::New();
SimulationStep1Pointer simuStep1 = SimulationStep1Type::New();
SimulationStep2Pointer simuStep2 = SimulationStep2Type::New();
//Compute params needed to the spectrum simulator
labelToParams->SetLabel(labelObject->GetAttribute("area"));
labelToParams->GenerateData();
simuStep1->SetInput(labelToParams->GetStep1Parameters());