【问题标题】:Draw Histogram of depth image?绘制深度图像的直方图?
【发布时间】:2013-07-18 09:16:56
【问题描述】:

我正在处理来自 kinect 的深度图像。我想计算深度图像的直方图,a/f:

     Mat depth; //(take from kinect sdk)

   int histSize = 64;

 // Set the ranges ( for B,G,R) )

  float range[] = { 0, 256 } ;

   const float* histRange = { range };

    bool uniform = true; bool accumulate = false;

    Mat depth_hist;

   // Compute the histograms:

  calcHist( &depth, 1, 0, Mat(), depth_hist, 1, &histSize, &histRange, uniform, accumulate );

 // Draw the histograms for depth

   int hist_w = 320; int hist_h = 240;

   int bin_w = cvRound( (double) hist_w/histSize );

   Mat histImage( hist_h, hist_w, CV_8UC1, 1 );

   // Normalize the result to [ 0, histImage.rows ]

    normalize(depth_hist, depth_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );

     // Draw for each channel
  for( int i = 1; i < histSize; i++ )
          {
  line( histImage, Point( bin_w*(i-1), hist_h - cvRound(depth_hist.at<float>(i-1)) ) ,
                   Point( bin_w*(i), hist_h - cvRound(depth_hist.at<float>(i)) ),
                   Scalar( 255), 2, 8, 0  );
  }

 // Display
 namedWindow("calcHist Demo", WINDOW_AUTOSIZE );
 imshow("calcHist Demo", histImage );

但是,它不起作用:(。我将此代码用于灰度图像,它工作正常。我不知道

什么是错误?

谢谢!

【问题讨论】:

  • 究竟是什么不起作用。你会得到什么,你期望得到什么。另外,请发布与您如何获取深度图像相关的任何代码,以及是否对其进行了任何处理。

标签: c++ visual-c++ opencv kinect openni


【解决方案1】:

深度的范围大于0-256(你应该假设0-10000),也许这就是失败的原因......

【讨论】:

    猜你喜欢
    • 2014-04-13
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 1970-01-01
    • 2020-09-07
    • 2015-03-20
    • 1970-01-01
    相关资源
    最近更新 更多