vs c++实现raw多张切片数据合并成一张 float类型

    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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值