opencv灰度直方图
感觉这个原理就是数学统计吧,直接上代码,哪有错的或者不懂得地方,欢迎交流。
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
class jRect { //自己写了个jRect类,感觉是吃饱了撑着吧
public:
jRect(Point p,int w,int h)
:lefttop(p),rect_width(w),rect_height(h){}
Point lefttop;
int rect_width;
int rect_height;
};
void grayhist(Mat &input_gray,Mat &output_histogram, const Scalar &histColor,int hist_width=2);//绘制直方图
void drawjRect(Mat &input,jRect rect, const Scalar &jRec