Access histogram data
Hello,
How do I extract actual histogram data (bin value)?. I am a bit confused, because after computing a histogram with cv::calcHist, the matrix size (rows, cols) appears to be -1,-1. However, the cv::compareHist seems to correctly tell that similar images have a small CHI2 distance, and different images have a large CHI2 value.
int bins = 4;
int histSize[] = {bins, bins, bins};
float rranges[] = { 0, 255 }, granges[] = { 0, 255 }, branges[] = { 0, 255 };
const float* ranges[] = { rranges, granges, branges };
int channels[] = {0, 1, 2};
cv::calcHist( &im, 1, channels, mask, hist, 3, histSize, ranges, true, false );
Thanks
@berak, yes, I updated the question with the code I am using to compute the histograms
since rows and cols only make sense for a 2d matrix, for higher dimensions you query the Mat.size member (not the function!). so hist.size[0] == hist.size[1] == hist.size[2] == 4;
(again, rows==-1 and cols==-1 is ok in your case)
I see... But then, how would it be the use of Mat::at method here? Or is it mandatory to use NAryMatIterator to get the histogram bin data?