diff --git a/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.h b/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..a58a9a9531e308ecbe24f8029168726dbc3a05e9 --- /dev/null +++ b/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.h @@ -0,0 +1,265 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + Some parts of this code are derived from ITK. See ITKCopyright.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. + +=========================================================================*/ +#ifndef __otbLmvmPanSharpeningFusionImageFilter_h +#define __otbLmvmPanSharpeningFusionImageFilter_h + +#include "itkImageToImageFilter.h" +#include "otbConvolutionImageFilter.h" +#include "itkTernaryFunctorImageFilter.h" +#include "otbPerBandVectorImageFilter.h" +#include "itkNoiseImageFilter.h" +#include "otbVectorImage.h" + +#include "itkProgressAccumulator.h" + + +namespace otb +{ +/** + * \class LmvmPanSharpeningFusionImageFilter + * \brief This class performs a Local Mean and Variance Matching (LMVM) Pan sharpening operation + * + * Given a Pan image and the corresponding Xs image (oversampled to have the + * same number of pixels), this filter realizes an Local Mean and Variance + * Matching Pan sharpening operation as described in: + * + * de Bethune, S. and Muller, F. and Donnay, J.P. 1998. Fusion of multispectral and panchromatic images + * by local mean and variance matching filtering techniques. Fusion of Earth Data, 28-30 August 1998. + * + * \ingroup Streamed + * \ingroup Multithreaded + * \ingroup Fusion + * + * + **/ + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision = float> +class ITK_EXPORT LmvmPanSharpeningFusionImageFilter : + public itk::ImageToImageFilter<TXsImageType, TOutputImageType> +{ +public: + /** Standard class typedefs */ + typedef LmvmPanSharpeningFusionImageFilter Self; + typedef itk::ImageToImageFilter<TXsImageType, TOutputImageType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Internal image type used as Pan smoothing and local standard deviation filter output */ + typedef otb::Image<TInternalPrecision, + TPanImageType::ImageDimension> InternalImageType; + + /** Single band Xs image type */ + typedef typename TXsImageType::InternalPixelType XsPixelType; + typedef otb::Image<XsPixelType, + TXsImageType::ImageDimension> XsBandImageType; + + /** Internal image type used as Xs smoothing and local standard deviation filter output */ + typedef otb::VectorImage<TInternalPrecision, + TXsImageType::ImageDimension> InternalVectorImageType; + + /** Typedef for the radius of the smoothing and local standard deviation filter */ + typedef typename itk::Array<TInternalPrecision> ArrayType; + + /** Method for creation through object factory */ + itkNewMacro(Self); + + /** Run-time type information */ + itkTypeMacro(LmvmPanSharpeningFusionImageFilter, + itk::ImageToImageFilter); + + /** Define the radius type for the smoothing and local standard deviation operation */ + typedef typename InternalImageType::SizeType RadiusType; + + /** Set the smoothing and local standard deviation filter radius */ + itkGetMacro(Radius, RadiusType); + itkSetMacro(Radius, RadiusType); + + /** Set the kernel used for the smoothing and local standard deviation filter */ + itkSetMacro(Filter, ArrayType); + itkGetConstReferenceMacro(Filter, ArrayType); + + virtual void SetPanInput(const TPanImageType * image); + const TPanImageType * GetPanInput(void) const; + + virtual void SetXsInput(const TXsImageType * path); + const TXsImageType * GetXsInput(void) const; + +protected: + /** Constructor */ + LmvmPanSharpeningFusionImageFilter(); + + /** Destructor */ + virtual ~LmvmPanSharpeningFusionImageFilter() {}; + + /** Call to generate data, wiring composite internal minipipeline */ + void GenerateData(); + + /** PrintSelf method */ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + LmvmPanSharpeningFusionImageFilter(Self &); // intentionally not implemented + void operator =(const Self&); // intentionally not implemented + + /** \class FusionFunctor + * This functor applies the LMVM + * operation. It is intended for internal use only. + */ + class FusionFunctor1 + { + public: + // Implement the fusion as a six arguments operator + typename TOutputImageType::PixelType operator()(const TInternalPrecision& smoothPanchroPixel, + const typename InternalVectorImageType::PixelType& stdXsPixel, + const typename TPanImageType::PixelType& sharpPanchroPixel) const + { + // Build output pixel + typename TOutputImageType::PixelType output(stdXsPixel.Size()); + + // Perform fusion for each band with appropriate casting + for(unsigned int i = 0; i < stdXsPixel.Size(); ++i) + { + output[i] = static_cast<typename TOutputImageType::InternalPixelType>( + ((sharpPanchroPixel - smoothPanchroPixel) * stdXsPixel[i])); + } + // Returns the output pixel + return output; + } + }; + + class FusionFunctor2 + { + public: + // Implement the fusion as a six arguments operator + typename TOutputImageType::PixelType operator()(const typename TOutputImageType::PixelType& functor1Pixel, + const typename InternalVectorImageType::PixelType& smoothXsPixel, + const TInternalPrecision& stdPanchroPixel) const + { + // Build output pixel + typename TOutputImageType::PixelType output(smoothXsPixel.Size()); + + TInternalPrecision scale = 1.; + + if(vcl_abs(stdPanchroPixel) > 1e-10) + { + scale = 1.0/stdPanchroPixel; + } + + // Perform fusion for each band with appropriate casting + for(unsigned int i = 0; i < smoothXsPixel.Size(); ++i) + { + output[i] = static_cast<typename TOutputImageType::InternalPixelType>( + ((functor1Pixel[i] * scale) + smoothXsPixel[i])); + } + // Returns the output pixel + return output; + } + }; + + /** + * Typedef of the TernaryFunctorImageFilter applying the fusion functor to + * p, p_smooth, p_std, xs_smooth, xs_std and xs. + */ + typedef itk::TernaryFunctorImageFilter<InternalImageType, + InternalVectorImageType, + TPanImageType, + TOutputImageType, + FusionFunctor1> FusionStep1FilterType; + + /** Pointer to the fusion filter */ + typename FusionStep1FilterType::Pointer m_FusionStep1Filter; + + + typedef itk::TernaryFunctorImageFilter<TOutputImageType, + InternalVectorImageType, + InternalImageType, + TOutputImageType, + FusionFunctor2> FusionStep2FilterType; + + /** Pointer to the fusion filter */ + typename FusionStep2FilterType::Pointer m_FusionStep2Filter; + + + /** Typedef of the convolution filter performing Pan smoothing */ + typedef otb::ConvolutionImageFilter + <TPanImageType, + InternalImageType, + itk::ZeroFluxNeumannBoundaryCondition<TPanImageType>, + TInternalPrecision> PanConvolutionFilterType; + + /** Pointer to the internal Pan convolution filter */ + typename PanConvolutionFilterType::Pointer m_PanConvolutionFilter; + + /** Typedef of the convolution filter performing Xs smoothing */ + typedef otb::ConvolutionImageFilter + <XsBandImageType, + InternalImageType, + itk::ZeroFluxNeumannBoundaryCondition<TPanImageType>, + TInternalPrecision> XsConvolutionFilterType; + + /** Pointer to the internal Xs convolution filter */ + typename XsConvolutionFilterType::Pointer m_XsConvolutionFilter; + + /** Typedef of the Pan local standard deviation filter*/ + typedef itk::NoiseImageFilter + <TPanImageType, InternalImageType> PanNoiseFilterType; + + /** Pointer to the Pan local standard deviation filter */ + typename PanNoiseFilterType::Pointer m_PanNoiseFilter; + + /** Typedef of the Xs local standard deviation filter*/ + typedef itk::NoiseImageFilter + <XsBandImageType, InternalImageType> XsNoiseFilterType; + + /** Pointer to the Xs local standard deviation filter */ + typename XsNoiseFilterType::Pointer m_XsNoiseFilter; + + /** Typedef of a helper filter to apply to a vector image*/ + typedef otb::PerBandVectorImageFilter + < TXsImageType, InternalVectorImageType, XsConvolutionFilterType> XsVectorConvolutionFilterType; + + /** Pointer to the helper vector image filter */ + typename XsVectorConvolutionFilterType::Pointer m_XsVectorConvolutionFilter; + + /** Typedef of a helper filter to apply to a vector image*/ + typedef otb::PerBandVectorImageFilter + < TXsImageType, InternalVectorImageType, XsNoiseFilterType> XsVectorNoiseFilterType; + + /** Pointer to the helper vector image filter */ + typename XsVectorNoiseFilterType::Pointer m_XsVectorNoiseFilter; + + /** Radius used for the smoothing filter */ + RadiusType m_Radius; + + /** Kernel used for the smoothing filter */ + ArrayType m_Filter; + + /** The internal progress accumulator */ + typename itk::ProgressAccumulator::Pointer m_ProgressAccumulator; +}; + +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbLmvmPanSharpeningFusionImageFilter.txx" +#endif + +#endif diff --git a/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.txx b/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..45ca9f52f7b8cd5877ae0fa2327749ee30ad3268 --- /dev/null +++ b/Code/Fusion/otbLmvmPanSharpeningFusionImageFilter.txx @@ -0,0 +1,184 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + Some parts of this code are derived from ITK. See ITKCopyright.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. + +=========================================================================*/ +#ifndef __otbLmvmPanSharpeningFusionImageFilter_txx +#define __otbLmvmPanSharpeningFusionImageFilter_txx + +#include "otbLmvmPanSharpeningFusionImageFilter.h" + +namespace otb +{ +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::LmvmPanSharpeningFusionImageFilter() +{ + // Fix number of required inputs + this->SetNumberOfRequiredInputs(2); + + // Instantiate convolution filters + m_PanConvolutionFilter = PanConvolutionFilterType::New(); + m_PanConvolutionFilter->NormalizeFilterOn(); + m_XsConvolutionFilter = XsConvolutionFilterType::New(); + m_XsConvolutionFilter->NormalizeFilterOn(); + m_PanNoiseFilter = PanNoiseFilterType::New(); + m_XsNoiseFilter = XsNoiseFilterType::New(); + m_XsVectorConvolutionFilter = XsVectorConvolutionFilterType::New(); + m_XsVectorNoiseFilter = XsVectorNoiseFilterType::New(); + + + // Set-up default parameters + m_Radius.Fill(3); + m_Filter.SetSize(7 * 7); + m_Filter.Fill(1); + + // Instantiate fusion filter + m_FusionStep1Filter = FusionStep1FilterType::New(); + m_FusionStep2Filter = FusionStep2FilterType::New(); + + // Set-up progress reporting + m_ProgressAccumulator = itk::ProgressAccumulator::New(); + m_ProgressAccumulator->SetMiniPipelineFilter(this); + m_ProgressAccumulator->RegisterInternalFilter(m_PanConvolutionFilter, 0.2); + m_ProgressAccumulator->RegisterInternalFilter(m_PanNoiseFilter, 0.2); + m_ProgressAccumulator->RegisterInternalFilter(m_XsVectorConvolutionFilter, 0.2); + m_ProgressAccumulator->RegisterInternalFilter(m_XsVectorNoiseFilter, 0.2); + m_ProgressAccumulator->RegisterInternalFilter(m_FusionStep1Filter, 0.1); + m_ProgressAccumulator->RegisterInternalFilter(m_FusionStep2Filter, 0.1); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +void +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::SetPanInput(const TPanImageType *image) +{ + // We have 2 inputs: an image and a vector image + + // Process object is not const-correct so the const_cast is required here + this->itk::ProcessObject::SetNthInput(1, + const_cast<TPanImageType*>(image)); + this->Modified(); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +const TPanImageType * +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::GetPanInput(void) const +{ + if (this->GetNumberOfInputs() < 2) + { + return 0; + } + + return static_cast<const TPanImageType *> + (this->itk::ProcessObject::GetInput(1)); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +void +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::SetXsInput(const TXsImageType *image) +{ + // We have 2 inputs: an image and a vector image + + // Process object is not const-correct so the const_cast is required here + this->itk::ProcessObject::SetNthInput(0, + const_cast<TXsImageType*>(image)); + this->Modified(); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +const TXsImageType * +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::GetXsInput(void) const +{ + if (this->GetNumberOfInputs() < 1) + { + return 0; + } + + return static_cast<const TXsImageType *> + (this->itk::ProcessObject::GetInput(0)); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +void +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::GenerateData() +{ + //Check if size is correct + typename TPanImageType::SizeType sizePan; + typename TXsImageType::SizeType sizeXs; + sizePan = this->GetPanInput()->GetLargestPossibleRegion().GetSize(); + sizeXs = this->GetXsInput()->GetLargestPossibleRegion().GetSize(); + if ((sizePan[0] != sizeXs[0]) || (sizePan[1] != sizeXs[1])) + { + itkExceptionMacro(<< "LmvmPanSharpeningFusionImageFilter: Wrong Pan/Xs size"); + } + + //Process the fusion + m_PanConvolutionFilter->SetInput(this->GetPanInput()); + m_PanConvolutionFilter->SetRadius(this->m_Radius); + m_PanConvolutionFilter->SetFilter(this->m_Filter); + m_PanNoiseFilter->SetRadius(this->m_Radius); + m_PanNoiseFilter->SetInput(this->GetPanInput()); + m_XsConvolutionFilter->SetRadius(this->m_Radius); + m_XsConvolutionFilter->SetFilter(this->m_Filter); + m_XsVectorConvolutionFilter->SetInput(this->GetXsInput()); + m_XsVectorConvolutionFilter->SetFilter(m_XsConvolutionFilter); + m_XsNoiseFilter->SetRadius(this->m_Radius); + m_XsVectorNoiseFilter->SetInput(this->GetXsInput()); + m_XsVectorNoiseFilter->SetFilter(m_XsNoiseFilter); + + + m_FusionStep1Filter->SetInput2(m_XsVectorNoiseFilter->GetOutput()); + m_FusionStep1Filter->SetInput1(m_PanConvolutionFilter->GetOutput()); + m_FusionStep1Filter->SetInput3(this->GetPanInput()); + + m_FusionStep2Filter->SetInput1(m_FusionStep1Filter->GetOutput()); + m_FusionStep2Filter->SetInput3(m_PanNoiseFilter->GetOutput()); + m_FusionStep2Filter->SetInput2(m_XsVectorConvolutionFilter->GetOutput()); + + // Wire composite filter + m_FusionStep2Filter->GraftOutput(this->GetOutput()); + m_FusionStep2Filter->Update(); + this->GraftOutput(m_FusionStep2Filter->GetOutput()); +} + +template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> +void +LmvmPanSharpeningFusionImageFilter +<TPanImageType, TXsImageType, TOutputImageType, TInternalPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); + os + << indent << "Radius:" << this->m_Radius + << std::endl; +} + +} // end namespace otb + +#endif 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; +}