n00b Question

Steve Freitas <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <1266822313.16307.414.camel@phat>
Hi all,

I've downloaded image data[1] which has no header and is comprised of
16-bit signed big-endian pixels (it's a heightmap). I figured I'd cull a
portion of the data and turn it into a TIFF so I could check it out
visually to make sure it looks kinda like a heightmap should. However, I
seem to be doing something wrong. I've read the data into a string (not
unicode, and the file was opened with 'rb'), and I'm using essentially
this code to generate a TIFF:

f = open('data.bin', 'rb')
data = f.read(<a subset of the file representing, say, Colorado>)
p = Image.fromstring('F', (tile_width, tile_height), data, 'raw',
'F;16BS', 0, 1)
p.save('foo.tiff')

I've verified that I'm pulling data that isn't just a bunch of zeros,
and I've verified that the generated TIFF isn't just a bunch of zeros,
but when I view it I get the checkerboard pattern which seems to
indicate a translucent image. Or something.

Part of my confusion comes from the interrelation between the two "mode"
arguments to Image.fromstring(). I guess the first one indicates the
kind of output mode you want, and the second one indicates the raw
decoder to use? But why am I specifying 'F' if the input data is all
integers? I tried changing them respectively to 'I' and 'I;16BS', but
that didn't change the resulting blank image.

Any tips appreciated!

Thanks,

Steve

[1] http://visibleearth.nasa.gov/view_rec.php?id=8391

_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.