Re: reading graphics files
- To: mathgroup@smc.vnet.net
- Subject: [mg12646] Re: [mg12597] reading graphics files
- From: Sean Ross <seanross@worldnet.att.net>
- Date: Sat, 30 May 1998 17:36:38 -0400
- References: <199805251825.OAA06271@smc.vnet.net.>
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.
- References:
- reading graphics files
- From: Russell Towle <rustybel@foothill.net>
- reading graphics files