how to open a binary *.bin file in Matlab

Hi all I have a binary Image file (1024*768) that I could open it through matlab using, fopen, fseek, fread. However, the image when viewed (imtool) is not correct. (seemed to have lots of lines in between). That is, the image matrix which is of size 1024*768 found to have every alternate rows being zero.(which is not correct). it is expected to have some pixel values entirely.
I checked my code by checking the status using , status = fseek(fileID, offset, origin).the code is working well. But the result is not expected one. Any help is much appreciated.
Regards

댓글 수: 4

Image Analyst
Image Analyst 2013년 3월 22일
편집: Image Analyst 2013년 3월 22일
Isn't this the same question you asked 7 months ago here: http://www.mathworks.com/matlabcentral/answers/45630-decompress-binary-image-files. You never seemed to finish that discussion, or mark an Answer as Accepted, for some reason.
Walter Roberson
Walter Roberson 2013년 3월 22일
What is the file size in bytes? Are you expecting the pixels to be unsigned or signed values? How many bytes per pixel are you expecting? RGB or grayscale?
each binary file is something like 3000 KB and they are uint16 values, grayscale images.
Walter Roberson
Walter Roberson 2013년 4월 4일
Please recheck the sizes. 1500 KB and 4500 KB (roughly) would be explainable, but 3000 KB does not work unless the entries are 32 bits instead of 16.

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

답변 (1개)

Image Analyst
Image Analyst 2013년 3월 22일

0 개 추천

That is not a standard format - it could be anything. People often use a .bin extension when they want to write it out in their own peculiar format. Unless you know what that is, you may have trouble guessing how to read it in. You can read it in with fread(), which you say you can do successfully, and then use imwrite() to write it out in a standard image format, such as PNG.

댓글 수: 2

this is not the same question as before. Last time, I was asking for how to decompress a binary file through matlab. But this time, I got a binary file and I want to open it through Matlab.The concern is , I don't want to save them in any of the image format.I just want to view them like anyother binary file.
Image Analyst
Image Analyst 2013년 3월 22일
편집: Image Analyst 2013년 3월 22일
There is no "any other binary file". All image files are binary and they have different formats. Some are standard (PNG, BMP, TIF, JPG, etc.) and some are custom/proprietary. Why do you not want to save them in any of the standard formats????? This just complicates things for yourself, as you can now see.

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

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2013년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by