/** 
* @file FastFilter.h
* @brief standard filter functions e.g. gradient filters
* @author Erik Rodner
* @date 07/22/2008

*/
#ifndef FastFilterINCLUDE
#define FastFilterINCLUDE


namespace OBJREC {

/** @brief standard filter functions e.g. gradient filters */
class FastFilter
{
    public:

	/** calculates gradient magnitude and gradient directions quantized in a number
	 * of bins. 
	 * @param pointer to the input image
	 * @param xsize width of the image
	 * @param ysize height of the image
	 * @param gradient pointer to the destination memory for the gradient magnitude values
	 * @param dir pointer to the destination memory for the gradient direction values
	 * @param numBins number of bins used for the quantization of the gradient directions
	 * @param usesigned if set put gradient directions alpha and - alpha in the same bin
	 **/
	template <class GrayValueType, class GradientMagnitudeType, class GradientDirectionType>
	static void calcGradient ( 
			  const GrayValueType *gray, 
			  int xsize, int ysize,
			  GradientMagnitudeType *gradient, 
			  GradientDirectionType *dir, 
			  int numBins, 
			  bool usesigned );

	/** calculates gradient magnitude and gradient directions of a color image (use
	 * the channel with the maximum magnitude at each pixel).
	 * The gradient direction is quantized in a number of bins. 
	 * @param r first channel of the input image
	 * @param g second channel of the input image
	 * @param b third channel of the input image
	 * @param xsize width of the image
	 * @param ysize height of the image
	 * @param gradient pointer to the destination memory for the gradient magnitude values
	 * @param dir pointer to the destination memory for the gradient direction values
	 * @param numBins number of bins used for the quantization of the gradient directions
	 * @param usesigned if set put gradient directions alpha and - alpha in the same bin
	 **/
	template <class GrayValueType, class GradientMagnitudeType, class GradientDirectionType>
	static void calcColorGradient ( 
			  const GrayValueType *r, 
			  const GrayValueType *g, 
			  const GrayValueType *b, 
			  int xsize, int ysize,
			  GradientMagnitudeType *gradient, 
			  GradientDirectionType *dir, 
			  int numBins, 
			  bool usesigned );

	template <class SrcValueType, class DstValueType>
	static void calcGradientY ( const SrcValueType *img, int xsize, int ysize, DstValueType *d );

	template <class SrcValueType, class DstValueType>
	static void calcGradientX ( const SrcValueType *img, int xsize, int ysize, DstValueType *d );

	///lazy attempt for realizing fast histogram of oriented gradients
	///since (neg.) double values are allowed, fast filtering based on look-up tables is no longer possible
	template <class GrayValueType, class OrientedGradientHistogramType>
	static void calcOrientedGradientHistogram ( const GrayValueType *gray, 
						    int xsize, int ysize,
						    OrientedGradientHistogramType *hog, 
						    int numBins, 
						    bool usesigned );

};

} // namespace

#include "FastFilter.tcc"

#endif
