#include "vislearning/features/regionfeatures/RFColor.h" #include using namespace OBJREC; using namespace std; using namespace NICE; RFColor::RFColor( const Config *_conf, const LocalFeature *_lf ):RegionFeatures(_conf) { lf = _lf; } void RFColor::extract ( const NICE::Image & img, const RegionGraph &rg, const NICE::Matrix &mask, VVector & feats ) { fprintf (stderr, "RFColor::extract: please use ColorImage instead of GrayImage. This are Colorfeatures!!\n"); exit(-1); } void RFColor::extractRGB ( const NICE::ColorImage & cimg, const RegionGraph &rg, const NICE::Matrix &mask, VVector & feats ) { int rgcount = rg.size(); vector > means; for(int i = 0; i < 3; i ++) { vector m(rgcount,0); means.push_back(m); } for(int y = 0; y < cimg.height(); y++) { for(int x = 0; x < cimg.width(); x++) { int pos = mask(x,y); for(int i = 0; i < 3; i++) { means[i][(int)pos] += cimg.getPixel(x,y,i); } } } ColorImage tmp(rgcount, 1); VVector positions; for(int j = 0; j < rgcount; j++) { for(int i = 0; i < 3; i++) { tmp.setPixel(j,0,i,(int)((double)means[i][j]/(double)rg[j]->getSize())); } Vector vec(2); vec[0] = j; vec[1] = 0; positions.push_back(vec); } lf->getDescriptors(tmp, positions, feats); } RFColor::~RFColor() { }