方法一:指针访问
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
void colorReduce(Mat& inputImage, Mat& outputImage, int div);
void ShowHelpText();
int main()
{
//【1】创建原始图并显示
Mat srcImage = imread("1.png");
imshow("原始图像", srcImage);
//【2】按原始图的参数规格来创建创建效果图
Mat dstImage;
dstImage.create(srcImage.rows, srcImage.cols, srcImage.type());//效果图的大小、类型与原图片相同
//【3】记录起始时间
double time0 = static_cast<double>(getTickCount());
//【4】调用颜色空间缩减函数
colorReduce(srcImage, dstImage, 32);
//【5】计算运行时间并输出
time0 = ((double)getTickCount() - time0) / getTickFrequency();
cout << "\t此方法运行时间为:" << time0 << "秒" << endl; //输出运行时间
//【6】显示效果图
imshow("效果图", dstImage);
waitKey(0);
}
void colorReduce(Mat& inputImage, Mat& outputIma