21 #ifndef otbJoinHistogramMI_h
22 #define otbJoinHistogramMI_h
24 #include "itkHistogram.h"
32 template <
class TInput1,
class TInput2,
class TOutput>
37 typedef typename itk::Statistics::Histogram<HistogramFrequencyType, itk::Statistics::DenseFrequencyContainer2>
HistogramType;
46 TOutput jointEntropy = itk::NumericTraits<TOutput>::Zero;
49 typename HistogramType::MeasurementVectorType sample(2);
50 for (
unsigned long pos = 0; pos < itA.Size(); ++pos)
52 double valueA =
static_cast<double>(itA.GetPixel(pos));
53 double valueB =
static_cast<double>(itB.GetPixel(pos));
58 typename HistogramType::IndexType index;
59 histogram->GetIndex(sample, index);
63 jointEntropy += freq * std::log(freq);
67 jointEntropy = -jointEntropy /
static_cast<TOutput
>(totalFreq) + std::log(totalFreq);