请广大博友转载时,注明文章出处,谢谢!!!
这个是对上一篇,在反投影算法中使用颜色信息的一个拓展,理解了上一篇和鼠标事件后,这个就是组合
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/imgproc/types_c.h>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include<iostream>
#include<vector>
#include<opencv2/nonfree/features2d.hpp>
#include<opencv2/legacy/legacy.hpp>
#include<opencv2/features2d/features2d.hpp>
#include<opencv2/calib3d/calib3d.hpp>
#include<opencv2/video/tracking.hpp>
using namespace cv;
using namespace std;
class Package
{
private:
public:
Mat CalcBack_Color(const Mat &InImage, const Rect &rectROI);
MatND ComterGrayHistogram(const Mat &InImage, bool isdisplay, bool isshow, const Scalar &color, int channelsnum);
Mat colorReduce(const Mat &InImage, int div);
};
Mat Package::colorReduce(const Mat &InImage, int div)
{
Mat OutImage(InImage.rows, InImage.cols, InImage.type());
int x = InImage.rows;
int y = InImage.cols*InImage.channels();
for (int i = 0; i < x; i++)
{
const uchar* data = InImage.ptr<const uchar>(i);
uchar* data_out = OutImage.ptr<uchar>(i);
for (int j = 0; j < y; j++)
{
data_out[j] = d