Ask Your Question

# How can I get Back Projection matrix including numbers over 255 or decimal by calcBackProject? 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 close merge delete

## 1 answer

Sort by » oldest newest most voted 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 );
}
}
}

more

Official site

GitHub

Wiki

Documentation

## Stats

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

Seen: 310 times

Last updated: Feb 01 '13
{"ft_lang_label":"__label__en","ft_lang_prob":0.8303794,"math_prob":0.7625829,"size":800,"snap":"2021-04-2021-17","text_gpt3_token_len":218,"char_repetition_ratio":0.13693467,"word_repetition_ratio":0.0,"special_character_ratio":0.305,"punctuation_ratio":0.18343195,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96463126,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-15T17:37:54Z\",\"WARC-Record-ID\":\"<urn:uuid:603a61b3-3c06-43f7-bfda-8ec156c0c51d>\",\"Content-Length\":\"53285\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:09147e08-ad9c-4195-9bf6-42c145cf34ea>\",\"WARC-Concurrent-To\":\"<urn:uuid:f4771e2a-2e9b-4e15-9291-d72172f6db7d>\",\"WARC-IP-Address\":\"5.9.49.245\",\"WARC-Target-URI\":\"https://answers.opencv.org/question/6546/how-can-i-get-back-projection-matrix-including-numbers-over-255-or-decimal-by-calcbackproject/\",\"WARC-Payload-Digest\":\"sha1:AB5MYA6BFUBNVZYJKICLBLOMKPP76X6C\",\"WARC-Block-Digest\":\"sha1:AAP46WB5ZIHA3GTBELOCWGS2F6655HVU\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038087714.38_warc_CC-MAIN-20210415160727-20210415190727-00516.warc.gz\"}"}