Search code examples
imagematlabbinaryfiles

Open 3D binary image in Matlab


I'm trying to open a .bin file in Matlab. The file is a xcat phantom of human body.

dims: 320,128,666 vxsize: 2.5,2.5,2.5 data type: 32-bit float, littleendian

And what I want is to open/see image of a specific slice of this file.


Solution

  • The XCAT phantom comes in raw format. Just use fopen, fread (with the precision flag set to the correct type) and fclose. Then you will likely need to reshape what fread returns.

    Once you have the 3D image in MATLAB, then just slice it with indexes img(:,100,:)