MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

reading graphics files



I saw some recent postings about using Mathematica to read and
manipulate image data, say, from a TIFF or PICT or some sort of
pixel-mapped file format. Since the last word seemed to be that reading
and working with such data was "supposed" to be feasible but in fact
was devilishly difficult, I decided to have a try.

I happened to have a 24-bit Targa file on hand with 180 columns of 200
pixels per column. I had made it in such a way that the red and green
bytes together formed 16-bit numbers, while the blue byte was empty.

Without knowing anything about the particulars of the Targa file format,
I opened it using OpenRead and read in a bunch of Numbers using
ReadList. About twenty numbers in from the beginning, I saw the numbers
180 and 200. Shortly thereafter, a long series in which every third
number was zero, was seen.

These triples were of course the red, green, and blue bytes. I went no
further, but my sense of the matter was, that, if one knew the
structure of such-and-such a file format: how long the header was,
where to find the row and column counts, at what point the actual pixel
data commenced--then one could easily read such data into Mathematica
expressions and apply transformations to it. By the same token, knowing
a particular file format, one could also use Mathematica to write a
pixel-mapped file to disk in that format.

Russell Towle
Giant Gap Press:  books on California history, digital topographic maps
P.O. Box 141
Dutch Flat, California 95714
------------------------------
Voice:  (916) 389-2872
e-mail:  rustybel@foothill.net
------------------------------




  • Prev by Date: write global vars while processing NDSolve
  • Next by Date: Re: ListPlot?
  • Prev by thread: write global vars while processing NDSolve
  • Next by thread: Re: reading graphics files