Opencv中将图片的像素值保存到vector容器中,并保存为文本文档
来源:互联网 发布:淘宝店铺打印快递单 编辑:程序博客网 时间:2024/05/25 21:36
#include<iostream>
#include<vector>
#include<string>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<fstream>
using namespace std;
using namespace cv;
int main()
{
ifstream file("E://tu//menglu.txt");
ofstream outfile;
outfile.open("E://tu//liu.txt");
if (!outfile)cout << "error" << endl;
string ImgName;
string imgName;
vector <Mat>channels;//定义通道`
vector<int> vec_lie;
vector<int> awai{1, 2 ,3 ,4};
while (getline(file, ImgName))
{
// cout << "处理:" << ImgName << endl;
imgName = "E://tu//" + ImgName ;
Mat img = imread(imgName);
/*cout << "img.type()=" << img.type() << endl;
cout << "img.channel: " << img.channels() << endl;*/
for (int i = 0; i < img.rows; i++)
{
for (int j = 0; j < img.cols; j++)
{
int v = img.at<Vec3b>(i, j)[1];
vec_lie.push_back(v);
}
}
}
for (auto i = vec_lie.begin(); i < vec_lie.end(); i++)
{
cout << *i << " ";
outfile << *i << " ";
}
outfile.close();
//outfile.close();
cout << endl;
cout << vec_lie.size() << endl;
//for (auto j =awai.begin(); j < awai.end(); j++)
//{
// vec_lie.push_back(*j);
//}
//cout << "添加之后的大小为:" << vec_lie.size() << endl;
return 0;
}
#include<vector>
#include<string>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<fstream>
using namespace std;
using namespace cv;
int main()
{
ifstream file("E://tu//menglu.txt");
ofstream outfile;
outfile.open("E://tu//liu.txt");
if (!outfile)cout << "error" << endl;
string ImgName;
string imgName;
vector <Mat>channels;//定义通道`
vector<int> vec_lie;
vector<int> awai{1, 2 ,3 ,4};
while (getline(file, ImgName))
{
// cout << "处理:" << ImgName << endl;
imgName = "E://tu//" + ImgName ;
Mat img = imread(imgName);
/*cout << "img.type()=" << img.type() << endl;
cout << "img.channel: " << img.channels() << endl;*/
for (int i = 0; i < img.rows; i++)
{
for (int j = 0; j < img.cols; j++)
{
int v = img.at<Vec3b>(i, j)[1];
vec_lie.push_back(v);
}
}
}
for (auto i = vec_lie.begin(); i < vec_lie.end(); i++)
{
cout << *i << " ";
outfile << *i << " ";
}
outfile.close();
//outfile.close();
cout << endl;
cout << vec_lie.size() << endl;
//for (auto j =awai.begin(); j < awai.end(); j++)
//{
// vec_lie.push_back(*j);
//}
//cout << "添加之后的大小为:" << vec_lie.size() << endl;
return 0;
}
阅读全文
0 0
- Opencv中将图片的像素值保存到vector容器中,并保存为文本文档
- 读取图片像素,保存到文档中,并灰度
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- OpenCV中将视频保存为连续的图片和连续的图片保存为视频
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- OpenCV读取RGB图像像素值,并保存到txt中
- Java中将图片保存到数据库中
- java中将图片保存到数据库中
- java中将图片保存到数据库中
- Android中将图片保存到数据库中
- opencv中批量读取图片并保存
- opencv中批量读取图片并保存
- opencv 保存灰度图像的像素值
- opencv 保存灰度图像的像素值
- 代码混淆后自定义view报空指针
- jieba “结巴”中文分词:做最好的 Python 中文分词组件
- [凸包] BZOJ1069: [SCOI2007]最大土地面积
- 数据库中仅存身份证号通过JavaBean获取生日和年龄
- 编程作业题之二-临时抱佛脚
- Opencv中将图片的像素值保存到vector容器中,并保存为文本文档
- 悲观锁
- 图论总结 下
- 浅谈关于移动端自动化构建
- QDU 良辰最喜欢良辰最喜欢对那些自认能力出众的人出手(Lucas定理推广)
- 网络请求之HTTP和HTTPS
- Android之启动模式
- Redis学习第四节
- cocos2dx-3.10例子无法编译android版本