Commit 7bc5c7ad authored by Manuel Grizonnet's avatar Manuel Grizonnet

TEST: restore and rename tests which where wrongly named 'New' tests

parent fe6f6b1d
......@@ -33,6 +33,7 @@ otbAngularProjectionSetImageFilter.cxx
otbNAPCAImageFilter.cxx
otbAngularProjectionImageFilter.cxx
otbAngularProjectionBinaryImageFilter.cxx
otbSparseWvltToAngleMapperListFilter.cxx
otbLocalActivityVectorImageFilter.cxx
)
......
......@@ -34,4 +34,5 @@ void RegisterTests()
REGISTER_TEST(otbAngularProjectionImageFilterTest);
REGISTER_TEST(otbLocalActivityVectorImageFilterTest);
REGISTER_TEST(otbAngularProjectionBinaryImageFilterTest);
REGISTER_TEST(otbSparseWvltToAngleMapperListFilterTest);
}
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbImage.h"
#include "otbWaveletOperator.h"
#include "otbWaveletFilterBank.h"
#include "otbWaveletTransform.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbCommandLineArgumentParser.h"
#include "itkListSample.h"
#include "otbSparseWvltToAngleMapperListFilter.h"
int otbSparseWvltToAngleMapperListFilterTest ( int argc, char * argv[] )
{
// number of images to consider
const unsigned int Dimension = 2;
const unsigned int nbInputImages = 2;
typedef otb::CommandLineArgumentParser ParserType;
ParserType::Pointer parser = ParserType::New();
parser->AddOption( "--InputImages", "Input Images", "-in", nbInputImages, true );
//parser->AddOption( "--OutputImages", "Generic name for output Images (_#.hdr will be added)", "-out", 1, true );
parser->AddOption( "--Threshold", "Lower threshold for accounting the waBinaryFunctorImageListToSampleListFiltervelet coeffs (def. 10)", "-th", 1, false );
typedef otb::CommandLineArgumentParseResult ParserResultType;
ParserResultType::Pointer parseResult = ParserResultType::New();
try
{
parser->ParseCommandLine( argc, argv, parseResult );
}
catch( itk::ExceptionObject & err )
{
std::cerr << argv[0] << " performs otbSparseWvltToAngleMapperListFilterNewTest on " << nbInputImages << " images\n";
std::string descriptionException = err.GetDescription();
if ( descriptionException.find("ParseCommandLine(): Help Parser")
!= std::string::npos )
return EXIT_SUCCESS;
if(descriptionException.find("ParseCommandLine(): Version Parser")
!= std::string::npos )
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
std::string inputImageName [ nbInputImages ];
for ( unsigned int i = 0; i < nbInputImages; i++ )
inputImageName[i] = parseResult->GetParameterString("--InputImages", i);
//const char * outputImageName = parseResult->GetParameterString("--OutputImages").c_str();
// Parameter (to be changed if necessary)
const double threshold = parseResult->IsOptionPresent("--Threshold") ?
parseResult->GetParameterDouble("--Threshold") : 10.;
// Main type definition
typedef float PixelType;
typedef double PrecisionType;
typedef itk::FixedArray< PrecisionType, nbInputImages-1 > AngleType;
typedef itk::Statistics::ListSample< AngleType > AngleListType;
typedef otb::Image< PixelType, Dimension > ImageType;
typedef otb::ImageList< ImageType > ImageListType;
// Reading input images
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ObjectList< ReaderType > ReaderListType;
ReaderListType::Pointer reader = ReaderListType::New();
reader->Resize( nbInputImages );
typedef otb::ObjectList< ImageListType > ListOfImageListType;
ListOfImageListType::Pointer listOfInputImages = ListOfImageListType::New();
listOfInputImages->Resize( nbInputImages );
for ( unsigned int i = 0; i < nbInputImages; i++ )
{
reader->SetNthElement(i, ReaderType::New());
reader->GetNthElement(i)->SetFileName( inputImageName[i].c_str() );
reader->GetNthElement(i)->Update();
// Here, we will have 'nbInputImages' image lists of one image each only
listOfInputImages->SetNthElement(i, ImageListType::New() );
listOfInputImages->GetNthElement(i)->PushBack( reader->GetNthElement(i)->GetOutput() );
}
// Filter
typedef otb::SparseWvltToAngleMapperListFilter<
ImageListType, AngleListType, nbInputImages > AngleListFilterType;
AngleListFilterType::Pointer filter = AngleListFilterType::New();
for ( unsigned int i = 0; i < nbInputImages; i++ )
{
filter->SetInput( i, listOfInputImages->GetNthElement(i) );
}
filter->SetThresholdValue( threshold );
filter->Update();
std::cerr << "Number of sample found over " << threshold << " : " << filter->GetOutputSampleList()->Size() << "\n";
return EXIT_SUCCESS;
}
......@@ -34,6 +34,7 @@ otbReduceSpectralResponseSVMClassifier.cxx
otbProspectTransTest.cxx
otbReduceSpectralResponseClassifierRAndNIR.cxx
otbSatelliteRSR.cxx
otbSurfaceReflectanceToReflectanceFilter.cxx
otbImageSimulationMethodWithSpatialisationTest.cxx
otbImageSimulationMethodSVMClassif.cxx
otbReduceSpectralResponse.cxx
......
......@@ -28,6 +28,7 @@ void RegisterTests()
REGISTER_TEST(otbSatelliteRSR);
REGISTER_TEST(otbSatelliteRSRCheckValue);
REGISTER_TEST(otbSatelliteRSRSolarIrradianceCheckValue);
REGISTER_TEST(otbSurfaceReflectanceToReflectanceFilterTest);
REGISTER_TEST(otbImageSimulationMethodWithSpatialisationTest);
REGISTER_TEST(otbImageSimulationMethodSVMClassif);
REGISTER_TEST(otbReduceSpectralResponse);
......
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbMacro.h"
#include "otbSpectralResponse.h"
#include "otbSurfaceReflectanceToReflectanceFilter.h"
int otbSurfaceReflectanceToReflectanceFilterTest(int argc, char * argv[])
{
if ( argc != 7 )
{
std::cout << argv[0] << std::endl << "\t" << "<RSR_filename>" << "\t" << "<intrinsic>" << "\t" << "<albedeo>" << "\t" << "<gaseous>" << "\t" << "<downTrans>" << "\t" << "<upTrans>" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::VectorImage<PixelType, Dimension> ImageType;
// typedef itk::ImageRegionIterator< ImageType > IteratorType;
//typedef ResponseType::PairType PairType;
//typedef otb::ObjectList< PairType > PairListType;
// PairListType::Pointer pairList = PairListType::New();
typedef otb::SurfaceReflectanceToReflectanceFilter< ImageType, ImageType> SurfaceReflectanceToReflectanceFilterType;
typedef SurfaceReflectanceToReflectanceFilterType::Pointer SurfaceReflectanceToReflectanceFilterPointerType;
typedef otb::SpectralResponse< PixelType, PixelType> ResponseType;
typedef ResponseType::Pointer ResponsePointerType;
//
ResponsePointerType myResponse=ResponseType::New();
//Load file into vector
const std::string file(argv[1]);
myResponse->Load(file, 100.0);
std::cout << "Input SpectResponse " << myResponse << std::endl;
//rsr to image
ImageType::IndexType start;
start[0] = 0;
start[1] = 0;
ImageType::SizeType size;
size[0] = 1;
size[1] = 1;
std::cout << "Image size: " << size << std::endl;
ImageType::PointType origin;
origin[0] = 0;
origin[1] = 0;
//origin[1] = -90;
ImageType::SpacingType spacing;
spacing[0] = 1;
spacing[1] = 1;
//spacing[1] = -resolution;
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( start );
ImageType::Pointer image = ImageType::New();
image->SetRegions( region );
image->SetNumberOfComponentsPerPixel( (myResponse)->Size() );
image->Allocate();
ImageType::PixelType pixel;
pixel.SetSize((myResponse)->Size());
for ( unsigned int i = 0; i<(myResponse)->Size(); ++i )
{
pixel[i] = myResponse->GetResponse()[i].second;
}
image->SetPixel(start, pixel);
//Instantiation
SurfaceReflectanceToReflectanceFilterPointerType myFilter=SurfaceReflectanceToReflectanceFilterType::New();
// myFilter->SetInput(image);
//
// typedef otb::AtmosphericRadiativeTerms::DataVectorType DataVectorType;
// otb::AtmosphericRadiativeTerms::Pointer atmo = otb::AtmosphericRadiativeTerms::New();
//
// DataVectorType intrinsic;
// DataVectorType albedo;
// DataVectorType gaseous;
// DataVectorType downTrans;
// DataVectorType upTrans;
//
//
// intrinsic.push_back(static_cast<double>(atof(argv[2])));
// albedo.push_back(static_cast<double>(atof(argv[3])));
// gaseous.push_back(static_cast<double>(atof(argv[4])));
// downTrans.push_back(static_cast<double>(atof(argv[5])));
// upTrans.push_back(static_cast<double>(atof(argv[6])));
//
//
// atmo->SetIntrinsicAtmosphericReflectances(intrinsic);
// atmo->SetSphericalAlbedos(albedo);
// atmo->SetTotalGaseousTransmissions(gaseous);
// atmo->SetDownwardTransmittances(downTrans);
// atmo->SetUpwardTransmittances(upTrans);
//
// myFilter->SetAtmosphericRadiativeTerms(atmo);
// myFilter->Update();
//
// i = 0;
// IteratorType iterator2( myFilter->GetOutput(), myFilter->GetOutput()->GetRequestedRegion() );
// for ( iterator2.GoToBegin(); !iterator2.IsAtEnd(); ++iterator2 )
// {
// myResponse->GetResponse()[i]->second = iterator2.Get()[];
// ++i;
// }
//
// std::cout << "Output SpectResponse " << myResponse << std::endl;
return EXIT_SUCCESS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment