help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I read an image into octave?


From: Neil Davey
Subject: Re: How do I read an image into octave?
Date: Mon, 6 Dec 1999 16:06:04 +1000 (EST)

On Mon, 6 Dec 1999, Alasdair McAndrew wrote:

> Hi there,

Greetings..
 
> I've just successfully compiled octave under linux; I'd like to use it
> to test some image processing algorithms.  But according to the info
> pages, images must be in octave's "img" format.  This is all very
> well, but how do I get a pgm/tif/gif/png image into that format?  Are
> there any file handling routines which will take, say, a 256 grey level
> pgm image and produce a matrix in octave?
>
> In other word, is there an octave equivalent to MATLAB's "imread"
> command?

I know of one way... there may be others so pls correct me if I'm wrong..

the file format pgm/ppm is a very simple and easy format to read in, I had
to do it for an image processing project in C. If you look at the header
of a pgn/ppm file created by XV you get this:

-----------------
P5
# CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2)
# CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2)
511 344
255
(etc)
----------------

The 4th line is the x and y dimensions of the file (511x344), and the next
line is the max colour code in gray scale, so since it's 255, the file is
in 8bit gray scale. What follows after that is the images data dumped in
one big long stream. This is were it gets a bit hazy, it's been about
12month since I did this.... I think the data is row dumped, ie

|--row 1 (511 bytes)--||--row 2 (511 bytes)--| etc etc |-- row 344--|

you can use the C command fopen and fread in octave to build scripts that
will read in and build a matrix. make sure to set fopen to read binary..

as I said, there may be an easier may... this is just a may I have used
before... 

cheers
        Neil

> Thanks for this.
> 
> cheers,
> 
> -- 
> Alasdair McAndrew
> 
> School of Communications and Informatics     Phone: +61 3 9688 4344
> Victoria University of Technology            Fax:   +61 3 9688 4050
> P.O. 14428, Melbourne City Mail Centre  address@hidden
> Melbourne, Vic 8001, Australia         http://cams.vut.edu.au/~amca
> 
> 
> 
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
> How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
> Subscription information:  http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Neil Davey
Postgraduate Research Student
Radio Science Laboratory
School of Microelectronic Engineering
Griffith University, Nathan, QLD Australia 4111
Ph: 3875 5574
Fax: 3875 5198
Mobile: 0414 662 110

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        Life is but a journey involving bigger and bigger fences

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Linux - Don't fear the penguin......



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]