Re: Convert image to binary file
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Thu, 31 Jul 2008 10:00:39 -0400
"Hgbreton Hughes" <abc@xxxxxxxxx> writes:
Hi. I'm trying to use Matlab to convert a black and white
image into a sting of bits which can then be used as the
input to an artificial neural network. I have the code
below, but when I execute it the output file is blank.
BW = imread('image1.bmp');
fid = fopen('exp.txt', 'w');
count = fwrite(fid, BW);
fclose(fid);
Does anyone know what I am doing wrong? I need the matrix
to be read line by line into a string of bits with a space
between each bit. e.g. for a 2*2 image with a white pixel
in the top left hand corner the output should be 1 0 0 0.
If you want exp.txt to actually be a text file, then fwrite is the wrong
command, and in addition you need to open the file in text mode, for
correct line ending handling:
fopen('exp.txt', 'wt')
As it is, exp.txt is probably a binary file, which has a misleading
extension.
-Peter
.
- References:
- Convert image to binary file
- From: Hgbreton Hughes
- Convert image to binary file
- Prev by Date: Re: concurrency + threads + synchronization
- Next by Date: Re: linear equation with restrictions
- Previous by thread: Convert image to binary file
- Next by thread: Re: Convert image to binary file
- Index(es):
Relevant Pages
|