學習c++版opencv3.4之2
阿新 • • 發佈:2018-12-11
載入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); }