您的位置:首页 > 运维架构

OpenCV 读RGB图像然后转换成灰度并保存成灰度图

2017-01-09 19:18 351 查看
1、imread 读入图像,最后一个参数0表示按灰度读入

2、imwrite 保存成新的图像

#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
cout<<argc<<endl;
cout<<argv[0]<<endl;
Mat image = imread("pathPlanningPlatform.png", 0);
namedWindow("picture1", CV_WINDOW_AUTOSIZE);
cout<<"Image In Rows : "<<image.rows<<endl;
cout<<"Image In Columns : "<<image.cols<<endl;
imshow("picture1", image);
waitKey(0);
imwrite("pathPlanningPlatformOut.png",image);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: