如何使用 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 生日广州男生祝福语简短