Ask Your Question
0

How can I get Back Projection matrix including numbers over 255 or decimal by calcBackProject?

asked 2013-01-27 08:30:08 -0600

Hongbo Miao gravatar image

updated 2013-01-27 11:32:12 -0600

Hi, I need to use calcBackProject and then display the exact number.

    for ( int i = 0; i < backProj.rows; ++i )
    {
        for ( int j = 0; j < backProj.cols; ++j )
        {
            cout << int(backProj.at< uchar >( i, j )) << " ";
        }
        cout << endl;
    }

But its max value is 255 because of "uchar". I tried to use

    Mat backProj( slid_.rows, slid_.cols, CV_64FC1 );

After using calcBackProject, display it

    cout << backProj.at< double >( i, j );

but it does not work.

I really need the exact numbers which are bigger than 255. I don't want to use normalize before. Can I make it by calcBackProject?

If I try to scale it down, can this Back Projection matrix includes decimal? Because I don't want that 0 exists in this matrix.

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-02-01 05:29:48 -0600

Hongbo Miao gravatar image

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 );
        }
    }
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-27 08:30:08 -0600

Seen: 443 times

Last updated: Feb 01 '13