我的实践:
#include<opencv2\opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main()
{Mat src = imread("E:\\vs2015\\opencvstudy\\2.jpg", 1);if (src.empty()){cout << "could not load the image!" << endl;return -1; //返回-1代表函数执行失败}imshow("input", src);Mat output_image;cvtColor(src, output_image, CV_BGR2GRAY);imshow("灰度图", output_image);imwrite("gray.jpg", output_image);waitKey(0);return 0; //返回值为0表示成功执行此函数
}