/** 
* @file Image_tools.h
* @author Alexander Lütz
* @date 18/11/2010
* @brief Contains tools for Image_Processing
*/
#ifndef _NICE_OBJREC_IMAGETOOLS
#define _NICE_OBJREC_IMAGETOOLS

#include "core/image/ImageT.h"
#include "core/image/ColorImageT.h"
// #include "core/image/Filter.h"
#include <utility>

namespace OBJREC {
class Image_tools 
{

    protected:

    public:

	/** simple constructor */
	Image_tools();

	/** simple destructor */
	~Image_tools();


	/** calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing*/
	void calculateGradients(const NICE::Image & origImage, NICE::ImageT<float> & grad_x_Image, NICE::ImageT<float> & grad_y_Image );
	/** calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing, considering the chanel with the greatest magnitude als resulting gradient*/
	void calculateGradients(NICE::ColorImage origColorImage, NICE::ImageT<float> & grad_x_Image, NICE::ImageT<float> & grad_y_Image );

	/** calculate gradient-orientations*/
	void calculateGradientOrientations(const NICE::ImageT<float> & grad_x_Image, const NICE::ImageT<float> & grad_y_Image , const int & number_Of_Bins, NICE::Image & gradient_orientations, const bool unsignedBins=true);

	void calculateGradientOrientations(const NICE::GrayImage16s & grad_x_Image, const NICE::GrayImage16s & grad_y_Image , const int & number_Of_Bins, NICE::Image & gradient_orientations, const bool unsignedBins=true);

	/** calculate gradient-magnitudes*/
	void calculateGradientMagnitudes(const NICE::ImageT<float>  & grad_x_Image, const NICE::ImageT<float> & grad_y_Image, NICE::ImageT<float> & gradient_magnitudes);

	/** Normalizes the descriptor-vector of the specified block, using L2-norm*/
	std::vector<float> normalizeBlockDescriptor(const std::vector<float> & orig_Block_Descriptor, const float epsilon = 0.01);

	/** calculates the resulting HoG-Features for an image by normalizing spatial blocks und storing the resulting normalized histograms in a vector - not implemented up to now*/
	std::vector< std::vector<float> > calculateResultingHogFeatures(const NICE::Image & gradient_orientations, const NICE::ImageT<float> & gradient_magnitudes, const int & blocksize = 2, const int & cellsize = 8);
};
}

#endif