Decompress binary image files

조회 수: 2 (최근 30일)
Kavitha Srinivasan
Kavitha Srinivasan 2012년 8월 9일
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
Walter Roberson
Walter Roberson 2012년 8월 9일
"Hallo Northern Sky" ?
Kavitha Srinivasan
Kavitha Srinivasan 2012년 8월 10일
No . thats proprietary file format. Dont know the expansion. But medical images (they are projections of CT)

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

채택된 답변

Image Analyst
Image Analyst 2012년 8월 10일
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
Kavitha Srinivasan
Kavitha Srinivasan 2012년 8월 10일
Thanks for it. I am not getting the exact meaning of it still.May I send you the sample file .
Image Analyst
Image Analyst 2012년 8월 10일
편집: Image Analyst 2012년 8월 10일
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?

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 8월 10일
  댓글 수: 2
Kavitha Srinivasan
Kavitha Srinivasan 2012년 8월 10일
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 2012년 8월 10일
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.

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

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by