Commit ad64f78e authored by Mickael Savinaud's avatar Mickael Savinaud

TEST: add test about new class to select one output from an image list

parent 407d266d
......@@ -357,6 +357,20 @@ ADD_TEST(bfTvVectorImageToImageListFilterIt2 ${BASICFILTERS_TESTS3}
png
)
ADD_TEST(bfTuImageListToSingleImageFilterNew ${BASICFILTERS_TESTS3}
otbImageListToSingleImageFilterNew)
ADD_TEST(bfTvImageListToSingleImageFilter ${BASICFILTERS_TESTS3}
otbImageListToSingleImageFilter
${INPUTDATA}/poupees.png
${TEMP}/bfTvImageListToSingleImageFilter.tif
)
ADD_TEST(bfTvImageListToSingleImageFilterBig ${BASICFILTERS_TESTS3}
otbImageListToSingleImageFilter
${LARGEINPUT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF
${TEMP}/bfTvImageListToSingleImageFilter.tif
)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbBasicFiltersTests4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -2849,6 +2863,7 @@ otbVectorRescaleIntensityImageFilterNew.cxx
otbVectorRescaleIntensityImageFilter.cxx
otbVectorImageToImageListFilterNew.cxx
otbVectorImageToImageListFilter.cxx
otbImageListToSingleImageFilterTest.cxx
otbShiftScaleVectorImageFilterNew.cxx
otbShiftScaleVectorImageFilterTest.cxx
)
......
......@@ -35,6 +35,8 @@ void RegisterTests()
REGISTER_TEST(otbVectorImageToImageListFilter);
REGISTER_TEST(otbVectorImageToImageListFilterIterator);
REGISTER_TEST(otbVectorImageToImageListFilterIterator2);
REGISTER_TEST(otbImageListToSingleImageFilterNew);
REGISTER_TEST(otbImageListToSingleImageFilter);
REGISTER_TEST(otbShiftScaleVectorImageFilterNew);
REGISTER_TEST(otbShiftScaleVectorImageFilterTest);
}
/*=========================================================================
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 "itkMacro.h"
#include "otbVectorImageToImageListFilter.h"
#include "otbImageListToSingleImageFilter.h"
#include "otbVectorImage.h"
#include "otbImageList.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbBandMathImageFilter.h"
int otbImageListToSingleImageFilterNew(int argc, char * argv[])
{
const unsigned int Dimension = 2;
typedef unsigned char PixelType;
typedef otb::Image<PixelType, Dimension> ImageType;
typedef otb::ImageList<ImageType> ImageListType;
typedef otb::ImageListToSingleImageFilter<ImageListType::ImageType> ImageListToSingleImageFilter;
// Instantiating object
ImageListToSingleImageFilter::Pointer filter = ImageListToSingleImageFilter::New();
std::cout << filter << std::endl;
return EXIT_SUCCESS;
}
int otbImageListToSingleImageFilter(int argc, char * argv[])
{
const unsigned int Dimension = 2;
char * infname = argv[1];
char * outfname1 = argv[2];
typedef unsigned char PixelType;
typedef otb::Image<PixelType, Dimension> ImageType;
typedef otb::VectorImage<PixelType, Dimension> VectorImageType;
typedef otb::ImageList<ImageType> ImageListType;
// IO
typedef otb::ImageFileReader<VectorImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::VectorImageToImageListFilter<VectorImageType, ImageListType> VectorImageToImageListFilterType;
typedef otb::ImageListToSingleImageFilter<ImageListType::ImageType> ImageListToSingleImageFilter;
typedef otb::BandMathImageFilter<ImageType> BandMathImageFilterType ;
// Instantiating object
VectorImageToImageListFilterType::Pointer filter1 = VectorImageToImageListFilterType::New();
ImageListToSingleImageFilter::Pointer filter2_1 = ImageListToSingleImageFilter::New();
ImageListToSingleImageFilter::Pointer filter2_2 = ImageListToSingleImageFilter::New();
BandMathImageFilterType::Pointer filter3 = BandMathImageFilterType::New();
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(infname);
filter1->SetInput(reader->GetOutput());
filter1->UpdateOutputInformation();
filter2_1->SetExtractedImagePosition(1);
filter2_1->SetInput(filter1->GetOutput());
filter2_2->SetExtractedImagePosition(2);
filter2_2->SetInput(filter1->GetOutput());
filter3->SetNthInput(0,filter2_1->GetOutput());
filter3->SetNthInput(1,filter2_2->GetOutput());
filter3->SetExpression("b1/b2");
filter3->SetExpression(" if( b2 > 1.0, b1/b2, 0)" );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outfname1);
writer->SetNumberOfDivisionsTiledStreaming(4);
writer->SetInput(filter3->GetOutput());
writer->Update();
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