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!