opencv1-加载、修改、保存图像

我的实践: 

#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表示成功执行此函数
}

猜你喜欢

转载自blog.csdn.net/weixin_38383877/article/details/89180255