Orfeo Toolbox  4.0
otbSimpleRcsPanSharpeningFusionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are derived from ITK. See ITKCopyright.txt
13  for details.
14 
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notices for more information.
19 
20 =========================================================================*/
21 #ifndef __otbSimpleRcsPanSharpeningFusionImageFilter_h
22 #define __otbSimpleRcsPanSharpeningFusionImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
27 
28 #include "itkProgressAccumulator.h"
29 
30 
31 namespace otb
32 {
51 template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision = float>
53  public itk::ImageToImageFilter<TXsImageType, TOutputImageType>
54 {
55 public:
61 
63  typedef otb::Image<TInternalPrecision,
64  TPanImageType::ImageDimension> InternalImageType;
65 
68 
70  itkNewMacro(Self);
71 
75 
77  typedef typename InternalImageType::SizeType RadiusType;
78 
80  itkGetMacro(Radius, RadiusType);
81  itkSetMacro(Radius, RadiusType);
82 
84  itkSetMacro(Filter, ArrayType);
85  itkGetConstReferenceMacro(Filter, ArrayType);
86 
87  virtual void SetPanInput(const TPanImageType * image);
88  const TPanImageType * GetPanInput(void) const;
89 
90  virtual void SetXsInput(const TXsImageType * path);
91  const TXsImageType * GetXsInput(void) const;
92 
93 protected:
96 
99 
101  void GenerateData();
102 
104  void PrintSelf(std::ostream& os, itk::Indent indent) const;
105 
106 private:
107  SimpleRcsPanSharpeningFusionImageFilter(Self &); // intentionally not implemented
108  void operator =(const Self&); // intentionally not implemented
109 
116  {
117  public:
118  // Implement the fusion as a three arguments operator
119  typename TOutputImageType::PixelType operator()(const typename TXsImageType::PixelType& xsPixel,
120  const TInternalPrecision& smoothPanchroPixel,
121  const typename TPanImageType::PixelType& sharpPanchroPixel) const
122  {
123  // Build output pixel
124  typename TOutputImageType::PixelType output(xsPixel.Size());
125 
126  TInternalPrecision scale = 1.;
127 
128  if(vcl_abs(smoothPanchroPixel) > 1e-10)
129  {
130  scale = sharpPanchroPixel/smoothPanchroPixel;
131  }
132 
133  // Perform fusion for each band with appropriate casting
134  for(unsigned int i = 0; i < xsPixel.Size(); ++i)
135  {
136  output[i] = static_cast<typename TOutputImageType::InternalPixelType>(
137  xsPixel[i] * scale);
138  }
139  // Returns the output pixel
140  return output;
141  }
142  };
143 
148  typedef itk::TernaryFunctorImageFilter<TXsImageType,
149  InternalImageType,
150  TPanImageType,
151  TOutputImageType,
153 
156  <TPanImageType,
159  TInternalPrecision> ConvolutionFilterType;
160 
163 
166 
169 
172 
175 };
176 
177 } // end namespace otb
178 
179 #ifndef OTB_MANUAL_INSTANTIATION
181 #endif
182 
183 #endif

Generated at Sat Mar 8 2014 16:18:08 for Orfeo Toolbox with doxygen 1.8.3.1