Convert an Image to a binary (.bin) file
조회 수: 19 (최근 30일)
이전 댓글 표시
Hello
I am trying to convert an image to a binary file (not binary image) for further processing in another software. I have tried the following code but does not seems to work as the file I am creating is zero bytes !
I= imread('cameraman.bin','w')
fid=fopen ('cameraman.bin','w');
fwrite(fid,I,'float32');
Can someone advice me on how to do this correctly ?
Thank you
댓글 수: 0
채택된 답변
Image Analyst
2013년 9월 16일
As far as I know there is no defined format for .bin. It's like .raw - you can basically define it however you want. You need to find out what format that other software package wants.
댓글 수: 0
추가 답변 (1개)
David Sanchez
2013년 9월 16일
Try this out:
I= imread('cameraman.tif');
level = .5;
BW = im2bw(I, level);
%choose your own options when writing to txt file
dlmwrite('myfile.txt', BW)
dlmwrite('myfile.txt', BW, 'delimiter', '\t', 'precision', 6)
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!