|
LBP +Adaboost训练分类器中LBP特征的计算在lbpfeatures.cpp中,部分代码
void CvLBPEvaluator::generateFeatures()
{
int offset = winSize.width + 1;
for( int x = 0; x < winSize.width; x++ )
for( int y = 0; y < winSize.height; y++ )
for( int w = 1; w <= winSize.width / 3; w++ )
for( int h = 1; h <= winSize.height / 3; h++ )
if ( (x+3*w <= winSize.width) && (y+3*h <= winSize.height) )//
features.push_back( Feature(offset, x, y, w, h ) );//
numFeatures = (int)features.size();
}
CvLBPEvaluator::Feature::Feature( int offset, int x, int y, int _blockWidth, int _blockHeight )
{
Rect tr = rect = cvRect(x, y, _blockWidth, _blockHeight);//
CV_SUM_OFFSETS( p[0], p[1], p[4], p[5], tr, offset )//
tr.x += 2*rect.width;
CV_SUM_OFFSETS( p[2], p[3], p[6], p[7], tr, offset )
tr.y +=2*rect.height;
CV_SUM_OFFSETS( p[10], p[11], p[14], p[15], tr, offset )
tr.x -= 2*rect.width;
CV_SUM_OFFSETS( p[8], p[9], p[12], p[13], tr, offset )
}
可以看出opencv是使用的3X3 MN_LBP,但是它的每个小块大小是不是递增的,从1x1,2x2.......直到达到图片大小限制,我的理解是否正确?请各位指教。
|
|