/** Author: Kanma This heuristic produces a 'blobbed' version of the (RGB) region of interest. The computation of the blobs is done by segmenting the RGB space in 512 discrete values (each channel range is segmented in 8).*/#include <mash/heuristic.h>#include <memory.h>usingnamespaceMash;//------------------------------------------------------------------------------// Declaration of the heuristic class//------------------------------------------------------------------------------classBlobsHeuristic:publicHeuristic{//_____ Construction / Destruction __________public:BlobsHeuristic();virtual~BlobsHeuristic();//_____ Implementation of Heuristic __________public:virtualunsignedintdim();virtualscalar_tcomputeFeature(unsignedintfeature_index);//_____ Attributes __________protected:byte_t_lookup[256];};//------------------------------------------------------------------------------// Creation function of the heuristic//------------------------------------------------------------------------------extern"C"Heuristic*new_heuristic(){returnnewBlobsHeuristic();}/************************* CONSTRUCTION / DESTRUCTION *************************/BlobsHeuristic::BlobsHeuristic(){for(unsignedinti=0;i<256;++i)_lookup[i]=i/32;}BlobsHeuristic::~BlobsHeuristic(){}/************************* IMPLEMENTATION OF Heuristic ************************/unsignedintBlobsHeuristic::dim(){// We have has many features than pixels in the region of interestunsignedintroi_size=roi_extent*2+1;returnroi_size*roi_size;}scalar_tBlobsHeuristic::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 blobbed value of the pixel corresponding to the desired featureRGBPixel_tpixel=image->rgbLines()[y0+y][x0+x];return(scalar_t)_lookup[pixel.r]+_lookup[pixel.g]*8+_lookup[pixel.b]*64;}