/** Author: Philip Abbet (philip.abbet@idiap.ch) Simple example of a heuristic: Identity. The features are a copy of the (grayscale) pixels contained in the processed region of interest.*/#include <mash/heuristic.h>usingnamespaceMash;//------------------------------------------------------------------------------/// The 'Identity' heuristic class//------------------------------------------------------------------------------classIdentityHeuristic:publicHeuristic{//_____ Construction / Destruction __________public:IdentityHeuristic();virtual~IdentityHeuristic();//_____ Implementation of Heuristic __________public:virtualunsignedintdim();virtualscalar_tcomputeFeature(unsignedintfeature_index);};//------------------------------------------------------------------------------/// Creation function of the heuristic//------------------------------------------------------------------------------extern"C"Heuristic*new_heuristic(){returnnewIdentityHeuristic();}/************************* CONSTRUCTION / DESTRUCTION *************************/IdentityHeuristic::IdentityHeuristic(){}IdentityHeuristic::~IdentityHeuristic(){}/************************* IMPLEMENTATION OF Heuristic ************************/unsignedintIdentityHeuristic::dim(){// We have has many features than pixels in the region of interestunsignedintroi_size=roi_extent*2+1;returnroi_size*roi_size;}scalar_tIdentityHeuristic::computeFeature(unsignedintfeature_index){// Compute the coordinates of the top-left pixel of the region of interestunsignedintx0=coordinates.x-roi_extent;unsignedinty0=coordinates.y-roi_extent;// Compute the coordinates of the pixel corresponding to the feature, in// the region of interestunsignedintroi_size=roi_extent*2+1;unsignedintx=feature_index%roi_size;unsignedinty=(feature_index-x)/roi_size;// Return the pixel value corresponding to the desired featurebyte_t**pLines=image->grayLines();return(scalar_t)pLines[y0+y][x0+x];}