How to make .bin file

17 visualizaciones (últimos 30 días)
hoang tuan
hoang tuan el 19 de Jun. de 2020
Respondida: Ameer Hamza el 19 de Jun. de 2020
I have image file (bmp), and i need to change it to format *.bin file.
Please help me if you know about it.
I tried below code but it seems the binary file is not good:
> a=imread("untitled.bmp")
>fid = fopen('binfile.bin', 'w+')
>fwrite (fid,a,'uint8')
>fclose(fid)
Thank you and Best Regards.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 19 de Jun. de 2020
"I tried below code but it seems the binary file is not good". How do you define "good"?
Following code shows the image is saved and loaded properly.
img = imread('pears.png');
fid = fopen('test.bin', 'w+');
fwrite(fid, img, 'uint8');
fclose(fid);
fid = fopen('test.bin', 'r');
img_loaded = uint8(fread(fid, inf, 'uint8'));
fclose(fid);
img_loaded = reshape(img_loaded, size(img));
imshow(img_loaded);

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by