Decompress binary image files

2 visualizaciones (últimos 30 días)
Kavitha Srinivasan
Kavitha Srinivasan el 9 de Ag. de 2012
I have set of binary files each of which is compressed. Each file is a matrix of size 1024*768, uint32.The file is in specific format called hnd files. I would like to know whether Matlab could be of any help to me. AS such I cannot open the file in Matlab as it is compressed. But should be open once it is decompressed using ‘fopen’. Your help is much appreciated.
  2 comentarios
Walter Roberson
Walter Roberson el 9 de Ag. de 2012
"Hallo Northern Sky" ?
Kavitha Srinivasan
Kavitha Srinivasan el 10 de Ag. de 2012
No . thats proprietary file format. Dont know the expansion. But medical images (they are projections of CT)

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 10 de Ag. de 2012
If MATLAB's imread() can't read it, and you can't find a reader for it in the File Exchange, then you'll have to write one with fopen(), fread(), and fclose() like you mentioned. If you don't know the format, you can guess at the number of rows and columns until your image does not look interlaced or skewed anymore. Most formats have a header of some length, followed by the pixels. You might be able to figure out pretty closely where the header ends by opening up the image file in a binary/hex editor and seeing where the number pattern changes. Then skip that number of bytes with fseek() and read in with fread(). Change the number of rows and columns you pass in to get rid of the skew.
  2 comentarios
Kavitha Srinivasan
Kavitha Srinivasan el 10 de Ag. de 2012
Thanks for it. I am not getting the exact meaning of it still.May I send you the sample file .
Image Analyst
Image Analyst el 10 de Ag. de 2012
Editada: Image Analyst el 10 de Ag. de 2012
I may or may not get around to doing anything with it this weekend, but you can upload it. http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers. But if it's not just simply the bytes written out - like it's some kind of funky compression scheme - I won't be able to do anything. Why don't you ask whomever gave you the file if they will give you the format, or see if you can export the files to a standard format instead?

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 10 de Ag. de 2012
  2 comentarios
Kavitha Srinivasan
Kavitha Srinivasan el 10 de Ag. de 2012
Thanks for referrring to that. however, it was me who asked that before. The hnd files are compressed and I could not open it through any means. Now only when I decompress them, I will be able to read them in matlab. Kindly help.
Walter Roberson
Walter Roberson el 10 de Ag. de 2012
The Varian hnd file format appears to be specific to Varian, and the compression algorithm is not one I have seen anywhere else. You are not likely to find any pre-written MATLAB routine to do the work. It is possible to write a MATLAB routine to handle it, but easier would likely be to use the existing C++ plastimatch routines from http://forge.abcd.harvard.edu/gf/project/plastimatch/scmsvn/?action=browse&path=%2Fplastimatch%2Ftrunk%2Fsrc%2Fplastimatch%2Fbase%2Fhnd_io.cxx&revision=3395&view=markup&pathrev=3395 . Plastimatch is open source.

Iniciar sesión para comentar.

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by