近日研究CT三维重建功能,将.dat格式的读取和显示记录下来,欢迎高手指点,共同进步。
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <fstream>
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;
}