学习c++版opencv3.4之2

加载imread,修改cvtColor,保存imwrite图像。

#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

int main()
{
    Mat src, dst;
    src = imread("/Users/ming/Documents/test.jpg");
    if (src.empty()){
        printf("cannot load the image...");
    }
    namedWindow("src img", CV_WINDOW_AUTOSIZE);
    imshow("src img", src);
    
    cvtColor(src, dst, CV_BGR2GRAY); //bgr to gray
//    cvtColor(src, dst, CV_BGR2RGB); //bgr to rgb
//    cvtColor(src, dst, CV_BGR2HSV);
    namedWindow("gray img");
    imshow("gray img", dst);
    imwrite("/Users/ming/Documents/test_gray.jpg", dst);
    
    waitKey(0);
}

猜你喜欢

转载自blog.csdn.net/u010397980/article/details/82820300