版权声明:——转载请留言询问—— https://blog.csdn.net/weixin_44344462/article/details/88743965
转换结果
原图像
灰度图像
Show me the code
#include <iostream>
#include <string>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
int main() {
// 图像路径
const string fileName = "xxx.jpg";
// 读取图像
cv::Mat origin = cv::imread(fileName);
// 开辟result存放结果
cv::Mat result;
// RGB转换成GRAY
cv::cvtColor(origin,
result,
cv::COLOR_BGR2GRAY);
// 显示原图像与结果
cv::imshow("Origin Image", origin);
cv::imshow("Result", result);
cv::waitKey(0);
}