Effacer les filtres
Effacer les filtres

Decompress binary image files

5 vues (au cours des 30 derniers jours)
Kavitha Srinivasan
Kavitha Srinivasan le 9 Août 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 commentaires
Walter Roberson
Walter Roberson le 9 Août 2012
"Hallo Northern Sky" ?
Kavitha Srinivasan
Kavitha Srinivasan le 10 Août 2012
No . thats proprietary file format. Dont know the expansion. But medical images (they are projections of CT)

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 10 Août 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 commentaires
Kavitha Srinivasan
Kavitha Srinivasan le 10 Août 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 le 10 Août 2012
Modifié(e) : Image Analyst le 10 Août 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?

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 10 Août 2012
  2 commentaires
Kavitha Srinivasan
Kavitha Srinivasan le 10 Août 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 le 10 Août 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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by