Opencv读取.dat格式CT数据

近日研究CT三维重建功能,将.dat格式的读取和显示记录下来,欢迎高手指点,共同进步。


#include "stdafx.h"
#include
#include
using namespace std;
using namespace cv;


int main()
{
    ifstream file("*.dat", ios::in | ios::binary);

    int height = 512; //需要预先知道
    int width = 512;  //需要预先知道

    Mat img;
    img.create(height, width, CV_8UC1);
    file.read((char*)img.data, height*width);

    namedWindow("show", CV_WINDOW_NORMAL);
    resizeWindow("show", height, width);
    imshow("show", img);

    waitKey(0);


    return 0;
}

Opencv读取.dat格式CT数据_第1张图片

你可能感兴趣的:(数字图像处理)