How to read a .dat file and creat a 3D image

1 回表示 (過去 30 日間)
Fangzhou Wang
Fangzhou Wang 2016 年 8 月 12 日
編集済み: Giao Vu 2019 年 12 月 3 日
Hello there,
There's a .dat file in which the value at each voxel is 1 (solid) or 0 (pore). Dose anyone know how to import this .dat file into Matlab and creat a 3D image of porous media?
Thank you,
Rick

回答 (1 件)

Giao Vu
Giao Vu 2019 年 12 月 3 日
編集済み: Giao Vu 2019 年 12 月 3 日
first u need to know:
  • how the data is stored (in 2D it is very straightforward, but not in 3D): is it slice by slice (which plane, xy,xz,or yz)
  • data type and format (binary, or integer?)
  • data size for each dimension x,y,z
fileid = fopen('mydata.dat','r');
data = fread(fileid, inf, 'single', 'ieee-be'); %read till the end of file
data = reshape(data,[dimx dimy dimz]); % reshape data

カテゴリ

Help Center および File ExchangeBiomedical Imaging についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by