/* @file  pmTrend2D.h
 *
 * functions to represent ways of modeling a 2D trend
 *
 * @author EAM, IfA
 *
 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
 * @date $Date: 2007-09-20 19:21:32 $
 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */

# ifndef PM_TREND_2D_H
# define PM_TREND_2d_H

/// @addtogroup Objects Object Detection / Analysis Functions
/// @{

typedef enum {
    PM_TREND_POLY_ORD,
    PM_TREND_POLY_CHEB,
    PM_TREND_MAP,
} pmTrend2DMode;

typedef struct {
    psPolynomial2D *poly;
    psImageMap *map;
    psStats *stats;
    pmTrend2DMode mode; // POLY_ORD, POLY_CHEB, MAP
} pmTrend2D;

// allocate a pmTrend2D structure tied to an image dimensions.  nXtrend,nYtrend is the order for the polynomials, max number of grid cells for
// psImageMap
pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, psImage *image, int nXtrend, int nYtrend, psStats *stats);

// allocate a pmTrend2D tied to an abstract field with size nXfield,nYfield 
pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats);

bool pmTrend2DFit (pmTrend2D *trend, psVector *mask, psMaskType maskVal, psVector *x, psVector *y, psVector *f, psVector *df);

double pmTrend2DEval (pmTrend2D *trend, float x, float y);
psVector *pmTrend2DEvalVector (pmTrend2D *trend, psVector *x, psVector *y);

/// @}
# endif
