OTB  9.0.0
Orfeo Toolbox
otbLmvmPanSharpeningFusionImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbLmvmPanSharpeningFusionImageFilter_h
23 #define otbLmvmPanSharpeningFusionImageFilter_h
24 
26 #include "otbFunctorImageFilter.h"
28 #include "itkNoiseImageFilter.h"
29 #include "otbVectorImage.h"
30 
31 #include "itkProgressAccumulator.h"
32 
33 
34 namespace otb
35 {
56 template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision = float>
57 class ITK_EXPORT LmvmPanSharpeningFusionImageFilter : public itk::ImageToImageFilter<TXsImageType, TOutputImageType>
58 {
59 public:
62  typedef itk::ImageToImageFilter<TXsImageType, TOutputImageType> Superclass;
63  typedef itk::SmartPointer<Self> Pointer;
64  typedef itk::SmartPointer<const Self> ConstPointer;
65 
68 
70  typedef typename TXsImageType::InternalPixelType XsPixelType;
72 
75 
77  typedef typename itk::Array<TInternalPrecision> ArrayType;
78 
80  itkNewMacro(Self);
81 
83  itkTypeMacro(LmvmPanSharpeningFusionImageFilter, itk::ImageToImageFilter);
84 
86  typedef typename InternalImageType::SizeType RadiusType;
87 
89  itkGetMacro(Radius, RadiusType);
90  itkSetMacro(Radius, RadiusType);
92 
94  itkSetMacro(Filter, ArrayType);
95  itkGetConstReferenceMacro(Filter, ArrayType);
97 
98  virtual void SetPanInput(const TPanImageType* image);
99  const TPanImageType* GetPanInput(void) const;
100 
101  virtual void SetXsInput(const TXsImageType* path);
102  const TXsImageType* GetXsInput(void) const;
103 
104 protected:
107 
110 
112  void GenerateData() override;
113 
115  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
116 
117 private:
118  LmvmPanSharpeningFusionImageFilter(Self&); // intentionally not implemented
119  void operator=(const Self&); // intentionally not implemented
120 
128  {
129  public:
130  // Implement the fusion as a six arguments operator
131  void operator()(typename TOutputImageType::PixelType& output, const typename InternalVectorImageType::PixelType& stdXsPixel,
132  const TInternalPrecision& smoothPanchroPixel, const typename TPanImageType::PixelType& sharpPanchroPixel) const
133  {
134  // Perform fusion for each band with appropriate casting
135  for (unsigned int i = 0; i < stdXsPixel.Size(); ++i)
136  {
137  output[i] = static_cast<typename TOutputImageType::InternalPixelType>(((sharpPanchroPixel - smoothPanchroPixel) * stdXsPixel[i]));
138  }
139  }
140  constexpr size_t OutputSize(const std::array<size_t, 3> inputsNbBands) const
141  {
142  return inputsNbBands[0];
143  }
144  };
145 
147  {
148  public:
149  // Implement the fusion as a six arguments operator
150  void operator()(typename TOutputImageType::PixelType& output, const typename TOutputImageType::PixelType& functor1Pixel,
151  const typename InternalVectorImageType::PixelType& smoothXsPixel, const TInternalPrecision& stdPanchroPixel) const
152  {
153  TInternalPrecision scale = 1.;
154 
155  if (std::abs(stdPanchroPixel) > 1e-10)
156  {
157  scale = 1.0 / stdPanchroPixel;
158  }
159 
160  // Perform fusion for each band with appropriate casting
161  for (unsigned int i = 0; i < smoothXsPixel.Size(); ++i)
162  {
163  output[i] = static_cast<typename TOutputImageType::InternalPixelType>(((functor1Pixel[i] * scale) + smoothXsPixel[i]));
164  }
165  }
166 
167  constexpr size_t OutputSize(const std::array<size_t, 3> inputsNbBands) const
168  {
169  return inputsNbBands[0];
170  }
171  };
172 
178 
181 
182 
184 
187 
188 
192 
195 
199 
202 
204  typedef itk::NoiseImageFilter<TPanImageType, InternalImageType> PanNoiseFilterType;
205 
207  typename PanNoiseFilterType::Pointer m_PanNoiseFilter;
208 
210  typedef itk::NoiseImageFilter<XsBandImageType, InternalImageType> XsNoiseFilterType;
211 
213  typename XsNoiseFilterType::Pointer m_XsNoiseFilter;
214 
217 
220 
223 
226 
229 
232 
234  typename itk::ProgressAccumulator::Pointer m_ProgressAccumulator;
235 };
236 
237 } // end namespace otb
238 
239 #ifndef OTB_MANUAL_INSTANTIATION
241 #endif
242 
243 #endif
otb::PerBandVectorImageFilter
This filter is a helper class to apply per band a standard itk::ImageToImageFilter to a VectorImage.
Definition: otbPerBandVectorImageFilter.h:49
otb::LmvmPanSharpeningFusionImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLmvmPanSharpeningFusionImageFilter.h:63
otbFunctorImageFilter.h
otb::ConvolutionImageFilter
Applies a convolution filter to a mono channel image.
Definition: otbConvolutionImageFilter.h:68
otbVectorImage.h
otb::LmvmPanSharpeningFusionImageFilter::PanNoiseFilterType
itk::NoiseImageFilter< TPanImageType, InternalImageType > PanNoiseFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:204
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor2
Definition: otbLmvmPanSharpeningFusionImageFilter.h:146
otb::LmvmPanSharpeningFusionImageFilter::m_Filter
ArrayType m_Filter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:231
otb::LmvmPanSharpeningFusionImageFilter::FusionStep2FilterType
FunctorImageFilter< FusionFunctor2 > FusionStep2FilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:183
otb::LmvmPanSharpeningFusionImageFilter::InternalVectorImageType
otb::VectorImage< TInternalPrecision, TXsImageType::ImageDimension > InternalVectorImageType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:74
otb::FunctorImageFilter
A generic functor filter templated by its functor.
Definition: otbFunctorImageFilter.h:322
otb::LmvmPanSharpeningFusionImageFilter::XsVectorConvolutionFilterType
otb::PerBandVectorImageFilter< TXsImageType, InternalVectorImageType, XsConvolutionFilterType > XsVectorConvolutionFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:216
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Image
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
otb::ConvolutionImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbConvolutionImageFilter.h:83
otb::FunctorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbFunctorImageFilter.h:329
otb::LmvmPanSharpeningFusionImageFilter::RadiusType
InternalImageType::SizeType RadiusType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:83
otb::LmvmPanSharpeningFusionImageFilter::m_XsConvolutionFilter
XsConvolutionFilterType::Pointer m_XsConvolutionFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:201
otb::LmvmPanSharpeningFusionImageFilter::m_XsVectorNoiseFilter
XsVectorNoiseFilterType::Pointer m_XsVectorNoiseFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:225
otbLmvmPanSharpeningFusionImageFilter.hxx
otb::LmvmPanSharpeningFusionImageFilter::m_XsVectorConvolutionFilter
XsVectorConvolutionFilterType::Pointer m_XsVectorConvolutionFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:219
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor2::operator()
void operator()(typename TOutputImageType::PixelType &output, const typename TOutputImageType::PixelType &functor1Pixel, const typename InternalVectorImageType::PixelType &smoothXsPixel, const TInternalPrecision &stdPanchroPixel) const
Definition: otbLmvmPanSharpeningFusionImageFilter.h:150
otb::Wrapper::Tags::Filter
static const std::string Filter
Definition: otbWrapperTags.h:39
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor1::operator()
void operator()(typename TOutputImageType::PixelType &output, const typename InternalVectorImageType::PixelType &stdXsPixel, const TInternalPrecision &smoothPanchroPixel, const typename TPanImageType::PixelType &sharpPanchroPixel) const
Definition: otbLmvmPanSharpeningFusionImageFilter.h:131
otbConvolutionImageFilter.h
otb::LmvmPanSharpeningFusionImageFilter::Self
LmvmPanSharpeningFusionImageFilter Self
Definition: otbLmvmPanSharpeningFusionImageFilter.h:61
otb::LmvmPanSharpeningFusionImageFilter::XsConvolutionFilterType
otb::ConvolutionImageFilter< XsBandImageType, InternalImageType, itk::ZeroFluxNeumannBoundaryCondition< TPanImageType >, TInternalPrecision > XsConvolutionFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:198
otb::LmvmPanSharpeningFusionImageFilter::m_FusionStep2Filter
FusionStep2FilterType::Pointer m_FusionStep2Filter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:186
otb::LmvmPanSharpeningFusionImageFilter::ArrayType
itk::Array< TInternalPrecision > ArrayType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:77
otb::LmvmPanSharpeningFusionImageFilter::~LmvmPanSharpeningFusionImageFilter
~LmvmPanSharpeningFusionImageFilter() override
Definition: otbLmvmPanSharpeningFusionImageFilter.h:109
otb::LmvmPanSharpeningFusionImageFilter::FusionStep1FilterType
FunctorImageFilter< FusionFunctor1 > FusionStep1FilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:177
otb::LmvmPanSharpeningFusionImageFilter::m_PanNoiseFilter
PanNoiseFilterType::Pointer m_PanNoiseFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:207
otb::LmvmPanSharpeningFusionImageFilter::XsBandImageType
otb::Image< XsPixelType, TXsImageType::ImageDimension > XsBandImageType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:71
otb::PerBandVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPerBandVectorImageFilter.h:55
otb::LmvmPanSharpeningFusionImageFilter::m_ProgressAccumulator
itk::ProgressAccumulator::Pointer m_ProgressAccumulator
Definition: otbLmvmPanSharpeningFusionImageFilter.h:234
otbPerBandVectorImageFilter.h
otb::LmvmPanSharpeningFusionImageFilter
This class performs a Local Mean and Variance Matching (LMVM) Pan sharpening operation.
Definition: otbLmvmPanSharpeningFusionImageFilter.h:57
otb::LmvmPanSharpeningFusionImageFilter::XsPixelType
TXsImageType::InternalPixelType XsPixelType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:70
otb::LmvmPanSharpeningFusionImageFilter::m_FusionStep1Filter
FusionStep1FilterType::Pointer m_FusionStep1Filter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:180
otb::VectorImage::PixelType
Superclass::PixelType PixelType
Definition: otbVectorImage.h:63
otb::LmvmPanSharpeningFusionImageFilter::InternalImageType
otb::Image< TInternalPrecision, TPanImageType::ImageDimension > InternalImageType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:67
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor2::OutputSize
constexpr vcl_size_t OutputSize(const std::array< vcl_size_t, 3 > inputsNbBands) const
Definition: otbLmvmPanSharpeningFusionImageFilter.h:167
otb::LmvmPanSharpeningFusionImageFilter::XsNoiseFilterType
itk::NoiseImageFilter< XsBandImageType, InternalImageType > XsNoiseFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:210
otb::LmvmPanSharpeningFusionImageFilter::Superclass
itk::ImageToImageFilter< TXsImageType, TOutputImageType > Superclass
Definition: otbLmvmPanSharpeningFusionImageFilter.h:62
otb::LmvmPanSharpeningFusionImageFilter::m_PanConvolutionFilter
PanConvolutionFilterType::Pointer m_PanConvolutionFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:194
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor1::OutputSize
constexpr vcl_size_t OutputSize(const std::array< vcl_size_t, 3 > inputsNbBands) const
Definition: otbLmvmPanSharpeningFusionImageFilter.h:140
otb::LmvmPanSharpeningFusionImageFilter::m_XsNoiseFilter
XsNoiseFilterType::Pointer m_XsNoiseFilter
Definition: otbLmvmPanSharpeningFusionImageFilter.h:213
otb::LmvmPanSharpeningFusionImageFilter::XsVectorNoiseFilterType
otb::PerBandVectorImageFilter< TXsImageType, InternalVectorImageType, XsNoiseFilterType > XsVectorNoiseFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:222
otb::LmvmPanSharpeningFusionImageFilter::PanConvolutionFilterType
otb::ConvolutionImageFilter< TPanImageType, InternalImageType, itk::ZeroFluxNeumannBoundaryCondition< TPanImageType >, TInternalPrecision > PanConvolutionFilterType
Definition: otbLmvmPanSharpeningFusionImageFilter.h:191
otb::LmvmPanSharpeningFusionImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLmvmPanSharpeningFusionImageFilter.h:64
otb::LmvmPanSharpeningFusionImageFilter::FusionFunctor1
Definition: otbLmvmPanSharpeningFusionImageFilter.h:127
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45
otb::LmvmPanSharpeningFusionImageFilter::m_Radius
RadiusType m_Radius
Definition: otbLmvmPanSharpeningFusionImageFilter.h:228
otb::Image::SizeType
Superclass::SizeType SizeType
Definition: otbImage.h:148