Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
// 1. just return a Mat, not a vector<float>
Mat spatialhist::spatialHistogramforknnorsvm( const Mat& lbpImage, const Size& grid)
{
    Mat histograms; // 2. start with an *empty* one, push_back the items later
    int width=lbpImage.cols/grid.width;
    int height=lbpImage.rows/grid.height;
    int cnt=0;
    //#pragma omp parallel for  // 3. dear, make it run, then make fast. in exactly that order ;)
    for(int i=0;i<grid.height;i++)
    {
        for(int j=0;j<grid.width;j++)
        {
            Mat cell=lbpImage(Rect(j*width,i*height,width,height));
            Mat cell_hist=computeHistogram(cell);
            histograms.push_back(cell_hist);
            // 4. you're already done here.
        }
    }
    return histograms.reshape(1,1); // all in one row now
}
// 1. just return a Mat, not a vector<float>
Mat spatialhist::spatialHistogramforknnorsvm( const Mat& lbpImage, const Size& grid)
{
    Mat histograms; // 2. start with an *empty* one, push_back the items later
    int width=lbpImage.cols/grid.width;
    int height=lbpImage.rows/grid.height;
    int cnt=0;
    //#pragma omp parallel for  // 3. dear, make it run, then make it fast. in exactly that order ;)
    for(int i=0;i<grid.height;i++)
    {
        for(int j=0;j<grid.width;j++)
        {
            Mat cell=lbpImage(Rect(j*width,i*height,width,height));
            Mat cell_hist=computeHistogram(cell);
            histograms.push_back(cell_hist);
            // 4. you're already done here.
        }
    }
    return histograms.reshape(1,1); // all in one row now
}