OpenCV读取图像,保存为灰度图
作者:三味书屋 来源: 2022/2/21 16:47:45
//读取图像保存为灰度图
#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;
}  
称      呼:
联系方式:
您的评论:
技术支持:l.w.dong@qq.com www.luweidong.cn
广州市   wx:lwdred
Copyright © 2014 三味书屋 All Rights Reserved
技术支持:l.w.dong@qq.com  sitemap xml  sitemap html

粤公网安备44010602011869号

粤ICP备13031080号-1