#if !defined(PS_CONVOLVE_H)
#define PS_CONVOLVE_H

/** \file psConvolve.h
 *  \brief Convolution functions
 *  \ingroup MathGroup
 */


/**** Convolution ****/

/** A convolution kernel */
typedef struct {
    psImage *data;                      ///< Kernel data, in the form of an image
    int xMin, yMin;                     ///< Most negative indices
    int xMax, yMax;                     ///< Most positive indices
    float **kernelRows;                 ///< Pointer to the rows of the kernel data
    float **kernel;                     ///< Pointer to the kernel data
} psKernel;



/** Functions **************************************************************/
/** \addtogroup MathGroup Math Utilities
 *  \{
 */


/** Constructor */
psKernel *psKernelAlloc(int xMin,	///< Size of the kernel in the negative x direction
			int xMax,	///< Size of the kernel in the positive x direction
			int yMin,	///< Size of the kernel in the negative y direction
			int yMax	///< Size of the kernel in the positive y direction
			);

/** Returns the kernel of OT shifts made during the course of the exposure. */
psKernel *psKernelGenerate(const psVector *xShifts, ///< List of OT shifts in x; integers
			   const psVector *yShifts ///< List of OT shifts in y; integers;
						   ///< xshifts->n == yShifts->n
    );

/** Returns an image that is the result of convolving the input image with the specified kernel. */
psImage *psImageConvolve(psImage *out,	///< Output image, or NULL
			 const psImage *in, ///< Input image to be convolved
			 const psKernel *kernel, ///< Kernel by which to convolve
			 bool direct	///< Do direct convolution?  If not, use FFT
    );


/* \} */ // End of MathGroup Functions

#endif
