///*
#include <opencv2\opencv.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
///*
int main()
{
FILE *fin;
int a[40][40];
int i,j;
fin = fopen("D:\\rgbbina.txt", "r"); // 打开文件,按读的方式打开
for (i = 0; i<40; i++)
for (j = 0; j<40; j++)
fscanf(fin, "%x", &a[i][j]); // 循环读
fclose(fin); //关闭文件
for (i = 0; i<40; i++)
for (j = 0; j<40; j++)
printf("%x\n", a[i][j]); //输出来看看
//system("pause");
//return 0;
//新建一个uchar类型的单通道矩阵(grayscale image 灰度图)
//Mat m(40, 40, CV_8UC3);
Mat m(40, 40, CV_8UC3, Scalar(30, 110, 55));
//Mat m(40, 40, CV_32FC3, Scalar(0.0, 0.0, 0.99));
//m.at<int>(20, 20) = ( 0,0,255);
for (i = 0; i<40; i++)
for (j = 0; j<40; j++)
{
m.at<Vec3b>(i, j)[0] = a[i][j];
m.at<Vec3b>(i, j)[1] = a[i][j]>>8;
m.at<Vec3b>(i, j)[2] = a[i][j]>>16;
}
/*
m.at<Vec3b>(20, 20)[0] = 1;
m.at<Vec3b>(20, 20)[1] = 1;
m.at<Vec3b>(20, 20)[2] = 1;
m.at<Vec3b>(20, 21)[0] = 1;
m.at<Vec3b>(20, 21)[1] = 1;
m.at<Vec3b>(20, 21)[2] = 1;
m.at<Vec3b>(20, 22)[0] = 1;
m.at<Vec3b>(20, 22)[1] = 1;
m.at<Vec3b>(20, 22)[2] = 1;
m.at<Vec3b>(20, 23)[0] = 1;
m.at<Vec3b>(20, 23)[1] = 1;
m.at<Vec3b>(20, 23)[2] = 1;
*/
/*
m.at<Vec3f>(20, 20)[0] = 1;
m.at<Vec3f>(20, 20)[1] = 1;
m.at<Vec3f>(20, 20)[2] = 1;
*/
//m.at<uchar>(30, 30) = 255;
/*
for (int col = 0; col < 400; col++)
{
for (int row = 195; row < 205; row++)
{
cout << (int)(*(m.data + m.step[0] * row + m.step[1] * col)) << " ==> ";
//获取第[row,col]个像素点的地址并用 * 符号解析
*(m.data + m.step[0] * row + m.step[1] * col) = 255;
cout << (int)(*(m.data + m.step[0] * row + m.step[1] * col)) << endl;
}
}
*/
///*
imshow("canvas", m);
cvWaitKey();
return 0;
}
//*/