如何使用 C++ 在 OpenCV 中保存图像?
在这里,我们将了解如何将OpenCV图像保存到您计算机上的任何位置。OpenCV提供imwrite()了将图像保存到指定文件的功能。文件扩展名代表图像格式。
该函数的实际格式是-
imwrite("Destination/Name of the image with extension", Source Matrix)在这里,“目的地”是我们想要保存图像的地方。在这个程序中,我们将图像保存为“Lakshmi.jpg”。我们可以给图像起任何名字。“源矩阵”是图像已加载的矩阵。在这个程序中,图像被加载为“myImage”矩阵。
示例
#include输出结果#include 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);//等到用户按任意键 destroyWindow("MyWindow");//close the window and release allocate memory// cout << "Image is saved successfully….."; return 0; }
Image is saved successfully...
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语