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);
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
Bayesian fusion filter. Contribution of Julien Radoux.
TOutputImage OutputImageType
InputMultiSpectralInterpImageType::InternalPixelType InputMultiSpectralInterpInternalPixelType
OutputImageType::PixelType OutputPixelType
void SetMultiSpectInterp(const InputMultiSpectralInterpImageType *multiSpectInterp)
StreamingStatisticsVectorImageFilter< InputMultiSpectralInterpImageType > StreamingStatisticsVectorImageFilterType
FunctorImageFilter< BayesianFunctorType > Superclass
OutputImageType::RegionType OutputImageRegionType
itk::NumericTraits< InputPanchroPixelType >::RealType InputPanchroRealType
InputMultiSpectralInterpImageType::PixelType InputMultiSpectralInterpPixelType
InputMultiSpectralInterpImageType::RegionType InputMultiSpectralInterpImageRegionType
InputPanchroImageType::RegionType InputPanchroImageRegionType
InputMultiSpectralImageType::InternalPixelType InputMultiSpectralInternalPixelType
void SetPanchro(const InputPanchroImageType *panchro)
const InputPanchroImageType * GetPanchro()
TInputMultiSpectralImage InputMultiSpectralImageType
itk::SmartPointer< const Self > ConstPointer
MatrixType m_CovarianceInvMatrix
~BayesianFusionFilter() override
ImageToVectorImageCastFilter< InputPanchroImageType, InputMultiSpectralImageType > CasterType
InputMultiSpectralImageType::SizeType SizeType
InputMultiSpectralImageType::RegionType InputMultiSpectralImageRegionType
const InputMultiSpectralInterpImageType * GetMultiSpectInterp()
itk::NumericTraits< InputMultiSpectralInterpInternalPixelType >::RealType InputMultiSpectralInterpRealType
void SetMultiSpect(const InputMultiSpectralImageType *multiSpect)
itk::NumericTraits< InputMultiSpectralInternalPixelType >::RealType InputMultiSpectralRealType
StreamingMatrixTransposeMatrixImageFilter< InputMultiSpectralImageType, InputMultiSpectralImageType > MSTransposeMSType
StreamingStatisticsVectorImageFilterType::MatrixType MatrixType
BayesianFusionFilter Self
TInputMultiSpectralInterpImage InputMultiSpectralInterpImageType
OutputImageType::InternalPixelType OutputInternalPixelType
InputMultiSpectralImageType::PixelType InputMultiSpectralPixelType
itk::SmartPointer< Self > Pointer
const InputMultiSpectralImageType * GetMultiSpect()
TInputPanchroImage InputPanchroImageType
bool m_StatisticsHaveBeenGenerated
MatrixType m_CovarianceMatrix
InputPanchroImageType::PixelType InputPanchroPixelType
A generic functor filter templated by its functor.
Functor for the bayesian fusion filter. Please refer to BayesianFusionFilter.
itk::VariableSizeMatrix< RealType > MatrixType
void SetLambda(float lambda)
MatrixType m_CovarianceInvMatrix
void SetCovarianceInvMatrix(MatrixType matrix)
void SetBeta(MatrixType matrix)
virtual ~BayesianFunctor()
TInputMultiSpectral::RealValueType RealType
void SetVcondopt(MatrixType matrix)
void operator()(TOutput &obs, const TInputMultiSpectral &, const TInputMultiSpectralInterp &msi, const TInputPanchro &p)
void SetAlpha(float alpha)
constexpr vcl_size_t OutputSize(const std::array< vcl_size_t, 3 > inputsNbBands) const
MatrixType GetCovarianceInvMatrix()
This is a helper class that convert an otb::Image into a single-channel otb::VectorImage.
This class streams the whole input image through the PersistentMatrixTransposeMatrixImageFilter.
This class streams the whole input image through the PersistentStatisticsImageFilter.
StatFilterType::MatrixType MatrixType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.