//保存
unsigned short* output = new unsigned short[width * height]();
int index = 0;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
output[index] = aa.at<unsigned short>(i, j);
index++;
}
}
//保存二进制
ofstream fout("aa.bin", ios::binary);
fout.write((char*)(&output[0]), sizeof(unsigned short) * width * height);
fout.close();
//读取二进制
string str = "aa.bin";
unsigned short* freadbufs = new unsigned short[width * height];
std::ifstream ifs(str, std::ios::binary);
ifs.read((char*)freadbufs, sizeof(unsigned short) * width * height);
ifs.close();
读写二进制文件
于 2023-03-06 13:12:19 首次发布