Histogram calculation, wrong example (Bug #1507)


Added by miguelnp - over 13 years ago. Updated about 13 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Alexander Shishkov % Done:

0%

Category:documentation
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

In histogram calculation ("it shows red and blue histograms interchanged. Lines 36, 37 and 38 are like this:

calcHist( &rgb_planes[0":http://opencv.itseez.com/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html#code])~ 1, 0, Mat(), r_hist, 1, &histSize, &histRange, uniform, accumulate );
calcHist( &rgb_planesr1, 1, 0, Mat(), g_hist, 1, &histSize, &histRange, uniform, accumulate );
calcHist( &rgb_planesr2, 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

and they should be
calcHist( &rgb_planesr2, 1, 0, Mat(), r_hist, 1, &histSize, &histRange, uniform, accumulate );
calcHist( &rgb_planesr1, 1, 0, Mat(), g_hist, 1, &histSize, &histRange, uniform, accumulate );
calcHist( &rgb_planesr0, 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

in order to follow the Blue-Green-Red Mat images order.
Furthermore (and I haven't yet targeted the problem), it shows an incomplete histogram. Intensity values over 200 aproximately aren't shown.

Associated revisions

Revision 1494da33
Added by Alexander Shishkov about 13 years ago

fixed #1507

Revision 88419f89
Added by Andrey Pavlenko over 11 years ago

Merge pull request #1507 from pengx17:2.4_fix_test

History

Updated by miguelnp - over 13 years ago

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

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

because the Mat constructor used here is
Mat(int rows, int cols, int type, const Scalar& s)

(note that the number of rows of a Mat object is equal to its height and the number of columns of a Mat object is equal to its width)
Also, if you use hist_w as the width, it will only show, like I said before, the intensity values from 0 to 199. When changing here hist_w by 510 (2*255) the histogram is fully plotted

Updated by Alexander Shishkov about 13 years ago

  • Status deleted (Open)
  • Target version set to 2.4.0
  • Assignee changed from miguelnp - to Alexander Shishkov

Updated by Alexander Shishkov about 13 years ago

Thanks for the report!
Problems are fixed in r7443.

  • Status set to Done

Also available in: Atom PDF