#ifndef __TEXTURE_H__
#define __TEXTURE_H__

#include "image2d.h"
#include "dset.h"
#include "gaussianmodel.h"
#include <math.h>
#include <vector>

class texture
{
 public:
  struct descriptor
  {
    double v1;
    double v2;
    double w;
  };

  texture();
  
  ~texture();
  int init( int x, int y, int r,
            image2d &vec, image2d &mag );

  int quantize( std::vector< gaussianmodel* > gmodels );

  double distance( texture &tx );

  int print();

  /// merge the descriptors of another texture
  int add( texture &tx );

  int clear();

  /// generate the data structure for em clustering
  /**
   * @param ndpts number of data points copied here
   * @param nparams number of parameters copied here
   * @return pointer to allocated memory containing data
   */
  double** getemdata( int &ndpts, int &nparams );

  int getvec( double *t );

  int getx()
  {
    return xcoor;
  }
  int gety()
  {
    return ycoor;
  }

 private:

  int addvalue( double v1, double v2,
                double d );
  unsigned int generateid(int v1, int d );

  int histbins;
  int distbins;

  int xcoor;
  int ycoor;
  int radius;
  //  dset desc;
  std::vector< double > desc;
  std::vector< descriptor > desvec;
};

#endif
