改进实例1——加一个进度条控制横坐标bin
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
#define cvQueryHistValue_1D( hist, idx0 ) ((float)cvGetReal1D( (hist)->bins, (idx0)))
int hist_size= 200; //直方图横坐标——bin
int hist_height= 300; 直方图纵坐标——随意定
void on_trackbar( int pos ) ;
void main( )
{
IplImage * src= cvLoadImage("b.jpg");
IplImage* gray_plane = cvCreateImage(cvGetSize(src),8,1);
cvCvtColor(src,gray_plane,CV_BGR2GRAY);
float range[] = {
0,255}; //灰度级的范围
float* ranges[]={range}; //就是用指针指向这个数组,
//然后这个指针就能访问和控制这个数组了。
cvNamedWindow( "H-S Histogram", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "GraySource", CV_WINDOW_AUTOSIZE );
while(1)
{
cvCreateTrackbar( "position", "H-S Histogram",&hist_size,255, on_trackbar );