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

7 visualizaciones (últimos 30 días)
Liam Day
Liam Day el 2 de Feb. de 2016
Comentada: Liam Day el 2 de Feb. de 2016
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.

Respuesta aceptada

James Tursa
James Tursa el 2 de Feb. de 2016
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 comentario
Liam Day
Liam Day el 2 de Feb. de 2016
This is giving me a [128 128 128] array, thank you for your help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by