여기에서는 OpenCV 이미지를 컴퓨터의 모든 위치에 저장하는 방법을 이해합니다. OpenCV는 imwrite()를 제공합니다. 이미지를 지정된 파일에 저장하는 기능입니다. 파일 확장자는 이미지 형식을 나타냅니다.
함수의 실제 형식은 -
입니다.imwrite("Destination/Name of the image with extension", Source Matrix) 여기서 "Destination"은 이미지를 저장할 위치입니다. 이 프로그램에서는 이미지를 "Lakshmi.jpg"로 저장합니다. 이미지에 어떤 이름도 지정할 수 있습니다. "소스 매트릭스"는 이미지가 로드된 매트릭스입니다. 이 프로그램에서 이미지는 "myImage" 행렬로 로드됩니다.
예시
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc,const char** argv) {
Mat myImage;//declaring a matrix named myImage//
myImage = imread("lena.png");//loading the image named lena in the matrix//
imwrite("lakshmi.jpg", myImage);
waitKey(0);//wait till user press any key
destroyWindow("MyWindow");//close the window and release allocate memory//
cout << "Image is saved successfully…..";
return 0;
} 출력
Image is saved successfully...