整体程序:
#include "tablewidget.h"
#include
#include
#include
#include
#include
void readData()//读入一张图的数据,将txt的二维数据传输到二维数组中
{
std::ifstream fin;
fin.open("Imagedata.txt");
if (fin.fail())
{
std::cout << "File open error!";
int m;
std::cin >> m;
}
else{
for (int i = 0; i < 85425; i++)
{
for (int j = 0; j < 33; j++){
fin >> imageData[i][j];
}
}
fin.close();
}
}
int x=1;
int y=20;//原本三维数组(225,355,33)转换成(85425,33)的矩阵
int location = (x-1)*355+y;//225*355的图上坐标为(x,y)的点数据存储在第location行
double imageData[85425][33];//(1,1)的点在第一行,(1,2)的点在第二行。。。(1,355)点