#ifndef __MUTUALINFORMATION_H__
#define __MUTUALINFORMATION_H__
#define MISTEP 1
#include <fftw3.h> 
#include "image2d.h"
#include "matrix.h"
#include <set>
#include <map>
#define MIPMFSZ 32

/// class to calculate mutualinformation of two image
class mutualinformation
{
 public:

  mutualinformation();
  ~mutualinformation();

  double miscore( image2d &A, image2d &B,
                  image2d &mapa, image2d &mapb, 
                  int xoff, int yoff );

  double miscore( image2d &A, image2d &B,
                  int xoff, int yoff );

 private:
  /// calculate the pmf of an image
  /**
   * calculates pmf of box 
   * [0, swidth], [im.height, send]
   * @param hist histrogram to store
   * @param im image to calculate
   */
  int calcpmf( double *hist, subimage &im );
  int calcpmf( double *hist, subimage &im, image2d &map );

  /// calculates joint pmf with respect to offset
  int calcjpmf(double *hist, subimage &A,
               subimage &B);
  int calcjpmf(double *hist, subimage &A,
               subimage &B, image2d &map);

  double *ahist, *bhist;
  double *jhist;

};

#endif
