title: How to use OpenCV's histogram?
body: <p>I'm struggling with taking the histogram of floating point data in OpenCV:</p>
  
  <pre><code>cv::ocl::setUseOpenCL(true);
  auto rows = 2048;
  auto cols = 2064;
  auto input_d = cv::UMat(rows, cols, CV_32F, cv::USAGE_ALLOCATE_DEVICE_MEMORY);
  cv::UMat hist_d;
  cv::randn(input_d, 0, 0.5);
  std::vector&lt;int&gt; channels = { 0 };
  std::vector&lt;int&gt; histSize = { 256 };
  std::vector&lt;float&gt; ranges = { 0, 1 };//run the histogram to track values 0 to 1
  cv::calcHist(input_d, channels, cv::UMat(), hist_d, histSize, ranges, false);
  </code></pre>
  
  <p>I'm getting an error like:</p>
  
  <pre><code>OpenCV Error: Assertion failed (0 &lt;= _rowRange.start &amp;&amp; _rowRange.start &lt;= _rowRange.end &amp;&amp; _rowRange.end &lt;= m.rows) in cv::Mat::Mat, file src\matrix.cpp, line 452
  </code></pre>
  
  <p>Anybody know how to use this function?</p>
  
  <p>The following code works, but the computation doesn't happen on the GPU</p>
  
  <pre><code>auto rows = 2048;
  auto cols = 2064;
  auto input_d = cv::Mat(rows, cols, CV_32F);
  cv::MatND hist_d;
  cv::randn(input_d, 0, 0.5);
  int histSize[1] = { 256 };
  float hranges[2] = { 0.0, 256.0 };
  const float*  range[1] = { hranges };
  int channels[1] = { 0 };
  cv::calcHist(&amp;input_d, 1, channels, cv::Mat(), hist_d, 1, histSize, range);
  </code></pre>
  
  <p>I suspect that foo should not be size zero, but I don't understand whats going on.</p>
  
  <pre><code>cv::InputArray&amp; foo = input_d;
  cv::calcHist(foo, channels, cv::UMat(), hist_d, histSize, ranges, false);
  </code></pre>