-
[Introduction to OpenCV] Load, Modify, and Save an ImageComputer Vision 2020. 7. 25. 17:09
#include <iostream> #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> using namespace std; using namespace cv; int main() { Mat img; img = imread("chemnitz.jpg",IMREAD_COLOR); if(!img.data){ cout<<"Could not open or find the image"<<endl; return -1; } Mat gray; cvtColor(img, gray, COLOR_BGR2GRAY); imwrite("/Users/kanakim/Coding/Opencv/chemnitz_gray.jpg", gray); namedWindow("Chemnitz", WINDOW_AUTOSIZE); namedWindow("Gray Chemnitz", WINDOW_AUTOSIZE); imshow("Chemnitz", img); imshow("Gray Chemnitz", gray); waitKey(0); return 0; }
-cvtColor ( source image, destination image, kind of transformation will be performed )
: 소스이미지를 BGR에서 원하는 형식으로 변환후 destination 이미지로 만든다
-imwrite( "path", image )
: 소스 이미지를 해당 경로에 저장
'Computer Vision' 카테고리의 다른 글
[The Core Functionality] Mask Operations on Matices (0) 2020.07.25 [The Core Functionality] How to scan Images, Lookup tables with Open CV (0) 2020.07.25 [ Introduction to OpenCV ] Load and Display an Image (0) 2020.07.25 [The Core Functionality] Mat - The Basic Image Container (0) 2020.07.25 X code 에서 Open CV 환경 만들기. (1) 2020.07.25