# Understanding the official histogram tutorial

Hi,

Im following the online documentation of opencv 2.4 to learn it. I am at histogram calculation and found a section that was not commented and not explained at all.

The section I am talking about is point number 5, which I have pasted below:

// Draw the histograms for R, G and B
int hist_w = 512; int hist_h = 400;
int bin_w = cvRound( (double) hist_w/histSize );

Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );


The tutorial does not state what hist_w and hist_h are and why are they given these values? Also why was a circle detecting function (cvRound) used here and no comment on its function.

Can some one please address these issues, I have spent way too long on the histogram section.

Thank you

edit retag close merge delete

Sort by ยป oldest newest most voted

The code section you pasted here has absolutely nothing to do with histogram computation. Nor does cvRound have anything to do with circle detection.

The code is not explained, because it is pretty self-explanatory. Maybe you should consider having a look at the OpenCV reference to find out, what cvRound actually does. Seriously... did you think the method would detect a circle within a double???

Mat histImage is just an image (as one could suggest from the variable name), which is used to display the histogram. Have a look again at the reference (notably at the Mat constructors). You should be able to find out, what hist_w and hist_h might signify.

more

Yes sorry, I had mistaken the cvRound function for the void Circle() function.. dont know why.. That was the reason I did not understand it. You are right about the histimage and it is a declaration of a function later used in the line function.. Also you did not have to be so harsh, as I was saying I am learning this and its normal for me to confuse two functions..

( 2012-10-18 17:20:15 -0500 )edit

Official site

GitHub

Wiki

Documentation