[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BMP loading
From: |
A+A Adler |
Subject: |
Re: BMP loading |
Date: |
Thu, 16 Sep 1999 21:36:18 -0400 (EDT) |
On 16 Sep 1999, Bostjan JERKO wrote:
> Anybody know of possibility to load BMP image in octave to get image
> data as matrix ?
Try this
fid= popen('bmptoppm /path/to/file.bmp','r');
strcmp( fgetl(fid),'P6') || error('bailing');
[wid,len]=sscanf( fgetl(fid) , '%d %d' , 'C');
fgetl(fid);
data= reshape( fread(fid), 3, wid* len );
red= reshape( data(1,:), wid, len)';
green= reshape( data(2,:), wid, len)';
blue = reshape( data(3,:), wid, len)';
fclose(fid);
Caveats:
1. This has almost no error checking
2. This has not been debugged
3. You need to be on UNIX with the libgr tools installed
4. I've build a proper imread/imwrite functionality that
will do this, I should be able to contribute it soon
to octave-sources
______________________________________________________________
Andy Adler, address@hidden
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------
- BMP loading, Bostjan JERKO, 1999/09/16
- Re: BMP loading,
A+A Adler <=