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

来源:互联网 发布:三国志11古武将数据 编辑:程序博客网 时间:2024/05/17 06:04

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;}



0 0
原创粉丝点击