CByteImage HOGFeatureExtractor::render(const Feature& f) const { CShape cellShape = _oriMarkers[0].Shape(); CFloatImage hogImgF(CShape(cellShape.width * f.Shape().width, cellShape.height * f.Shape().height, 1)); hogImgF.ClearPixels(); float minBinValue, maxBinValue; f.getRangeOfValues(minBinValue, maxBinValue); // For every cell in the HOG for(int hi = 0; hi < f.Shape().height; hi++) { for(int hj = 0; hj < f.Shape().width; hj++) { // Now _oriMarkers, multiplying contribution by bin level for(int hc = 0; hc < _nAngularBins; hc++) { float v = f.Pixel(hj, hi, hc) / maxBinValue; for(int ci = 0; ci < cellShape.height; ci++) { float* cellIt = (float*) _oriMarkers[hc].PixelAddress(0, ci, 0); float* hogIt = (float*) hogImgF.PixelAddress(hj * cellShape.height, hi * cellShape.height + ci, 0); for(int cj = 0; cj < cellShape.width; cj++, hogIt++, cellIt++) { (*hogIt) += v * (*cellIt); } } } } } CByteImage hogImg; TypeConvert(hogImgF, hogImg); return hogImg; }
CByteImage FeatureExtractor::render(const Feature& f, bool normalizeFeat) const { if(normalizeFeat) { CShape shape = f.Shape(); Feature fAux(shape); float fMin, fMax; f.getRangeOfValues(fMin, fMax); for(int y = 0; y < shape.height; y++) { float* fIt = (float*) f.PixelAddress(0,y,0); float* fAuxIt = (float*) fAux.PixelAddress(0,y,0); for(int x = 0; x < shape.width * shape.nBands; x++, fAuxIt++, fIt++) { *fAuxIt = (*fIt) / fMax; } } return this->render(fAux); } else { return this->render(f); } }