title: difference between cvCalcHist and calcHist
body: <p>I'm trying to understand the difference between the <code>cvCalcHist</code>, the method to compute the histogram of an image in <code>openCV c version</code> and <code>calcHist</code>, the method to compute the histogram of an image in <code>openCV c++ version</code>.</p>
  
  <p><code>openCV c version code:</code></p>
  
  <pre><code>    // load the color image
      IplImage* im = cvLoadImage("2.png");
  
      // get the color histogram
      IplImage* im32f = cvCreateImage(cvGetSize(im), IPL_DEPTH_32F, 3);
      cvConvertScale(im, im32f);
  
      int histSize[] = {32, 32, 32};
      float rgbRange[] = {0, 256};
      float* ranges[] = {rgbRange, rgbRange, rgbRange};
  
      CvHistogram* hist = cvCreateHist(3, histSize, CV_HIST_ARRAY, ranges);
      IplImage* b = cvCreateImage(cvGetSize(im32f), IPL_DEPTH_32F, 1);
      IplImage* g = cvCreateImage(cvGetSize(im32f), IPL_DEPTH_32F, 1);
      IplImage* r = cvCreateImage(cvGetSize(im32f), IPL_DEPTH_32F, 1);
  
      cvSplit(im32f, b, g, r, NULL);
      IplImage* planes[] = {b, g, r};
      cvCalcHist(planes, hist);
  
      // find min and max values of histogram bins
      float minval, maxval;
      cvGetMinMaxHistValue(hist, &amp;minval, &amp;maxval);
      cout &lt;&lt; "Min : " &lt;&lt; minval &lt;&lt; " / Max : " &lt;&lt; maxval &lt;&lt; endl;
  
      //OUTPUT: Min : 0 / Max : 177617 
  </code></pre>
  
  <p><code>openCV c++ version code:</code></p>
  
  <pre><code>    const int channels[] = {0, 1, 2};
      const int histSize[] = {32, 32, 32};
      const float rgbRange[] = {0, 256};
      const float* ranges[] = {rgbRange, rgbRange, rgbRange};
      Mat im = imread("2.png",IMREAD_COLOR);
      MatND hist;
      Mat im32fc3, backpr32f(im.cols, im.rows, CV_32F), backpr8u(im.cols, im.rows, CV_8U), backprBw;
      im.convertTo(im32fc3, CV_32F);
  
      // compute histogram, scale it to 0-255 range and backproject
      calcHist( &amp;im32fc3, 1, channels, Mat(), hist, 1, histSize, ranges, true, false);
      // find min and max values of histogram bins
      double minval, maxval;
      cv::minMaxIdx(hist, &amp;minval, &amp;maxval);
      cout &lt;&lt; "Min : " &lt;&lt; minval &lt;&lt; " / Max : " &lt;&lt; maxval &lt;&lt; endl;
  
      //OUTPUT: Min : 455 / Max : 476732
  </code></pre>
  
  <p>As you can see in the <code>//OUTPUT</code> comments in the code sections above, the values are different between the 2 pieces of code where I think I should get the same result. Any clue what is happening?</p>