如何使用 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...
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬