MathGroup Archive 1998

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

Search the Archive

Re: reading graphics files



Russell Towle wrote:
> 
> 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
> ------------------------------

You lucked out with the "targa" format. It seems very close to a PPM
(Portable Pixel Map) format.  Try the same thing with a TIF, PICT, GIF,
or JPG  and I will buy you lunch if you can actually figure out the
file format just by looking at the numbers.  It will also show that you
are a genius at pattern recognition because those files are
compressed/encrypted in some way.



  • Prev by Date: Re: Simple integral over special functions---HOW?
  • Next by Date: UK Conference: Symposium in Technology for Mathematical Learning
  • Prev by thread: reading graphics files
  • Next by thread: CoefficientList[] option