21 #ifndef otbBayesianFusionFilter_h
22 #define otbBayesianFusionFilter_h
24 #include "itkImageToImageFilter.h"
42 template <
class TInputMultiSpectral,
class TInputMultiSpectralInterp,
class TInputPanchro,
class TOutput>
52 typedef typename TInputMultiSpectral::RealValueType
RealType;
53 typedef typename itk::VariableSizeMatrix<RealType>
MatrixType;
104 void operator()(TOutput& obs,
const TInputMultiSpectral& itkNotUsed(ms),
const TInputMultiSpectralInterp& msi,
const TInputPanchro& p)
107 obsMat.SetSize(1, obs.GetSize());
108 msiVect.SetSize(1, msi.GetSize());
109 for (
unsigned int i = 0; i < msi.GetSize(); ++i)
111 msiVect(0, i) = msi[i];
116 PanVect =
m_Beta.GetTranspose();
125 if ((obsMat.Cols() != PanVect.Cols()) || (obsMat.Rows() != PanVect.Rows()))
127 itkGenericExceptionMacro(<<
"Matrix with size (" << obsMat.Rows() <<
"," << obsMat.Cols() <<
") cannot be subtracted from matrix with size ("
128 << PanVect.Rows() <<
"," << PanVect.Cols() <<
" )");
132 for (
unsigned int r = 0; r < obsMat.Rows(); ++r)
134 for (
unsigned int c = 0; c < obsMat.Cols(); ++c)
136 obsMat(r, c) += PanVect(r, c);
141 for (
unsigned int i = 0; i < obs.GetSize(); ++i)
143 obs[i] =
static_cast<typename TOutput::ValueType
>(obsMat(0U, i));
148 constexpr
size_t OutputSize(
const std::array<size_t, 3> inputsNbBands)
const
150 return inputsNbBands[1];
194 template <
class TInputMultiSpectralImage,
class TInputMultiSpectralInterpImage,
class TInputPanchroImage,
class TOutputImage>
196 :
public FunctorImageFilter<Functor::BayesianFunctor<typename TInputMultiSpectralImage::PixelType, typename TInputMultiSpectralInterpImage::PixelType,
197 typename TInputPanchroImage::PixelType, typename TOutputImage::PixelType>>
201 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputMultiSpectralImage::ImageDimension);
202 itkStaticConstMacro(OutputImageDimension,
unsigned int, TOutputImage::ImageDimension);
214 typename TInputPanchroImage::PixelType,
typename TOutputImage::PixelType>;
244 typedef typename InputMultiSpectralImageType::SizeType
SizeType;
254 this->
template SetInput<0>(multiSpect);
259 this->
template SetInput<1>(multiSpectInterp);
264 this->
template SetInput<2>(panchro);
269 return this->
template GetInput<0>();
274 return this->
template GetInput<1>();
279 return this->
template GetInput<2>();
283 itkSetMacro(Lambda,
float);
286 itkGetConstReferenceMacro(Lambda,
float);
289 itkSetMacro(Beta, MatrixType);
292 itkGetConstReferenceMacro(Beta, MatrixType);
295 itkSetMacro(CovarianceMatrix, MatrixType);
298 itkGetConstReferenceMacro(CovarianceMatrix, MatrixType);
301 itkSetMacro(CovarianceInvMatrix, MatrixType);
304 itkGetConstReferenceMacro(CovarianceInvMatrix, MatrixType);
307 itkSetMacro(Vcondopt, MatrixType);
310 itkGetConstReferenceMacro(Vcondopt, MatrixType);
313 itkSetMacro(S,
float);
316 itkGetConstReferenceMacro(S,
float);
323 m_StatisticsHaveBeenGenerated =
false;
328 void BeforeThreadedGenerateData()
override;
331 void ComputeInternalStatistics(
void);
335 void Modified(
void)
const override;
360 #ifndef OTB_MANUAL_INSTANTIATION