How to input data from a .bin file into a 3D array?

조회 수: 13 (최근 30일)
Liam Day
Liam Day 2016년 2월 2일
댓글: Liam Day 2016년 2월 2일
I have a .bin file which signifies the positions of lungs from CT imaging, in 3D size [128 128 128]. I am trying to upload it using fopen and fread but it only gives a single 2D image size [128 128 1].
My code:
fid = fopen('filedirectoryandname.bin')
image = fread(fid, [128 128 128], '*uint16')
I don't think fread can work wth [128 128 128] images. Is there another way?
I have also tried the function interfileread but apparently my .bin file isn't a valid interfile file.

채택된 답변

James Tursa
James Tursa 2016년 2월 2일
You could read it into a vector and then reshape. E.g.,
image = fread(fid, 128*128*128, '*uint16');
image = reshape(image,128,128,128);
  댓글 수: 1
Liam Day
Liam Day 2016년 2월 2일
This is giving me a [128 128 128] array, thank you for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by