#ifndef _INTEGRAL_H_
#define _INTEGRAL_H_
/**
 * \file integral.h
 * \brief a header for integral.c
 *
 *
 *  \ingroup corefiles
 * \date Jul 10, 2009
 * \author Alexander Pimenov
 */
#ifdef __cplusplus
	extern "C" {
#endif


#include <stdint.h>
#include "g12buffer.h"

/**
 * \brief This buffer holds the integral image
 *
 * For an input grayscale buffer the integral image for each point (x,y)
 * will hold the sum_{i=0}^x sum_{j=0}^y GELEM(i,j). This allows to compute the sum
 * of all the elements of the input image inside the arbitrary rectangle in 4 random acesses to the
 * integral image
 */
typedef struct integralBuffer_tag {
	int h;              /**< \brief Height of the buffer */
	int w;              /**< \brief Width of the buffer */
	uint32_t *data;		/**< \brief buffer data*/
} integralBuffer;

integralBuffer *integralBufferCreate(int h, int w);
void integralBufferDelete(integralBuffer *toDelete);
integralBuffer *integralBufferCreateFromG12(G12Buffer *src);
uint32_t getRectangleValue(integralBuffer *buf, int y1, int x1, int y2, int x2);

#ifdef __cplusplus
	} // 	extern "C"
#endif
#endif
