/** Author: FrancoisFleuret TODO: Write a description of your heuristic*/#include <mash/heuristic.h>usingnamespaceMash;//------------------------------------------------------------------------------// Declaration of the heuristic class//------------------------------------------------------------------------------classAverage:publicHeuristic{//_____ Construction / Destruction __________public:Average();virtual~Average();//_____ Implementation of Heuristic __________public://--------------------------------------------------------------------------// Returns the number of features this heuristic computes//// When this method is called, the 'roi_extent' attribute is initialized//--------------------------------------------------------------------------virtualunsignedintdim();//--------------------------------------------------------------------------// Called once per image, before any computation //// Pre-computes from a full image the data the heuristic will need to compute// features at any coordinates in the image//// When this method is called, the following attributes are initialized:// - roi_extent// - image//--------------------------------------------------------------------------virtualvoidprepareForImage();//--------------------------------------------------------------------------// Called once per image, after any computation //// Frees the memory allocated by the prepareForImage() method//--------------------------------------------------------------------------virtualvoidfinishForImage();//--------------------------------------------------------------------------// Called once per coordinates, before any computation//// Pre-computes the data the heuristic will need to compute features at the// given coordinates//// When this method is called, the following attributes are initialized:// - roi_extent// - image// - coordinates//--------------------------------------------------------------------------virtualvoidprepareForCoordinates();//--------------------------------------------------------------------------// Called once per coordinates, after any computation //// Frees the memory allocated by the prepareForCoordinates() method//--------------------------------------------------------------------------virtualvoidfinishForCoordinates();//--------------------------------------------------------------------------// Computes the specified feature//// When this method is called, the following attributes are initialized:// - roi_extent// - image// - coordinates//--------------------------------------------------------------------------virtualscalar_tcomputeFeature(unsignedintfeature_index);//_____ Attributes __________protected:// TODO: Declare all the attributes you'll need here};//------------------------------------------------------------------------------// Creation function of the heuristic//------------------------------------------------------------------------------extern"C"Heuristic*new_heuristic(){returnnewAverage();}/************************* CONSTRUCTION / DESTRUCTION *************************/Average::Average(){// TODO: Initialization of the attributes that doesn't depend of anything}Average::~Average(){// TODO: Cleanup of the allocated memory still remaining}/************************* IMPLEMENTATION OF Heuristic ************************/unsignedintAverage::dim(){// TODO: Implement itreturn1;}voidAverage::prepareForImage(){// TODO: Initialization of the attributes that depend of the whole image}voidAverage::finishForImage(){// TODO: Frees the memory allocated by the prepareForImage() method}voidAverage::prepareForCoordinates(){// TODO: Initialization of the attributes that depend of the coordinates}voidAverage::finishForCoordinates(){// TODO: Frees the memory allocated by the prepareForCoordinates() method}scalar_tAverage::computeFeature(unsignedintfeature_index){scalar_ts=0;byte_t**pLines=image->grayLines();for(inty=coordinates.y-roi_extent;y<=coordinates.y+roi_extent;y++){for(intx=coordinates.x-roi_extent;x<=coordinates.x+roi_extent;x++){s+=scalar_t(pLines[y][x]);}}// TODO: Implement itreturns/scalar_t((2*roi_extent+1)*(2*roi_extent+1));}