【发布时间】:2017-12-22 08:26:50
【问题描述】:
我正在尝试使用 OpenCV for C# (EmguCV) 从图像中计算直方图。
这是我的代码:
VectorOfMat bgr_planes = new VectorOfMat();
CvInvoke.Split(myImage, bgr_planes);
int[] dim = new int[] { 0 };
int[] histSize = new int[] { 256 };
float[] range = new float[] { 0f, 255f };
bool accumulate = false;
Mat b_hist = new Mat();
Mat g_hist = new Mat();
Mat r_hist = new Mat();
CvInvoke.CalcHist(bgr_planes, dim, new Mat(), b_hist, histSize, range, accumulate);
CvInvoke.CalcHist(bgr_planes, dim, new Mat(), g_hist, histSize, range, accumulate);
CvInvoke.CalcHist(bgr_planes, dim, new Mat(), r_hist, histSize, range, accumulate);`
但我没有得到数据 b_hist、g_hist 和 r_hist。我无法处理bgr_planes[0] 的特定频道,因为它们属于Mat 类型,并且会引发错误。
如何调整参数dim、histSize和range以获得颜色直方图?
非常感谢您的帮助!
【问题讨论】:
标签: c# histogram emgucv opencv3.0 mat