//读取图像保存为灰度图
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#include "opencv2/core.hpp"//基本图像数据处理库
#include "opencv2/highgui.hpp"
using namespace cv;
int main()
{
string url = "K:\\test.png.";
Mat color = imread(url);
Mat gray = imread(url, IMREAD_GRAYSCALE);//读取图像并转换为灰色图像
if (!color.data)
{
return -1;
}
imwrite("K:\\lenaGray.png", gray);//保存灰色图像
waitKey(0);
return 0;
}