Commit 492eb20f authored by Mickael Savinaud's avatar Mickael Savinaud

TEST: add tests about VectorImageToImageList with managment of the output with an iterator

parent 04a39080
......@@ -330,6 +330,33 @@ ADD_TEST(bfTvVectorImageToImageListFilter ${BASICFILTERS_TESTS3}
${TEMP}/bfTvVectorImageToImageListFilterBand3.png
)
ADD_TEST(bfTvVectorImageToImageListFilterIt ${BASICFILTERS_TESTS3}
--compare-n-images ${EPSILON_7} 3
${BASELINE}/bfTvVectorImageToImageListFilterBand1.png
${TEMP}/bfTvVectorImageToImageListFilterBand1.png
${BASELINE}/bfTvVectorImageToImageListFilterBand2.png
${TEMP}/bfTvVectorImageToImageListFilterBand2.png
${BASELINE}/bfTvVectorImageToImageListFilterBand3.png
${TEMP}/bfTvVectorImageToImageListFilterBand3.png
otbVectorImageToImageListFilterIterator
${INPUTDATA}/poupees.png
${TEMP}/bfTvVectorImageToImageListFilter
png
)
ADD_TEST(bfTvVectorImageToImageListFilterIt2 ${BASICFILTERS_TESTS3}
--compare-n-images ${EPSILON_7} 3
${BASELINE}/bfTvVectorImageToImageListFilterBand1.png
${TEMP}/bfTvVectorImageToImageListFilterBand1.png
${BASELINE}/bfTvVectorImageToImageListFilterBand2.png
${TEMP}/bfTvVectorImageToImageListFilterBand2.png
${BASELINE}/bfTvVectorImageToImageListFilterBand3.png
${TEMP}/bfTvVectorImageToImageListFilterBand3.png
otbVectorImageToImageListFilterIterator
${INPUTDATA}/poupees.png
${TEMP}/bfTvVectorImageToImageListFilter
png
)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbBasicFiltersTests4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -33,6 +33,8 @@ void RegisterTests()
REGISTER_TEST(otbVectorRescaleIntensityImageFilter);
REGISTER_TEST(otbVectorImageToImageListFilterNew);
REGISTER_TEST(otbVectorImageToImageListFilter);
REGISTER_TEST(otbVectorImageToImageListFilterIterator);
REGISTER_TEST(otbVectorImageToImageListFilterIterator2);
REGISTER_TEST(otbShiftScaleVectorImageFilterNew);
REGISTER_TEST(otbShiftScaleVectorImageFilterTest);
}
......@@ -70,3 +70,107 @@ int otbVectorImageToImageListFilter(int argc, char * argv[])
return EXIT_SUCCESS;
}
int otbVectorImageToImageListFilterIterator(int argc, char * argv[])
{
const unsigned int Dimension = 2;
const char * infname = argv[1];
const char * outputFilenamePrefix = argv[2];
const char * outputFilenameSuffix = argv[3];
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 VectorImageToImageListFilterType::OutputImageListType::Iterator ImageListIterator;
// Instantiating object
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(infname);
VectorImageToImageListFilterType::Pointer filter = VectorImageToImageListFilterType::New();
filter->SetInput(reader->GetOutput());
ImageListIterator itOutput = filter->GetOutput()->Begin();
WriterType::Pointer writer = WriterType::New();
int i = 1;
std::stringstream oss;
while ((itOutput != filter->GetOutput()->End()) )
{
oss << outputFilenamePrefix << "Band" << i << "." << outputFilenameSuffix;
writer->SetInput(itOutput.Get());
writer->SetFileName(oss.str().c_str());
writer->Update();
++itOutput;
++i;
}
return EXIT_SUCCESS;
}
int otbVectorImageToImageListFilterIterator2(int argc, char * argv[])
{
const unsigned int Dimension = 2;
const char * infname = argv[1];
const char * outputFilenamePrefix = argv[2];
const char * outputFilenameSuffix = argv[3];
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 VectorImageToImageListFilterType::OutputImageListType::Iterator ImageListIterator;
// Instantiating objects
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(infname);
VectorImageToImageListFilterType::Pointer filter = VectorImageToImageListFilterType::New();
filter->SetInput(reader->GetOutput());
ImageListIterator itOutput = filter->GetOutput()->Begin();
int i = 1;
std::stringstream oss;
while ((itOutput != filter->GetOutput()->End()) )
{
WriterType::Pointer writer = WriterType::New();
oss << outputFilenamePrefix << "Band" << i << "." << outputFilenameSuffix;
writer->SetInput(itOutput.Get());
writer->SetFileName(oss.str().c_str());
writer->Update();
++itOutput;
++i;
}
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