最近在用opencv画直方图时,按照书上的例子程序,发现opencv 3 版本中没有cvQueryHistValue_1D这个函数,但是在以前的版本中都是有的,查看网上的解决方法是写一个宏,程序在下面:
#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
#define cvQueryHistValue_1D( hist, idx0 ) \
((float)cvGetReal1D( (hist)->bins, (idx0)))
int size = 255 ;
float range[] = { 0,255 }; float* ranges[] = { range };
//画直方图函数
IplImage* draw_hist_img(CvHistogram* hist, float scaleX, float scaleY) {
float histMax = 0;
cvGetMinMaxHistValue(hist, 0, &histMax, 0, 0);
IplImage* hist_img = cvCreateImage(cvSize(255 * scaleX, 64 * scaleY), 8, 1);
cvZero(hist_img);
f