#ifndef __SCALESPACE_H__
#define __SCALESPACE_H__

#include "image2d.h"
#include <math.h>
#include <iostream>
#include <string.h>
#include <vector>

class scalespace
{
 public:
  struct scales
  {
    image2d *im;
    double k;
  };
  struct feature
  {
    int x;
    int y;
    double scale;
  };
  scalespace();
  ~scalespace();

  int analyze( image2d &imin, double sig );

  int getscales( std::vector< scales* > &s );
  int getfeatures( std::vector< feature > &f );

  int clear();

#ifndef _NOMAGICK_
  int print( Magick::Image &im );
#endif

 private:

  struct imagescale
  {
    image2d im;
    image2d dxx;
    image2d dxy;
    image2d dyx;
    image2d dyy;
  };

  int findextrema();

  int hessian( image2d &in, image2d &dxx, 
               image2d &dyy, image2d &dxy,
               image2d &dyx);

  int checkedge( int x, int y );

  int filter();

  int dximage( image2d &in, image2d &out );
  int dyimage( image2d &in, image2d &out );

  double sigma;
  image2d myscales[9];
  imagescale dog[8];
  image2d ssf;
};

#endif
