[Image-SIG] 16 bit TIFF support

Roger Burnham rburnham@cri-inc.com
Tue, 1 Jun 1999 12:45:45 -800


Thanks to all who responded to my "Need 12 or 16 bits/pixel images" query.  

As David Ascher said, my app is one where > 8 bits is needed for optimal 
analysis.

This is to announce that I have added 16 bit luminance image support to Imaging-
1.0b1.

I usurped the TIFF 16 bit 'L' mode (which converted 16 bit images to 8 bits), and 
called it mode 'W' (word length bits).  

It all seems to work for the Imaging functions my apps use, altho there is some 
tiff functionality missing from 1.0b1: e.g. writing a tiff file does not write 
out the tags that were read in (working on this).

Going thru the diffs, this is what I've implemented for 16 bit grayscale images:

   TYPE_UINT16 and IMAGING_TYPE_UINT16 defines
   added UINT16 *image16 member to the ImagingInstance structure
   point operations (not tested)
   getpixel
   getink (not tested)
   histogram
   putdata (not tested)
   putpixel
   export the PyCObject (ala Numeric) for extensions to "import_imaging();"
      (extensions #include "ImageObject.h" instead of Image.h)
   in map.c and imDib.h , undef INT32 and UINT32 before including windows.h to    
      avoid compiler error.
   blend operations
   chop operations (some tested)
   convert 'W' to 'L'
   draw operations (untested)
   spread effect (random pixels) (untested)
   disallow fill operations on 'W' images
   filter operations (untested)
   geometry ops (untested)
   getbbox (untested)
   offset (untested)
   added a     {"W",	"W",   		16,	packW16B} packer
   appropriate paste operations (some tested)
   quantize (untested)
   create new 16 bit 'W' images
   added     {"W",	"L;16B",  	16,	unpackW16B},
                 {"W",	"W",       	16,	unpackW16B}, unpackers

   In TiffImagePlugin, changed OPEN entry
         (1, (16,)): ("L", "L;16B"),
      to 
         (1, (16,)): ("W", "L;16B"),

      added a SAVE entry
         "W": ("W", 16, 1),


The point of all this is that this is my first time delving into pil internals, 
and I'm sure I'm on shaky ground in places (particularly the nuances of packers 
and unpackers) and am asking if anyone who is familiar with the Imaging API would 
be willing to review and comment on what I've done, so that I can clean up, add, 
or delete functionality as appropriate before submitting the changes to Fredrick 
(I've gotten no responses from /F, is he the right place to submit patches?).

Cheers,

Roger Burnham   
Cambridge Research & Instrumentation   
rburnham@cri-inc.com   
http://www.cri-inc.com/   
http://starship.python.net/crew/roger/   
PGP Key: http://www.nai.com/default_pgp.asp   
PGP Fingerprint: 5372 729A 9557 5F36 177F  084A 6C64 BE27 0BC4 CF2D