diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index 4801509b86a15c923063f9eb0bd27d6f5c23212b..2ce629166fb90c96d230edea22884b54e13bfd54 100644 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -456,7 +456,6 @@ ADD_TEST(ioTvStreamingPipeline_TIF2PNG ${IO_TESTS2} ${TEMP}/ioPipeline.png ) - # --- Image FLOAT ADD_TEST(ioTvImageFileReaderFloatBSQ2HDR ${IO_TESTS2} --compare-image ${EPSILON_9} ${INPUTDATA}/poupees_R4.hd @@ -542,7 +541,82 @@ ADD_TEST(ioTvStreamingWithIFWriterBSQWithStreaming ${IO_TESTS2} SET_TESTS_PROPERTIES(ioTvStreamingWithIFWriterBSQWithStreaming PROPERTIES DEPENDS ioTvImageFileReaderPNG2BSQ) +ADD_TEST(ioTvGDALImageIO_Tiff_NoOption ${IO_TESTS2} + --compare-image ${NOTOL} ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_NoOption.tif + otbGDALImageIOTest_uint16 + ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_NoOption.tif + ) + +ADD_TEST(ioTvGDALImageIO_Tiff_12bits ${IO_TESTS2} + --compare-image ${NOTOL} ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_12bits.tif + otbGDALImageIOTest_uint16 + ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_12bits.tif + "NBITS=12" + ) + +ADD_TEST(ioTvGDALImageIO_Tiff_Stripped ${IO_TESTS2} + --compare-image ${NOTOL} ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_stripped.tif + otbGDALImageIOTest_uint16 + ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_stripped.tif + "BLOCKYSIZE=10" + ) + +ADD_TEST(ioTvGDALImageIO_Tiff_Tiled_16x16 ${IO_TESTS2} + --compare-image ${NOTOL} ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_tiled_16x16.tif + otbGDALImageIOTest_uint16 + ${INPUTDATA}/maur_rgb.tif + ${TEMP}/ioTvGDALImageIO_Tiff_tiled_16x16.tif + "TILED=YES" + "BLOCKXSIZE=16" + "BLOCKYSIZE=16" + ) +ADD_TEST(ioTvGDALImageIO_Tiff_JPEG_20 ${IO_TESTS2} + --compare-image ${NOTOL} ${BASELINE}/ioTvGDALImageIO_Tiff_JPEG_20.tif + ${TEMP}/ioTvGDALImageIO_Tiff_JPEG_20.tif + otbGDALImageIOTest_uint8 + ${INPUTDATA}/maur_rgb_24bpp.tif + ${TEMP}/ioTvGDALImageIO_Tiff_JPEG_20.tif + "COMPRESS=JPEG" + "JPEG_QUALITY=20" + "PHOTOMETRIC=YCBCR" + ) + +ADD_TEST(ioTvGDALImageIO_Tiff_JPEG_99 ${IO_TESTS2} + --compare-image ${NOTOL} ${BASELINE}/ioTvGDALImageIO_Tiff_JPEG_99.tif + ${TEMP}/ioTvGDALImageIO_Tiff_JPEG_99.tif + otbGDALImageIOTest_uint8 + ${INPUTDATA}/maur_rgb_24bpp.tif + ${TEMP}/ioTvGDALImageIO_Tiff_JPEG_99.tif + "COMPRESS=JPEG" + "JPEG_QUALITY=99" + "PHOTOMETRIC=YCBCR" + ) + +ADD_TEST(ioTvGDALImageIO_JPEG_20 ${IO_TESTS2} + --compare-image ${NOTOL} ${BASELINE}/ioTvGDALImageIO_JPEG_20.jpg + ${TEMP}/ioTvGDALImageIO_JPEG_20.jpg + otbGDALImageIOTest_uint8 + ${INPUTDATA}/maur_rgb_24bpp.tif + ${TEMP}/ioTvGDALImageIO_JPEG_20.jpg + "QUALITY=20" + ) + +ADD_TEST(ioTvGDALImageIO_JPEG_99 ${IO_TESTS2} + --compare-image ${NOTOL} ${BASELINE}/ioTvGDALImageIO_JPEG_99.jpg + ${TEMP}/ioTvGDALImageIO_JPEG_99.jpg + otbGDALImageIOTest_uint8 + ${INPUTDATA}/maur_rgb_24bpp.tif + ${TEMP}/ioTvGDALImageIO_JPEG_99.jpg + "QUALITY=99" + ) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbIOTests3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3674,6 +3748,7 @@ otbDoubleImageIOTest.cxx otbStreamingImageFilterTest.cxx otbStreamingImageFileWriterTest.cxx otbPipeline.cxx +otbGDALImageIOTest.cxx ) SET(BasicIO_SRCS3 otbIOTests3.cxx diff --git a/Testing/Code/IO/otbGDALImageIOTest.cxx b/Testing/Code/IO/otbGDALImageIOTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a747ec662e05fde3eefe8e3136fada97136c2b7c --- /dev/null +++ b/Testing/Code/IO/otbGDALImageIOTest.cxx @@ -0,0 +1,79 @@ +/*========================================================================= + + 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 "otbVectorImage.h" +#include "itkMacro.h" +#include <iostream> + +#include "otbImageFileReader.h" +#include "otbStreamingImageFileWriter.h" +#include "otbGDALImageIO.h" + +template<class PixelType> +int otbGenericGDALImageIOTest(int argc, char* argv[]) +{ + // Verify the number of parameters in the command line + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; + + std::vector<std::string> creationOptions; + for (int curArg = 3; curArg < argc; curArg++) + { + creationOptions.push_back(argv[curArg]); + std::cout << "Creation option : " << argv[curArg] << std::endl; + } + + typedef PixelType InputPixelType; + typedef PixelType OutputPixelType; + const unsigned int Dimension = 2; + + typedef otb::VectorImage<InputPixelType, Dimension> InputImageType; + typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; + + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::StreamingImageFileWriter<OutputImageType> WriterType; + + typename ReaderType::Pointer reader = ReaderType::New(); + typename WriterType::Pointer writer = WriterType::New(); + + + reader->SetFileName(inputFilename); + writer->SetFileName(outputFilename); + + // Be sure to use GDALImageIO + otb::GDALImageIO::Pointer io = otb::GDALImageIO::New(); + io->SetOptions(creationOptions); + writer->SetImageIO(io.GetPointer()); + + writer->SetInput(reader->GetOutput()); + writer->Update(); + + return EXIT_SUCCESS; +} + +int otbGDALImageIOTest_uint8(int argc, char* argv[]) +{ + return otbGenericGDALImageIOTest<unsigned char>(argc, argv); +} + +int otbGDALImageIOTest_uint16(int argc, char* argv[]) +{ + return otbGenericGDALImageIOTest<unsigned short>(argc, argv); +} diff --git a/Testing/Code/IO/otbIOTests2.cxx b/Testing/Code/IO/otbIOTests2.cxx index d0298b9ebab38175420074541be1dcd8685923b8..80c24b3e1a0568ae0e9054e2e656a59528442cab 100644 --- a/Testing/Code/IO/otbIOTests2.cxx +++ b/Testing/Code/IO/otbIOTests2.cxx @@ -31,4 +31,6 @@ void RegisterTests() REGISTER_TEST(otbStreamingImageFilterTest); REGISTER_TEST(otbStreamingImageFileWriterTest); REGISTER_TEST(otbPipeline); + REGISTER_TEST(otbGDALImageIOTest_uint8); + REGISTER_TEST(otbGDALImageIOTest_uint16); }