Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Finally, I wrote my own function to get Back Projection. Hope it can help you who have same problem.

float ReadValueFromHist( const Mat& hist, const int x, const int y ) const
{
    int indexAlpha = int( mat.at< Vec4b >( x, y )[ 3 ] ) * bins / 256;
    return hist.at< float >( indexAlpha, 0 );
}

void CalcBackProj()
{
    backProj = Mat( mat.rows, mat.cols, CV_32FC1);
    for ( int i = 0; i < mat.rows; ++i )
    {
        for ( int j = 0; j < mat.cols; ++j )
        {
            backProj.at< float >( i, j ) = ReadValueFromHist( hist, i, j );
        }
    }
}