/** Author: Charles Dubout (charles.dubout@idiap.ch) * * Simple example of a heuristic: Identity. The features are a copy of the * (rgb) pixels contained in the processed region of interest. */#include <mash/heuristic.h>usingnamespaceMash;//------------------------------------------------------------------------------/// The 'Identity' heuristic class//------------------------------------------------------------------------------classIdentityHeuristic:publicHeuristic{//_____ Implementation of Heuristic __________public:virtualunsignedintdim();virtualscalar_tcomputeFeature(unsignedintfeature_index);};//------------------------------------------------------------------------------/// Creation function of the heuristic//------------------------------------------------------------------------------extern"C"Heuristic*new_heuristic(){returnnewIdentityHeuristic();}/************************* IMPLEMENTATION OF Heuristic ************************/unsignedintIdentityHeuristic::dim(){// We have has many features than pixels in the region of interest times 3unsignedintroi_size=roi_extent*2+1;returnroi_size*roi_size*3;}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;unsignedintc=feature_index%3;unsignedintx=(feature_index/3)%roi_size;unsignedinty=(feature_index/3)/roi_size;// Return the pixel value corresponding to the desired featureRGBPixel_t**pLines=image->rgbLines();if(c==0){return(scalar_t)pLines[y0+y][x0+x].r;}elseif(c==1){return(scalar_t)pLines[y0+y][x0+x].g;}else{return(scalar_t)pLines[y0+y][x0+x].b;}}