float* part = new float[height * width * sizeof(float)];//height*width图片尺寸
float* all = new float[height * width * z * sizeof(float)];
FILE* rawfile;
for (int i = 0; i < z; i++)//z是切片数量
{
string path = "D:/data/XXXXXXX/";
path.append(to_string(i) + ".raw");//编号
const char* rawpath = path.c_str();
errno_t error = fopen_s(&rawfile, rawpath, "rb");
if (error == 0)
{
fread(part, sizeof(float), height * width * sizeof(float), rawfile);
}
memcpy(all+i*(height * width * sizeof(float)), part, height * width * sizeof(float));
//Mat temp(height,width,CV_32FC1,part);
}
fclose(rawfile);
FILE* wFile;
const char* path2 = "D:/data/XXXXXXXX.raw";//存储路径
fopen_s(&wFile, path2, "wb");
fwrite(all, height * width * z * sizeof(float),1, wFile);
delete[] all;
fclose(wFile);
vs c++实现raw多张切片数据合并成一张 float类型
于 2022-10-21 11:02:50 首次发布