#include <string>
int main(
int argc,
char *argv[])
{
if (argc != 19)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0] << std::endl;
std::cerr <<
" inputImage outputImage atmosphericCorrectionSequencement_alpha_beta.txt atmosphericCorrectionSequencement_solar_illumination.txt atmosphericCorrectionSequencement_wavelength_spectral_bands_spot4_1.txt SolarZenithalAngle day month SolarAzimuthalAngle ViewingZenithalAngle ViewingAzimuthalAngle AtmosphericPresure WaterVaporAmount OzoneAmount AerosolModel AerosolOpticalThickness WindowRadiusForAdjacencyCorrection PixelSpacing"
<< std::endl;
std::cerr << std::endl;
return 1;
}
const unsigned int Dimension = 2;
typedef double PixelType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
try
{
reader->GenerateOutputInformation();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
catch (...)
{
std::cout << "Unknown exception !" << std::endl;
return EXIT_FAILURE;
}
unsigned int nbOfComponent =
reader->GetOutput()->GetNumberOfComponentsPerPixel();
ImageToLuminanceImageFilterType;
ImageToLuminanceImageFilterType::Pointer filterImageToLuminance
= ImageToLuminanceImageFilterType::New();
VectorType alpha(nbOfComponent);
VectorType beta(nbOfComponent);
alpha.Fill(0);
beta.Fill(0);
std::ifstream fin;
fin.open(argv[3]);
double dalpha(0.), dbeta(0.);
for (unsigned int i = 0; i < nbOfComponent; ++i)
{
fin >> dalpha;
fin >> dbeta;
alpha[i] = dalpha;
beta[i] = dbeta;
}
fin.close();
filterImageToLuminance->SetAlpha(alpha);
filterImageToLuminance->SetBeta(beta);
LuminanceToReflectanceImageFilterType;
LuminanceToReflectanceImageFilterType::Pointer filterLuminanceToReflectance
= LuminanceToReflectanceImageFilterType::New();
VectorType solarIllumination(nbOfComponent);
solarIllumination.Fill(0);
fin.open(argv[4]);
double dsolarIllumination(0.);
for (unsigned int i = 0; i < nbOfComponent; ++i)
{
fin >> dsolarIllumination;
solarIllumination[i] = dsolarIllumination;
}
fin.close();
filterLuminanceToReflectance->SetZenithalSolarAngle(
static_cast<double>(atof(argv[6])));
filterLuminanceToReflectance->SetDay(atoi(argv[7]));
filterLuminanceToReflectance->SetMonth(atoi(argv[8]));
filterLuminanceToReflectance->SetSolarIllumination(solarIllumination);
AtmosphericCorrectionParametersTo6SRadiativeTermsType;
AtmosphericCorrectionParametersType;
AtmosphericRadiativeTermsType;
typedef AtmosphericCorrectionParametersType::AerosolModelType
AerosolModelType;
FilterFunctionValuesType;
typedef FilterFunctionValuesType::ValuesVectorType
ValuesVectorType;
AtmosphericCorrectionParametersType::Pointer
dataAtmosphericCorrectionParameters =
AtmosphericCorrectionParametersType::New();
AtmosphericRadiativeTermsType::Pointer dataAtmosphericRadiativeTerms =
AtmosphericRadiativeTermsType::New();
float minSpectralValue(0.);
float maxSpectralValue(0.);
float userStep(0.);
float value(0.);
unsigned int nbBands(0);
unsigned int nbValuesPerBand(0);
std::string sString;
ValuesVectorType vector;
fin.open(argv[5]);
fin >> nbBands;
for (unsigned int i = 0; i < nbBands; ++i)
{
vector.clear();
fin >> sString;
fin >> minSpectralValue;
fin >> maxSpectralValue;
fin >> userStep;
fin >> nbValuesPerBand;
for (unsigned int j = 0; j < nbValuesPerBand; ++j)
{
fin >> value;
vector.push_back(value);
}
FilterFunctionValuesType::Pointer functionValues =
FilterFunctionValuesType::New();
functionValues->SetFilterFunctionValues(vector);
functionValues->SetMinSpectralValue(minSpectralValue);
functionValues->SetMaxSpectralValue(maxSpectralValue);
functionValues->SetUserStep(userStep);
dataAtmosphericCorrectionParameters->SetWavelengthSpectralBandWithIndex(
i,
functionValues);
}
fin.close();
dataAtmosphericCorrectionParameters->SetSolarZenithalAngle(
static_cast<double>(atof(argv[6])));
dataAtmosphericCorrectionParameters->SetSolarAzimutalAngle(
static_cast<double>(atof(argv[9])));
dataAtmosphericCorrectionParameters->SetViewingZenithalAngle(
static_cast<double>(atof(argv[10])));
dataAtmosphericCorrectionParameters->SetViewingAzimutalAngle(
static_cast<double>(atof(argv[11])));
dataAtmosphericCorrectionParameters->SetMonth(atoi(argv[8]));
dataAtmosphericCorrectionParameters->SetDay(atoi(argv[7]));
dataAtmosphericCorrectionParameters->SetAtmosphericPressure(
static_cast<double>(atof(argv[12])));
dataAtmosphericCorrectionParameters->SetWaterVaporAmount(
static_cast<double>(atof(argv[13])));
dataAtmosphericCorrectionParameters->SetOzoneAmount(
static_cast<double>(atof(argv[14])));
AerosolModelType aerosolModel =
static_cast<AerosolModelType>(::atoi(argv[15]));
dataAtmosphericCorrectionParameters->SetAerosolModel(aerosolModel);
dataAtmosphericCorrectionParameters->SetAerosolOptical(
static_cast<double>(atof(argv[16])));
AtmosphericCorrectionParametersTo6SRadiativeTermsType::Pointer
filterAtmosphericCorrectionParametersTo6SRadiativeTerms =
AtmosphericCorrectionParametersTo6SRadiativeTermsType::New();
filterAtmosphericCorrectionParametersTo6SRadiativeTerms->SetInput(
dataAtmosphericCorrectionParameters);
filterAtmosphericCorrectionParametersTo6SRadiativeTerms->Update();
ImageType>
ReflectanceToSurfaceReflectanceImageFilterType;
ReflectanceToSurfaceReflectanceImageFilterType::Pointer
filterReflectanceToSurfaceReflectanceImageFilter
= ReflectanceToSurfaceReflectanceImageFilterType::New();
filterReflectanceToSurfaceReflectanceImageFilter->
SetAtmosphericRadiativeTerms(
filterAtmosphericCorrectionParametersTo6SRadiativeTerms->GetOutput());
ImageType>
SurfaceAdjacencyEffect6SCorrectionSchemeFilterType;
SurfaceAdjacencyEffect6SCorrectionSchemeFilterType::Pointer
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter
= SurfaceAdjacencyEffect6SCorrectionSchemeFilterType::New();
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->
SetAtmosphericRadiativeTerms(
filterAtmosphericCorrectionParametersTo6SRadiativeTerms->GetOutput());
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->SetZenithalViewingAngle(
dataAtmosphericCorrectionParameters->GetViewingZenithalAngle());
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->SetWindowRadius(atoi(argv
[17]));
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->
SetPixelSpacingInKilometers(static_cast<double>(atof(argv[18])));
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[2]);
filterImageToLuminance->SetInput(reader->GetOutput());
filterLuminanceToReflectance->SetInput(filterImageToLuminance->GetOutput());
filterReflectanceToSurfaceReflectanceImageFilter->SetInput(
filterLuminanceToReflectance->GetOutput());
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->SetInput(
filterReflectanceToSurfaceReflectanceImageFilter->GetOutput());
writer->SetInput(
filterSurfaceAdjacencyEffect6SCorrectionSchemeFilter->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
catch (...)
{
std::cout << "Unknown exception !" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}