diff --git a/Testing/Code/Fusion/CMakeLists.txt b/Testing/Code/Fusion/CMakeLists.txt index 08bc51f6bc44ed7b44edc124a81fcf3978dcb40c..d3eb9851a002ae1340d0bd66eae45e8cd6b787fa 100644 --- a/Testing/Code/Fusion/CMakeLists.txt +++ b/Testing/Code/Fusion/CMakeLists.txt @@ -42,6 +42,20 @@ ADD_TEST(fuTvSimpleRcsPanSharpeningFusionImageFilter ${FUSION_TESTS1} ${TEMP}/fuTvRcsPanSharpeningFusion.tif ) +# ------- otb::LmvmPanSharpeningFusionImageFilter ------------------- +ADD_TEST(fuTuLmvmPanSharpeningFusionImageFilterNew ${FUSION_TESTS1} + otbLmvmPanSharpeningFusionImageFilterNew +) + +ADD_TEST(fuTvLmvmPanSharpeningFusionImageFilter ${FUSION_TESTS1} + --compare-image ${EPSILON_8} ${BASELINE}/fuTvLmvmPanSharpeningFusion.tif + ${TEMP}/fuTvLmvmPanSharpeningFusion.tif + otbLmvmPanSharpeningFusionImageFilter + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif + ${TEMP}/fuTvLmvmPanSharpeningFusion.tif +) + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbFusion2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -54,6 +68,8 @@ otbBayesianFusionFilterNew.cxx otbBayesianFusionFilter.cxx otbSimpleRcsPanSharpeningFusionImageFilterNew.cxx otbSimpleRcsPanSharpeningFusionImageFilter.cxx +otbLmvmPanSharpeningFusionImageFilterNew.cxx +otbLmvmPanSharpeningFusionImageFilter.cxx ) OTB_ADD_EXECUTABLE(otbFusionTests1 "${Fusion_SRCS1}" "OTBFusion;OTBIO;OTBTesting") diff --git a/Testing/Code/Fusion/otbFusionTests1.cxx b/Testing/Code/Fusion/otbFusionTests1.cxx index 0bf04110072764ad64ce41b39115fd895fc2198a..a0ecdfbede4ae05e83e4481084e6c8db67f34aee 100644 --- a/Testing/Code/Fusion/otbFusionTests1.cxx +++ b/Testing/Code/Fusion/otbFusionTests1.cxx @@ -29,4 +29,6 @@ void RegisterTests() REGISTER_TEST(otbFusionImageBaseNew); REGISTER_TEST(otbSimpleRcsPanSharpeningFusionImageFilterNew); REGISTER_TEST(otbSimpleRcsPanSharpeningFusionImageFilter); + REGISTER_TEST(otbLmvmPanSharpeningFusionImageFilterNew); + REGISTER_TEST(otbLmvmPanSharpeningFusionImageFilter); } diff --git a/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.cxx b/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..47f5f8baaabf8bc5d0a26ad0dfeea8f56ad92ffe --- /dev/null +++ b/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.cxx @@ -0,0 +1,80 @@ +/*========================================================================= + + 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 "otbImageFileReader.h" +#include "otbStreamingImageFileWriter.h" +#include "otbVectorImage.h" +#include "otbImage.h" + +#include "otbLmvmPanSharpeningFusionImageFilter.h" + +int otbLmvmPanSharpeningFusionImageFilter(int argc, char * argv[]) +{ + const char * panchro = argv[1]; + const char * multispect = argv[2]; + const char * output = argv[3]; + + const unsigned int Dimension = 2; + typedef double PixelType; + + typedef otb::VectorImage<PixelType, Dimension> VectorImageType; + typedef otb::Image<PixelType, Dimension> PanchroImageType; + typedef otb::ImageFileReader<VectorImageType> VectorReaderType; + typedef otb::ImageFileReader<PanchroImageType> ImageReaderType; + typedef otb::StreamingImageFileWriter<VectorImageType> VectorImageWriterType; + typedef otb::LmvmPanSharpeningFusionImageFilter + <PanchroImageType, VectorImageType, VectorImageType, double> FilterType; + + VectorReaderType::Pointer multiSpectReader = VectorReaderType::New(); + ImageReaderType::Pointer panchroReader = ImageReaderType::New(); + FilterType::Pointer filter = FilterType::New(); + VectorImageWriterType::Pointer writer = VectorImageWriterType::New(); + + multiSpectReader->SetFileName(multispect); + panchroReader->SetFileName(panchro); + + PanchroImageType::SizeType radius; + radius[0] = 3; + radius[1] = 3; + itk::Array<double> filterCoeffs; + filterCoeffs.SetSize((2 * radius[0] + 1) * (2 * radius[1] + 1)); + + // double filterTmp[] = { + // 0.00390625, 0.0078125, 0.0117188, 0.015625, 0.0117188, 0.0078125, 0.00390625, + // 0.0078125, 0.015625, 0.0234375, 0.03125, 0.0234375, 0.015625, 0.0078125, + // 0.0117188, 0.0234375, 0.0351562, 0.046875, 0.0351562, 0.0234375, 0.0117188, + // 0.015625, 0.03125, 0.046875, 0.0625, 0.046875, 0.03125, 0.015625, + // 0.0117188, 0.0234375, 0.0351562, 0.046875, 0.0351562, 0.0234375, 0.0117188, + // 0.0078125, 0.015625, 0.0234375, 0.03125, 0.0234375, 0.015625, 0.0078125, + // 0.00390625, 0.0078125, 0.0117188, 0.015625, 0.0117188, 0.0078125, 0.00390625 }; + // + // filterCoeffs.SetData(filterTmp); + + filterCoeffs.Fill(1); + + filter->SetXsInput(multiSpectReader->GetOutput()); + filter->SetPanInput(panchroReader->GetOutput()); + filter->SetRadius(radius); + filter->SetFilter(filterCoeffs); + writer->SetInput(filter->GetOutput()); + writer->SetFileName(output); + writer->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilterNew.cxx b/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..aa8044919ff1b921e8ccac9343795aa5b40a16a3 --- /dev/null +++ b/Testing/Code/Fusion/otbLmvmPanSharpeningFusionImageFilterNew.cxx @@ -0,0 +1,44 @@ +/*========================================================================= + + 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 "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbVectorImage.h" +#include "otbImage.h" + +#include "otbLmvmPanSharpeningFusionImageFilter.h" + +int otbLmvmPanSharpeningFusionImageFilterNew(int argc, char * argv[]) +{ + const unsigned int Dimension = 2; + typedef double PixelType; + + typedef otb::VectorImage<PixelType, Dimension> VectorImageType; + typedef otb::Image<PixelType, Dimension> PanchroImageType; + typedef otb::ImageFileReader<VectorImageType> VectorReaderType; + typedef otb::ImageFileReader<PanchroImageType> ImageReaderType; + typedef otb::LmvmPanSharpeningFusionImageFilter + <PanchroImageType, VectorImageType, VectorImageType> FilterType; + + FilterType::Pointer filter = FilterType::New(); + + std::cout << filter << std::endl; + + return EXIT_SUCCESS; +}