OpenCV学习之旅——输出图像信息到TXT
2017-09-26 14:35
1076 查看
目的:输出图像信息到TXT
代码示例:
原图:
TXT文档:
转载:> http://bbs.csdn.net/topics/391842084?page=1
代码示例:
#include <iostream> #include <fstream> #include <string> #include <windows.h> #include <gdiplus.h> #pragma comment(lib, "gdiplus.lib") using namespace std; using namespace Gdiplus; int main() { GdiplusStartupInput gdiplusstartupinput; ULONG_PTR gdiplustoken; GdiplusStartup(&gdiplustoken, &gdiplusstartupinput, NULL); wstring infilename(L"1.jpg"); string outfilename("color.txt"); Bitmap* bmp = new Bitmap(infilename.c_str()); UINT height = bmp->GetHeight(); UINT width = bmp->GetWidth(); cout << "width " << width << ", height " << height << endl; Color color; ofstream fout(outfilename.c_str()); for (UINT y = 0; y < height; y++) for (UINT x = 0; x < width ; x++) { bmp->GetPixel(x, y, &color); fout << x << "," << y << ";" << (int)color.GetRed() << "," << (int)color.GetGreen() << "," << (int)color.GetBlue() << endl; } fout.close(); delete bmp; GdiplusShutdown(gdiplustoken); return 0; }
原图:
TXT文档:
转载:> http://bbs.csdn.net/topics/391842084?page=1
相关文章推荐
- opencv输出图像数据到txt文件
- OpenCV学习笔记(5)图像的载入,显示和输出
- 【学习OpenCV】教程三:图像的载入,显示和输出
- Opencv学习三-图像的载入,显示和输出
- 【OpenCV学习笔记 003】图像的载入、显示和输出
- OpenCV 学习日记(二)---牛刀小试:输入输出图像和视频
- opencv学习(1)图像的载入、显示与输出
- opencv学习笔记——图像的载入、显示和输出
- OpenCV学习——图像信息读取和倒置
- 【OpenCV学习】图像信息读取和倒置
- opencv学习笔记----浅析图像的载入,显示和输出
- OpenCV学习记录 图像的载入、输出与显示
- OpenCv学习笔记(四)--Mat基本图像容器Mat对象信息头,矩阵体的创建,深复制,浅复制详解
- opencv输出特征数据、libsvm进行图像分类输出置信度、matlab输出ROC曲线
- opencv的几个图像载入、显示和输出的函数
- opencv学习之(五)-直方图计算和绘制图像直方图
- Opencv学习_2 (opencv结构&显示图像)
- opencv入门 - 显示图像学习总结
- DCMTK学习之利用RGB进行图像的输出时,图像反向的问题
- OpenCV学习笔记(16)双目测距与三维重建的OpenCV实现问题集锦(一)图像获取与单目定标