#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;
}